fix(tools): isolate streaming Relay scope - #356
Conversation
Signed-off-by: Devdeep Ray <devdeepr@nvidia.com>
|
Reviewed at This resolves both open blockers from the #355 review: the AGENTS.md sweep is complete (the remaining Blockers
Suggestions
This is the right fix, verified to do what it claims: the producer task is the only design that makes the scope pop context-correct, and the AGENTS.md updates close out the documentation drift. The blockers above should be resolved before merge. |
Signed-off-by: Devdeep Ray <devdeepr@nvidia.com>
|
Addressed in Blockers
Suggestions
Validation:
|
Signed-off-by: Devdeep Ray <devdeepr@nvidia.com>
Signed-off-by: Devdeep Ray <devdeepr@nvidia.com>
Follow-up to #355.
What changed
AGENTS.mdso new and migrated native tools are placed inxr-ai-tools, withxr-ai-natreserved for compatibility surfaces still awaiting migrationAsyncToolhandler in an isolated producer task that owns the Relay scope and handler cleanupWhy
AsyncTool.streampreviously held a task-local Relay scope open acrossyield. If a consumer stopped iterating after an error, async-generator finalization could pop that scope from a different context, corrupt the scope stack and prevent streaming handler cleanup from returning the participant toidle.Impact
Abandoned streams now finalize their handler in the producer Relay context without leaking the tool scope into consumer code. Future streaming tools inherit the safe lifecycle behavior.
Validation
tests/.venv/bin/pytest tests/test_native_tools.py tests/test_simple_vlm_example_worker.py(22 passed)uvx --from ruff==0.15.16 ruff check .uvx pyright --pythonpath tests/.venv/bin/python agent-sdk/xr-ai-tools/xr_ai_tools/async_tools.py tests/test_native_tools.pyuv build agent-sdk/xr-ai-tools