Skip to content

Coerce ToolCallItem/ToolCallOutputItem call_id to str | None consistently#3541

Open
jluocsa wants to merge 1 commit into
openai:mainfrom
jluocsa:fix/tool-call-id-str-coercion
Open

Coerce ToolCallItem/ToolCallOutputItem call_id to str | None consistently#3541
jluocsa wants to merge 1 commit into
openai:mainfrom
jluocsa:fix/tool-call-id-str-coercion

Conversation

@jluocsa
Copy link
Copy Markdown
Contributor

@jluocsa jluocsa commented May 31, 2026

Summary

ToolCallItem.call_id and ToolCallOutputItem.call_id returned the raw value untouched on the object branch, so a non-string call_id/id (e.g. an int) leaked through despite the str | None return annotation. This makes both properties consistently coerce to str | None, matching the canonical behavior of extract_tool_call_id in run_internal/tool_execution.py.

Changes

  • ToolCallItem.call_id and ToolCallOutputItem.call_id now coerce the resolved value to str (or None when absent) on both the dict and object branches.

Test plan

  • Added unit tests in tests/test_items_helpers.py:
    • dict and object raw items with string call_id return the string unchanged.
    • a non-string (int) call_id is coerced to "123".
    • a missing call_id returns None.
  • make format, make lint, make typecheck, and the full make tests suite pass (4615 passed, 11 skipped).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant