Skip to content

Commit e4f331d

Browse files
declan-scaleclaude
andcommitted
fix(pydantic-ai): drop removed coalesce_tool_requests kwarg from tutorials [greptile]
PydanticAITurn.__init__ accepts only (stream, model, tracing_handler); the coalesce_tool_requests workaround was removed now that the unified auto_send path delivers streamed tool requests natively (Start+Delta+Done). Two tutorial agents still passed coalesce_tool_requests=True, which would raise TypeError at runtime (P0): - 10_async/00_base/harness_pydantic_ai (acp.py) - 10_async/10_temporal/harness_pydantic_ai (agent.py) Also refresh the now-stale references to the removed parameter in the sync tutorial comment and the cross-channel conformance test docstring (AGX1-377 has landed; streamed tool requests are delivered and asserted). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent df2839a commit e4f331d

4 files changed

Lines changed: 18 additions & 26 deletions

File tree

examples/tutorials/00_sync/harness_pydantic_ai/project/acp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ async def handle_message_send(
8585
)
8686

8787
async with agent.run_stream_events(user_message) as stream:
88-
# Default coalesce_tool_requests=False preserves token-by-token
89-
# tool-call argument streaming on the sync/HTTP channel.
88+
# PydanticAITurn preserves token-by-token tool-call argument
89+
# streaming (Start+Delta+Done) on the sync/HTTP channel.
9090
turn = PydanticAITurn(stream, model=MODEL_NAME)
9191
async for ev in emitter.yield_turn(turn):
9292
yield ev

examples/tutorials/10_async/00_base/harness_pydantic_ai/project/acp.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""ACP handler for the async harness Pydantic AI test agent.
22
33
This agent exercises the UNIFIED HARNESS SURFACE on the async (Redis-streaming)
4-
channel — ``UnifiedEmitter.auto_send_turn(PydanticAITurn(..., coalesce_tool_requests=True))``
4+
channel — ``UnifiedEmitter.auto_send_turn(PydanticAITurn(...))``
55
— calling it directly rather than via the ``stream_pydantic_ai_events`` helper
66
(which the ``110_pydantic_ai`` tutorial uses). This makes the unified-surface
77
wiring explicit at the agent-author level.
@@ -132,13 +132,11 @@ async def tee_messages(upstream) -> AsyncIterator[Any]:
132132
yield event
133133

134134
async with agent.run_stream_events(user_message, message_history=previous_messages) as stream:
135-
# coalesce_tool_requests=True is required on the async/auto_send
136-
# path until AGX1-377 lands: tool requests are delivered as a single
137-
# Full(tool_request) rather than streamed Start+Delta+Done.
135+
# The unified auto_send path delivers streamed tool requests natively
136+
# (Start+Delta+Done), so no coalescing workaround is needed.
138137
turn = PydanticAITurn(
139138
tee_messages(stream),
140139
model=MODEL_NAME,
141-
coalesce_tool_requests=True,
142140
)
143141
result = await emitter.auto_send_turn(turn)
144142

examples/tutorials/10_async/10_temporal/harness_pydantic_ai/project/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ async def event_handler(
8888
8989
The UnifiedEmitter is constructed from ``deps`` (task_id + parent_span_id),
9090
so tool spans nest under the workflow's per-turn span and messages auto-send
91-
to the task stream. ``coalesce_tool_requests=True`` is required on the
92-
auto_send path until AGX1-377 lands.
91+
to the task stream. The auto_send path delivers streamed tool requests
92+
natively, so no coalescing workaround is needed.
9393
"""
9494
emitter = UnifiedEmitter(
9595
task_id=run_context.deps.task_id,
9696
trace_id=run_context.deps.task_id,
9797
parent_span_id=run_context.deps.parent_span_id,
9898
)
99-
turn = PydanticAITurn(events, model=MODEL_NAME, coalesce_tool_requests=True)
99+
turn = PydanticAITurn(events, model=MODEL_NAME)
100100
await emitter.auto_send_turn(turn)
101101

102102

tests/lib/core/harness/conformance/test_pydantic_ai_conformance.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
"""Cross-channel conformance fixtures derived from real pydantic-ai event sequences.
22
33
Each fixture is built by running a pydantic_ai event stream through PydanticAITurn
4-
(default coalesce_tool_requests=False) and collecting the canonical StreamTaskMessage*
5-
output. These canonical event lists are then registered with the conformance runner and
6-
exercised by the cross-channel test (yield_events vs auto_send).
4+
and collecting the canonical StreamTaskMessage* output. These canonical event lists are
5+
then registered with the conformance runner and exercised by the cross-channel test
6+
(yield_events vs auto_send).
77
8-
AGX1-377 NOTE
9-
-------------
8+
Streamed tool requests
9+
----------------------
1010
The pydantic-ai stream emits a tool REQUEST as Start + ToolRequestDelta + Done (not a
11-
Full event). The runner's current normalization does NOT produce a logical delivery for
12-
Start+Delta+Done(tool_request): _yield_logical_deliveries only produces a delivery for
13-
Full(tool_request) or Full(tool_response), and Start+Done for text/reasoning content.
14-
auto_send likewise drops the Start+Delta+Done(tool_request) shape. Both channels handle
15-
it consistently (both ignore it), so the cross-channel test PASSES, but it does NOT yet
16-
assert that the streamed tool-request is actually delivered. Full delivery-equivalence
17-
coverage for streamed tool requests will land once AGX1-377 fixes the normalization.
18-
The fixtures below retain the ToolRequestDelta events so they become valid test inputs
19-
automatically once AGX1-377 lands.
11+
Full event). AGX1-377 has landed: both the conformance runner and auto_send now deliver
12+
the Start+Delta+Done(tool_request) shape, so the cross-channel test asserts full
13+
delivery-equivalence for streamed tool requests. The fixtures below retain the
14+
ToolRequestDelta events as the streamed tool-request inputs.
2015
"""
2116

2217
from __future__ import annotations
@@ -61,8 +56,7 @@ async def _aiter(events: list[Any]) -> AsyncIterator[Any]:
6156
async def _canonical(pydantic_events: list[Any]) -> list[Any]:
6257
"""Run pydantic_ai events through PydanticAITurn and collect the output.
6358
64-
Default coalesce_tool_requests=False means the output equals the bare
65-
convert_pydantic_ai_to_agentex_events output.
59+
The output equals the bare convert_pydantic_ai_to_agentex_events output.
6660
"""
6761
turn = PydanticAITurn(_aiter(pydantic_events), model=None)
6862
return [e async for e in turn.events]

0 commit comments

Comments
 (0)