acoustic-carpenter-78188
07/08/2026, 2:10 PMagent and run_id, so consumers (such as the UI) can reliably distinguish between events from different runs or agents. The UI now ignores progress events from sub-agents to prevent them from interfering with the main agent's display, while still allowing custom/unstamped events to pass through. Comprehensive tests are added to verify these behaviors.
Agent run identity and event attribution:
• Added a _RunIdentity dataclass and a context variable _current_run to track the current agent and run ID for each event, ensuring that concurrent and nested agent runs do not conflate their events. The _run_loop method sets and resets this context for each run, and _emit automatically stamps agent and run_id onto every AgentEvent. (src/flyte/ai/agents/agent.py)
• Updated the AgentEvent class to include agent and run_id fields, and documented that these are now stamped automatically. (src/flyte/ai/agents/agent.py)
UI and event filtering:
• Modified the chat UI event handler so that only events from the top-level (first) run are processed; events from sub-agents (with a different run_id) are dropped to prevent them from interfering with the UI state, while unstamped events still pass through. (src/flyte/ai/chat/app.py)
Testing:
• Added tests to verify that all events are correctly stamped with the agent name and run ID, that sub-agent events are attributed to their own runs without interfering with the outer agent, and that the run identity context is properly restored after sub-agent execution. (tests/flyte/ai/agents/test_agent.py)
• Added a test to ensure that the chat stream drops sub-agent progress events (with a different run_id) but allows unstamped events, and that sub-agent events do not clobber the UI attempt counter or phase. (tests/flyte/ai/chat/test_app.py)
flyteorg/flyte-sdkacoustic-carpenter-78188
07/08/2026, 4:33 PM