WeKnora/internal
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
..
agent fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
application fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
common feat: Implement deadlock retry mechanism for chunk creation 2026-04-22 21:17:21 +08:00
config feat(agent): human-in-the-loop approval for MCP tool calls (#1173) 2026-05-10 22:57:12 +08:00
container refactor(agent): rebuild multi-turn history from DB, drop llmcontext layer 2026-05-12 12:26:24 +08:00
database fix: update environment configuration for debugging and logging, enhance SQLite FTS5 table management, and improve API base URL handling 2026-04-11 18:51:16 +08:00
datasource fix(feishu): tolerate partial wiki node listing failures 2026-05-12 17:40:59 +08:00
errors feat: Add agent configuration and cleanup scripts for database migrations 2025-11-05 23:18:44 +08:00
event feat(agent): human-in-the-loop approval for MCP tool calls (#1173) 2026-05-10 22:57:12 +08:00
handler feat(observability): log end-to-end TTFB on both ends of chat stream 2026-05-12 21:16:37 +08:00
im fix(agent): exclude wiki-only KBs from quick-answer (RAG) mode 2026-05-12 16:27:28 +08:00
infrastructure refactor(web-search): drop dead api_key path in SearXNG provider 2026-05-11 16:53:47 +08:00
logger feat(observability): integrate Langfuse for LLM token tracking and tracing 2026-04-24 10:29:19 +08:00
mcp feat(mcp): implement reconnection logic for MCP tool calls and tool listing 2026-03-31 11:57:15 +08:00
middleware fix(middleware): mask camelCase secret fields in request logs 2026-05-12 19:27:29 +08:00
models fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
router feat(agent): human-in-the-loop approval for MCP tool calls (#1173) 2026-05-10 22:57:12 +08:00
runtime init commit 2025-08-05 15:08:07 +08:00
sandbox feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
searchutil feat(prompt): enhance question rewriting and intent classification in prompt templates 2026-04-16 23:15:02 +08:00
stream feat(redis): add REDIS_USERNAME support for Redis ACL 2026-02-04 19:38:40 +08:00
tracing feat(observability): extend Langfuse tracing across asynq pipeline 2026-04-24 13:16:47 +08:00
types fix(agent): pass reasoning_content back to providers that require it 2026-05-13 12:29:10 +08:00
utils refactor(security_test): standardize struct field formatting in SSRF whitelist tests 2026-05-11 16:53:47 +08:00