The agent runner's cold-start history reconstruction previously filtered only text content, silently discarding thinking, tool_use, and tool_result blocks. This caused multi-turn reasoning continuity loss and API 400 errors when sessions restarted or switched directories. The fix introduces a block-aware serializer that preserves these structured blocks during session replay, restoring accurate tool-call execution and model reasoning traces.
Block-aware serialization for agent conversation history reconstruction during cold-start and session restarts
AI agent operators running multi-turn tasks will stop losing reasoning steps and tool outputs when sessions restart or switch directories, preventing silent accuracy drops and hard API failures. By replacing a text-only filter with a block-preserving serializer in the agent runner, the system now correctly replays structured reasoning and tool tags into the prompt preamble. This stops providers like DeepSeek V4 Flash from rejecting requests with 400 errors and restores explainability for models relying on chain-of-thought context. Watch for potential context window bloat if the new serialization processes large nested tool calls or file attachments, and verify that downstream parsers handle the updated XML structure without breaking existing integrations.
The previous rebuild loop did: msg.content.filter((c) => c.type === 'text') which silently dropped thinking, tool_use, and tool_result blocks.