Repository navigation
Conversation
Pull request dashboard statusClosed · refreshed 2026-10-19 12:10 UTC Status above doesn't look right?
|
There was a problem hiding this comment.
🟡 Changes recommended
It does not fix linked OpenAI issue #825 and lacks async stream regression coverage.
2 open findings
What changed in this PR
Fixes one-shot iterator handling in Anthropic instrumentation, though linked issue #825 concerns OpenAI.
Changes:
- Materializes
messages,system, andtoolsiterators. - Adds sync and async regression tests.
- Adds a changelog fragment.
| File | Description |
|---|---|
patch.py |
Materializes request iterators before extraction and SDK calls. |
test_sync_messages.py |
Tests sync create and stream behavior. |
test_async_messages.py |
Tests async create behavior. |
.changelog/825.fixed |
Documents the Anthropic fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| SDK and the tool definitions read it. Call this before either of them does: | ||
| ``create`` reads the request after this wrapper, but ``stream`` serializes | ||
| it while building the manager, before the invocation is created. | ||
| def _materialize_iterables(kwargs: dict[str, Any]) -> None: |
| kwargs: dict[str, Any], | ||
| ) -> AsyncMessagesStreamManagerWrapper[Any]: | ||
| _materialize_tools(kwargs) | ||
| _materialize_iterables(kwargs) |
Assisted-by: Claude Opus 4.6
Assisted-by: Claude Opus 4.6
This comment has been minimized.
This comment has been minimized.
Responding to review findingsBoth findings are addressed. Finding 1: #825 is OpenAI-only — this PR does not fix itAddressed. The PR was never intended to fix the OpenAI issue; it fixes the same class of bug for Anthropic. Evidence:
The PR title includes Finding 2: Missing async stream
|
| Test | Line | Asserts request body | Asserts telemetry |
|---|---|---|---|
test_async_messages_stream_messages_generator_is_recorded |
1172 | seen["body"]["messages"] == [user_msg] |
input_messages span |
test_async_messages_stream_system_generator_is_recorded |
1217 | seen["body"]["system"] == [system_block] |
system_instruction span |
test_async_messages_stream_tools_generator_is_recorded |
1127 | seen["body"]["tools"] == [tool_def] |
tool_definitions span |
All use MockTransport to capture the serialized request, then assert both the JSON body and the span attributes. All 8 async generator tests + all 5 sync generator tests pass:
$ pytest -k generator
6 passed, 170 deselected
These tests were added as part of PR #865 itself but appear to have been missed in review.
|
Thanks for the work on this @Pr1meGG, and for the detailed replies on the review threads. I think this one has been overtaken by #873, which landed the same fix for On those two, Given that, I think it makes sense to close this. If you spot a case that the matrix in Thanks again 🙂 |

Materialize generator and one-shot iterator inputs for
messages,system, andtoolsinkwargsbefore telemetry extraction in Anthropiccreateandstreammethods when content capture is enabled, leaving them unmaterialized when content capture is disabled.This prevents generator exhaustion in Anthropic instrumentation, mirroring the fix in #864 for OpenAI (Issue #825).
Known gaps or concerns
None.