Skip to content

Commit d933a1d

Browse files
committed
Address Douwe's feedback
- Add 'optional' to second metadata annotation - Revert unrelated test_examples.py changes
1 parent d3c7603 commit d933a1d

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

docs/deferred-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ async def main():
329329
```
330330

331331
1. Generate a task ID that can be tracked independently of the tool call ID.
332-
2. The `metadata` parameter passes the `task_id` so it can be matched with results later, accessible in `DeferredToolRequests.metadata` keyed by `tool_call_id`.
332+
2. The optional `metadata` parameter passes the `task_id` so it can be matched with results later, accessible in `DeferredToolRequests.metadata` keyed by `tool_call_id`.
333333
3. In reality, this would typically happen in a separate process that polls for the task status or is notified when all pending tasks are complete.
334334

335335
_(This example is complete, it can be run "as is" — you'll need to add `asyncio.run(main())` to run `main`)_

tests/test_examples.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def print(self, *args: Any, **kwargs: Any) -> None:
179179
env.set('MOONSHOTAI_API_KEY', 'testing')
180180
env.set('DEEPSEEK_API_KEY', 'testing')
181181
env.set('OVHCLOUD_API_KEY', 'testing')
182-
env.set('PYDANTIC_AI_GATEWAY_API_KEY', 'testing')
183182

184183
prefix_settings = example.prefix_settings()
185184
opt_test = prefix_settings.get('test', '')
@@ -259,9 +258,7 @@ def print(self, *args: Any, **kwargs: Any) -> None:
259258
def print_callback(s: str) -> str:
260259
s = re.sub(r'datetime\.datetime\(.+?\)', 'datetime.datetime(...)', s, flags=re.DOTALL)
261260
s = re.sub(r'\d\.\d{4,}e-0\d', '0.0...', s)
262-
s = re.sub(r'datetime.date\(', 'date(', s)
263-
s = re.sub(r"run_id='.+?'", "run_id='...'", s)
264-
return s
261+
return re.sub(r'datetime.date\(', 'date(', s)
265262

266263

267264
def mock_render_duration(seconds: float, force_signed: bool) -> str:
@@ -874,14 +871,10 @@ async def model_logic( # noqa: C901
874871
return ModelResponse(
875872
parts=[TextPart('The answer to the ultimate question of life, the universe, and everything is 42.')]
876873
)
877-
if isinstance(m, ToolReturnPart):
874+
else:
878875
sys.stdout.write(str(debug.format(messages, info)))
879876
raise RuntimeError(f'Unexpected message: {m}')
880877

881-
# Fallback for any other message type
882-
sys.stdout.write(str(debug.format(messages, info)))
883-
raise RuntimeError(f'Unexpected message type: {type(m).__name__}')
884-
885878

886879
async def stream_model_logic( # noqa C901
887880
messages: list[ModelMessage], info: AgentInfo

0 commit comments

Comments
 (0)