fix(frontend): show reasoning_content in historical agent steps

Tool-calling rounds emit reasoning into the OpenAI-protocol
reasoning_content field rather than visible content, so AgentStep.Thought
is often empty in DB. The history reconstructor only read step.thought,
which made the historical step card silent for those rounds even though
the user saw the reasoning live.

Fall back to step.reasoning_content when step.thought is empty so
reload mirrors the live experience.
This commit is contained in:
wizardchen
2026-05-13 13:36:51 +08:00
committed by lyingbug
parent b00bc84f35
commit ec2b44494f
+13 -3
View File
@@ -322,12 +322,22 @@ const reconstructEventStreamFromSteps = (agentSteps, messageContent, isCompleted
// Compute step timestamp (milliseconds) from step.timestamp if available
const stepTimestamp = step.timestamp ? new Date(step.timestamp).getTime() : 0;
// Add thinking event if thought content exists
if (step.thought && step.thought.trim()) {
// Add thinking event if thought content exists.
// For tool-calling rounds, providers like MiMo / DeepSeek thinking-mode
// emit reasoning into the OpenAI-protocol `reasoning_content` field
// rather than visible `content`, so step.thought is often empty even
// though the model did reason. Fall back to step.reasoning_content so
// the historical step card mirrors what the user saw live.
const thoughtText = (step.thought && step.thought.trim())
? step.thought
: (step.reasoning_content && step.reasoning_content.trim())
? step.reasoning_content
: '';
if (thoughtText) {
events.push({
type: 'thinking',
event_id: `step-${step.iteration}-thought`,
content: step.thought,
content: thoughtText,
done: true,
thinking: false,
timestamp: stepTimestamp || undefined,