feat: add Event.intermediate flag for multi-step agent streaming#273
feat: add Event.intermediate flag for multi-step agent streaming#273nuthalapativarun wants to merge 1 commit into
Conversation
e2618c5 to
0d35f5b
Compare
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
1 similar comment
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
|
Hi team — bumping this again after ~2 weeks with no activity. Happy to rebase, split differently, or adjust scope if that helps move it forward. Let me know! |
305b4b5 to
449b80f
Compare
|
Rebased on current |
|
Hi team — bumping this once more. This PR adds an |
449b80f to
7a3a8de
Compare
Add an optional Event.intermediate boolean field that is set to true on all events emitted during agent steps that produce function calls (i.e. steps that are followed by tool execution and more LLM calls). This allows streaming consumers to distinguish between model text produced as part of a reasoning/tool-calling step versus the final response text returned to the user. Motivation: issue google#261. Aligned with adk-python behaviour.
7a3a8de to
1f4e02d
Compare
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Problem:
During multi-step agent turns (e.g. model text → tool call → model text), streaming consumers cannot distinguish model text emitted before a tool call from the final response text. Both appear as identical events, forcing clients to buffer everything or show intermediate reasoning text to the user unintentionally.
Solution:
Add an optional
intermediate?: booleanfield to theEventinterface. InLlmAgent.runAsyncImpl, events from steps that are followed by function calls are markedintermediate: true. Final response events remain unmarked (undefined).This is a purely additive, non-breaking change. Existing consumers that do not check
intermediateare unaffected. Aligned with adk-python behaviour.Implementation details:
Event.intermediate?: booleanadded tocore/src/events/event.tsLlmAgent.runAsyncImplincore/src/agents/llm_agent.tsnow collects all events per step, checks whether the step is final (isFinalResponse), and setsintermediate: trueon non-final steps before yieldingTesting Plan
Unit Tests:
Summary of passed npm test results:
Full suite (on this branch): 1101 passed | 21 skipped
Manual End-to-End (E2E) Tests:
The
intermediatefield is optional and additive. All existing tests pass without modification.Checklist