Skip to content

fix: include tool fields in CompletionResponse.to_dict()#52

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/justllms-repository-improvements-e5b7
Draft

fix: include tool fields in CompletionResponse.to_dict()#52
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/justllms-repository-improvements-e5b7

Conversation

@cursor

@cursor cursor Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

CompletionResponse.to_dict() was dropping tool-related metadata when serializing responses. This fix ensures tool calling results are preserved for logging and downstream consumers.

Changes

  • Serialize full message fields (including tool_calls and tool_call_id) via Message.model_dump()
  • Include tools_used, tool_execution_cost, and tool_execution_history when set
  • Add unit tests covering tool call serialization and optional tool metadata fields

Testing

All CI checks pass locally:

  • ruff check justllms/
  • black --check justllms/
  • mypy justllms/ --ignore-missing-imports
  • pytest tests/ -v (97 tests)

Branch

Feature branch: darshan/fix-completion-response-to-dict

Open in Web View Automation 

CompletionResponse.to_dict() dropped tools_used, tool_execution_history,
tool_execution_cost, and tool_calls from serialized messages. Extend
serialization to preserve tool metadata for logging and downstream
consumers, with unit tests.

Co-authored-by: Darshan Harihar <DarshanHarihar1@users.noreply.github.com>
@github-actions github-actions Bot added core tests bug Something isn't working llm size/M labels Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant