You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f80498b
Browse filesBrowse the repository at this point in the historyBrowse files
Python: mark hosted /responses incomplete on content_filter and length finish reasons (microsoft#8478)
* Python: mark hosted /responses incomplete on content_filter and length finish reasons
The hosted /responses path iterated each AgentResponseUpdate's contents but never read
its finish_reason, so a turn the model stopped early (Azure OpenAI content filter, token
limit) ended with status "completed" and no trace of the cut-off. Callers could only
detect a filtered turn by matching the canned refusal text.
_OutputItemTracker now records truncating finish reasons from both the plain-agent and
workflow update loops, and _handle_response ends the response with response.incomplete
plus incomplete_details.reason ("content_filter" / "max_output_tokens") instead of
response.completed, mirroring the OpenAI Responses shape. The refusal text is still
delivered as an output item.
Fixesmicrosoft#8475
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* Persist the incomplete reason across resilient checkpoint recovery
Recovery rebuilds _OutputItemTracker from the persisted response, so a marker held only in
memory was lost if the crash landed between a filtered update and a later one. Mirror it
into the stream's internal_metadata (persisted with every checkpoint, like the last
checkpoint id) and restore it in the tracker constructor.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* Handle updates through one tracker entry point and pair snapshots with the checkpoint an update follows
_OutputItemTracker.handle_update records the update's finish reason and then handles its
contents, so the plain-agent and workflow loops share one ordering rule.
The workflow loop snapshotted the response against the latest checkpoint in storage at the
time an update was consumed. _SignalledIterator drives the workflow one update ahead, so by then
the runner could already have checkpointed past the update; a crash after that snapshot resumed
the workflow with the update never replayed and its output (and any incomplete reason) lost.
_SignalledIterator now takes an optional stamp coroutine that the driver awaits right after each
item is produced, before advancing the wrapped iterator again, and the loop pairs snapshots with
that stamped checkpoint id. After the workflow completes, its final checkpoint is paired with the
full output so recovery does not replay the last superstep. The real-crash recovery integration
tests that were xfailed against microsoft#7809 pass with this.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* Fix pre-commit and typing failures
- Drop the redundant `None, None` Generator parameters flagged by pyupgrade.
- Type the `finish_reason` test parameters as `FinishReasonLiteral` instead of
`str` + `type: ignore`, which `ty` does not honour.
- Read the text delta with `.get()` so the `ResponseStreamEvent` TypedDict
union does not need narrowing.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
0 commit comments