Class ChatStreamerImpl
- All Implemented Interfaces:
ChatStreamer
Each invocation of stream(com.axelor.ai.chat.ChatRequest, com.axelor.ai.chat.stream.StreamWriter) runs an asynchronous loop: call the ChatProvider,
relay text/reasoning deltas as StreamEvents, and when the provider finishes with FinishReason.TOOL_CALLS, execute the requested tools via ToolExecutor and feed results
back for the next iteration. The loop is capped at 10 steps.
Sub-agent consultation is handled via ToolResult.Consult: the outer loop builds a
nested pipeline for the target agent and runs runConsultLoop(com.axelor.ai.chat.stream.ChatStreamerImpl.AgentFrame, com.axelor.ai.chat.stream.StreamWriter, java.util.concurrent.atomic.AtomicBoolean, com.axelor.ai.chat.stream.ToolOutputDeduplicator) which streams to the same
SSE connection, wrapped in a ConsultWriter so the sub-agent's prose does not surface in
the conversation. The sub-agent finishes naturally — its last assistant text becomes the
consult_agent tool output for the parent.
-
Method Summary
Modifier and TypeMethodDescriptionstream(ChatRequest req, StreamWriter w) Starts an asynchronous streaming chat loop.
-
Method Details
-
stream
Description copied from interface:ChatStreamerStarts an asynchronous streaming chat loop.The implementation calls the LLM, relays streaming deltas as
StreamEvents to the writer, and when the LLM requests tool calls, executes them and feeds results back for subsequent iterations.- Specified by:
streamin interfaceChatStreamer- Parameters:
req- the chat request containing message history and optionsw- the SSE stream writer for the HTTP response- Returns:
- a handle to cancel the loop or await its completion
-