feat: add thinking mode support for agents

This commit is contained in:
wizardchen
2026-01-20 16:20:43 +08:00
committed by lyingbug
parent b1895f7443
commit aa4af5365e
21 changed files with 1118 additions and 481 deletions
+4 -3
View File
@@ -688,12 +688,13 @@ func (e *AgentEngine) streamThinkingToEventBus(
iteration int,
sessionID string,
) (*types.ChatResponse, error) {
logger.Infof(ctx, "[Agent][Thinking][Iteration-%d] Starting thinking stream with temperature=%.2f, tools=%d",
iteration+1, e.config.Temperature, len(tools))
logger.Infof(ctx, "[Agent][Thinking][Iteration-%d] Starting thinking stream with temperature=%.2f, tools=%d, thinking=%v",
iteration+1, e.config.Temperature, len(tools), e.config.Thinking)
opts := &chat.ChatOptions{
Temperature: e.config.Temperature,
Tools: tools,
Thinking: e.config.Thinking,
}
logger.Debug(context.Background(), "[Agent] streamLLM opts tool_choice=auto temperature=", e.config.Temperature)
@@ -832,7 +833,7 @@ func (e *AgentEngine) streamFinalAnswerToEventBus(
fullAnswer, _, err := e.streamLLMToEventBus(
ctx,
messages,
&chat.ChatOptions{Temperature: e.config.Temperature},
&chat.ChatOptions{Temperature: e.config.Temperature, Thinking: e.config.Thinking},
func(chunk *types.StreamResponse, fullContent string) {
if chunk.Content != "" {
logger.Debugf(ctx, "[Agent][FinalAnswer] Emitting answer chunk: %d chars", len(chunk.Content))