Skip to content

Add streaming support to ToolCallAdvisor#5383

Closed
tzolov wants to merge 7 commits intospring-projects:mainfrom
tzolov:toolcalladvisor-streaming
Closed

Add streaming support to ToolCallAdvisor#5383
tzolov wants to merge 7 commits intospring-projects:mainfrom
tzolov:toolcalladvisor-streaming

Conversation

@tzolov
Copy link
Contributor

@tzolov tzolov commented Feb 1, 2026

Implement the adviseStream method in ToolCallAdvisor to enable
streaming tool calling with recursive loop support. The streaming
implementation mirrors the synchronous adviseCall pattern,
supporting returnDirect tool execution and conversation
history management.

  • Implement adviseStream with full tool calling loop for streaming
  • Add copy(StreamAdvisor) method to StreamAdvisorChain interface
  • Refactor DefaultAroundAdvisorChain to share copy logic between
    call and stream advisor chains
  • Add hook methods for streaming: doInitializeLoopStream,
    doBeforeStream, doAfterStream, doFinalizeLoopStream, and
    doGetNextInstructionsForToolCallStream
  • Execute tool calls on boundedElastic scheduler for blocking ops
  • Properly handle ToolCallReactiveContextHolder for reactive context

Implement the adviseStream method in ToolCallAdvisor to enable
streaming tool calling with recursive loop support. The streaming
implementation mirrors the synchronous adviseCall pattern,
supporting returnDirect tool execution and conversation
history management.

- Implement adviseStream with full tool calling loop for streaming
- Add copy(StreamAdvisor) method to StreamAdvisorChain interface
- Refactor DefaultAroundAdvisorChain to share copy logic between
  call and stream advisor chains
- Add hook methods for streaming: doInitializeLoopStream,
  doBeforeStream, doAfterStream, doFinalizeLoopStream, and
  doGetNextInstructionsForToolCallStream
- Execute tool calls on boundedElastic scheduler for blocking ops
- Properly handle ToolCallReactiveContextHolder for reactive context

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
… streaming behavior

- Add `streamToolCallResponses` configuration option to ToolCallAdvisor that controls
  whether intermediate tool call responses are emitted during streaming operations
- Add `streamWithToolCallResponses()` method for real-time streaming of all chunks
  including tool call responses using publish() for multicast
- Add `streamWithoutToolCallResponses()` method that buffers chunks and only emits
  for final non-tool-call responses (previous default behavior)
- Add `suppressToolCallStreaming()` builder method as convenient shorthand
- Refactor streaming implementation with improved code organization and comments
- Add unit tests for new streamToolCallResponses configuration
- Update AbstractToolCallAdvisorIT with improved test coverage:
  - Add returnDirect tool callback tests for both call and stream
  - Add external memory integration tests
  - Rename test methods for consistency
- Remove Google GenAI specific ToolCallAdvisor integration test (consolidated into
  abstract test class)

The main feature in this commit is the new `streamToolCallResponses` option that allows users to control whether intermediate tool call responses are streamed in real-time (for better UX feedback) or buffered until the final response (previous behavior).

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Replace dual-path streaming implementation (buffering vs. parallel) with a single unified approach
that always uses parallel streaming and applies a terminal filter to control tool call response visibility.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@tzolov tzolov force-pushed the toolcalladvisor-streaming branch from 070e89f to fb69a3f Compare February 3, 2026 09:09
@ilayaperumalg ilayaperumalg self-assigned this Feb 3, 2026
@ilayaperumalg ilayaperumalg added this to the 2.0.0-M3 milestone Feb 3, 2026
@ilayaperumalg
Copy link
Member

Rebased and merged as 19c606a into main and backported into 1.1.x via 21dac8d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants