-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Python: Bug: Streaming replies error – final ResponseOutputMessage missing .delta on large runs #12296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Digging a bit deeper Root cause – Since March 2025 the OpenAI/Azure Responses API appends a terminal object of type ResponseOutputMessage to every streamed run. This object exposes its payload in .content and deliberately has no .delta. By contrast, the incremental events SK was written for (ResponseTextDeltaEvent, ResponseMessageDeltaEvent, etc.) all carry their chunk under .delta. Why we hit it mostly with tool calls – Whenever the model returns a tool_calls array, the SDK is required (per the Assistants spec) to emit the consolidated ResponseOutputMessage so you get a valid, schema-complete assistant message — see the “Final message” note in the official Assistants streaming docs. Plain-text replies may skip that step when the answer is short, which is why non-tool completions often survive. Trigger pattern – Any long response (many tokens) or any function-calling response, because both reliably produce the final ResponseOutputMessage. Effect in SK – In responses_agent_thread_actions.py the stream loop still assumes every event owns .delta; when the last object doesn’t, Python raises Impact – Hard stop: the completed assistant message (and any tool_calls) never reaches callers, breaking both user UX and planner logic. I’m putting together a concise fix and will open a PR shortly. Just wanted to document the investigation so everyone sees it’s a general streaming issue rather than something unique to function calls. |
…alls_from_output - Updated type annotation from list[ResponseFunctionToolCall] to list[ResponseOutputItem < /dev/null | ResponseOutputMessage] to accurately reflect actual input types - Improved filtering to only process ResponseFunctionToolCall objects, safely ignoring other types like ResponseOutputMessage - Removed problematic .delta access and dangerous cast operations that caused AttributeError: 'ResponseOutputMessage' object has no attribute 'call_id' Fixes microsoft#12296 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…alls_from_output (#12301) ## Summary Fixes AttributeError: 'ResponseOutputMessage' object has no attribute 'call_id' in `ResponsesAgentThreadActions._get_tool_calls_from_output` - Updated type annotation from `list[ResponseFunctionToolCall]` to `list[ResponseOutputItem < /dev/null | ResponseOutputMessage]` to accurately reflect actual input types - Improved filtering to only process `ResponseFunctionToolCall` objects, safely ignoring other types like `ResponseOutputMessage` - Removed problematic `.delta` access and dangerous cast operations that caused the AttributeError ## Test plan - [x] All existing OpenAI responses agent tests pass (34/34) - [x] Ruff formatting and linting passes - [x] Pre-commit hooks pass Fixes #12296 Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Invoking an
AzureResponseAgent
that returns a function‑calling answer whose total context grows to many tokens (exact threshold still unclear) causes the run to terminate withTo Reproduce
gpt‑4o
).AzureResponseAgent
with at least one function/tool; keep all defaults.AttributeError
above.Expected behavior
The agent run should finish cleanly and deliver the complete assistant message (including
tool_calls
) without raising an exception, regardless of response length.Screenshots
N/A – console traceback available upon request.
Platform
gpt‑4.1
Additional context
…MessageDeltaEvent
objects to a finalResponseOutputMessage
(which lacks.delta
) for very large tool‑calling completions—but the precise size boundary still needs investigation.The text was updated successfully, but these errors were encountered: