feat: add Event.intermediate flag for multi-step agent streaming#273
Open
nuthalapativarun wants to merge 6 commits into
Open
feat: add Event.intermediate flag for multi-step agent streaming#273nuthalapativarun wants to merge 6 commits into
nuthalapativarun wants to merge 6 commits into
Conversation
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.
e2618c5 to
0d35f5b
Compare
Contributor
Author
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
Contributor
Author
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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