Keep response spans active during LLM hooks#2779
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7927f0f533
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ) | ||
| stream_failed_retry_attempts: list[int] = [0] | ||
| retry_stream = stream_response_with_retry( | ||
| get_stream=lambda: model.stream_response(**stream_request_kwargs), |
There was a problem hiding this comment.
Preserve positional invocation for streamed model calls
run_single_turn_streamed now calls model.stream_response via model.stream_response(**stream_request_kwargs). In the previous implementation, the required model arguments were passed positionally, so legacy custom Model implementations with positional-only parameters (or different parameter names but the same positional order) still worked; with this change they now raise TypeError at runtime and streamed runs fail before producing output. Please keep the required parameters positional (or add a fallback path) to maintain compatibility with existing custom streamed models.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Restored positional-argument compatibility for both streamed and non-streamed custom models. Required parameters are positional again, optional values continue through kwargs, and response_span is still passed only when the model supports it.
|
I think this PR still has two merge blockers.
Because both issues reproduce at runtime, I don't think this is ready to merge yet. Also, the CI checks are failing. |
|
Pushed follow-up fixes for both blockers on the latest head:
Local verification on this branch:
The new |
Summary
esponse span current while RunHooks.on_llm_start/on_llm_end and AgentHooks.on_llm_start/on_llm_end execute.
esponse span metadata and cover both streamed and non-streamed paths with regression tests.
esponse spans before tool/handoff processing so streamed traces match the non-streamed hierarchy.
Test plan
Issue number
Closes #1844
Checks