wangzhigang1999 commented on PR #7417:
URL: https://github.com/apache/kyuubi/pull/7417#issuecomment-4301990204

   ## ReactAgent Execution Flow
   
   ```
   ReactAgent.run(request, memory, eventConsumer)
   │
   ├─ memory.addUserMessage(userInput)
   ├─ dispatchAgentStart  /  emit(AgentStart)
   │
   ├─ for step in 1..maxIterations:
   │    ├─ emit(StepStart)
   │    │
   │    ├─ messages = memory.buildLlmMessages()
   │    ├─ messages = middleware.beforeLlmCall(messages)      ← may rewrite or 
abort the call
   │    │
   │    ├─ streamLlmResponse(messages)                        ← streaming + 
chunk accumulation
   │    │     └─ emit(ContentDelta)*   (one per token)
   │    │
   │    ├─ emit(ContentComplete)
   │    ├─ memory.addAssistantMessage(...)
   │    ├─ middleware.afterLlmCall(...)
   │    │
   │    ├─ if no toolCalls → emit(StepEnd) + emit(AgentFinish) + return   ✅ 
normal termination
   │    │
   │    └─ executeToolCalls (3-phase pipeline):
   │         ├─ Phase 1 (serial)   : parse args → beforeToolCall → approval gate
   │         ├─ Phase 2 (parallel) : toolRegistry.submitTool(...) → futures
   │         └─ Phase 3 (serial)   : future.join()
   │                                 → afterToolCall (may rewrite result, e.g. 
offload)
   │                                 → memory.addToolResult(...)
   │                                 → emit(ToolResult)
   │
   ├─ exceeded maxIterations → emit(AgentError) + emit(AgentFinish)
   ├─ exception thrown       → emit(AgentError) + emit(AgentFinish)
   └─ finally: dispatchAgentFinish   ← guarantees middleware cleanup
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to