Skip to content

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

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/justllms-repository-improvements-c86b
Draft

fix: include tool fields in CompletionResponse.to_dict()#51
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/justllms-repository-improvements-c86b

Conversation

@cursor

@cursor cursor Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

CompletionResponse.to_dict() only serialized role and content on messages, which dropped tool_calls and tool_call_id needed for multi-turn tool workflows. It also omitted tools_used, tool_execution_cost, and tool_execution_history.

Changes

  • Use message.model_dump() for full message serialization (includes tool_calls, tool_call_id, name, function_call)
  • Include logprobs on choices when present
  • Append tool execution metadata (tools_used, tool_execution_cost, tool_execution_history) when set
  • Add unit tests in tests/test_completion_response.py

Testing

All CI checks pass locally:

  • ruff check justllms/
  • black --check justllms/
  • mypy justllms/ --ignore-missing-imports
  • pytest tests/ -v (97 tests)
  • python -m build + wheel import verification
Open in Web View Automation 

cursoragent and others added 2 commits June 13, 2026 09:36
CompletionResponse.to_dict() only serialized role and content on messages,
dropping tool_calls and tool_call_id needed for multi-turn tool workflows.
It also omitted tools_used, tool_execution_cost, and tool_execution_history.

Use message.model_dump() for full message serialization and append tool
metadata when present.

Co-authored-by: Darshan Harihar <DarshanHarihar1@users.noreply.github.com>
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 13, 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