WeKnora/internal/agent
wizardchen b00bc84f35 fix(agent): pass reasoning_content back to providers that require it
MiMo and DeepSeek V3.2/V4 reject multi-turn requests in thinking mode
when the prior assistant message lacks reasoning_content with HTTP 400:
"The reasoning_content in the thinking mode must be passed back to the API."

Agent's ReAct loop is the worst-case scenario — every round produces tool
calls, exactly the case DeepSeek's docs specify reasoning_content MUST
participate in subsequent context.

Plumb reasoning_content through the full assistant-message round-trip:
- chat.Message / types.ChatResponse / types.AgentStep gain a
  reasoning_content field (AgentStep persists via the existing
  Message.AgentSteps jsonb column, no migration needed).
- streamLLMToEventBus accumulates reasoning chunks into
  result.ReasoningContent and surfaces it on the round's ChatResponse.
- engine.runReActIteration writes it onto AgentStep so cross-turn replay
  preserves it.
- observe.appendToolResults attaches it to the same-turn assistant
  message; agent_history.buildAssistantHistoryMessages does the same on
  cross-turn replay.
- RemoteAPIChat.ConvertMessages forwards it on assistant turns to
  openai.ChatCompletionMessage.ReasoningContent (already supported by
  go-openai); providers that don't recognize the field ignore it.

Tests cover the three boundaries: ConvertMessages serializes it for
upstream, appendToolResults preserves it within the same turn, and
buildAssistantHistoryMessages replays it across turns.

Scope is intentionally limited to Agent mode — KnowledgeQA's chat
pipeline and Anthropic's signed thinking_blocks are separate fixes that
require schema changes (rendered_content / thinking_blocks columns).

Fixes #1302
2026-05-13 12:29:10 +08:00
..
approval fix(agent): enhance user authorization and concurrency handling in tool approval 2026-05-10 22:57:12 +08:00
memory feat(agent): enhance message consolidation and context management 2026-03-25 22:08:29 +08:00
skills feat: adapt preloaded skills to smart-reasoning agent 2026-02-04 20:08:49 +08:00
token feat(agent): enhance message consolidation and context management 2026-03-25 22:08:29 +08:00
tools fix(agent): exclude wiki-only KBs from quick-answer (RAG) mode 2026-05-12 16:27:28 +08:00
act.go fix(agent): 加固 MCP 工具人审批的跨实例与并发语义 2026-05-10 22:57:12 +08:00
const.go feat: Implement wiki_config updates in knowledge base management 2026-04-22 21:17:21 +08:00
engine.go fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
engine_image_test.go feat: auto-describe MCP tool result images via VLM 2026-03-25 21:38:15 +08:00
engine_test.go refactor(agent): rebuild multi-turn history from DB, drop llmcontext layer 2026-05-12 12:26:24 +08:00
finalize.go fix(agent): 修复WeKnora对话完前端未显示结束标记问题 2026-05-07 16:34:20 +08:00
langfuse_test.go feat(observability): instrument agent ReAct loop and tool calls in Langfuse 2026-04-24 19:58:08 +08:00
observe.go fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
observe_test.go fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
prompts.go feat: Update agent type presets and prompt templates for improved knowledge base handling 2026-04-22 21:18:34 +08:00
prompts_wiki.go fix(ingest): stop hallucinating summaries from filenames on empty PDFs 2026-05-06 11:23:32 +08:00
prompts_wiki_test.go feat: Enhance wiki extraction and configuration options 2026-04-22 21:18:32 +08:00
think.go fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00