# Reasoning Trace Carry-Forward

> For reasoning models, keep the chain-of-thought trace in context within a tool-use episode — but drop it at user-turn boundaries to prevent stale reasoning from accumulating.

- **Category**: Agentic AI
- **Subcategory**: Memory
- **Canonical URL**: https://designpattern.fyi/patterns/reasoning_trace_carry_forward/

---

## Description
**Intent**: For reasoning models that emit a separate reasoning trace, preserve it in context across the same logical task episode (across tool-call/result turns) — but drop it at user-turn boundaries.
**Context**: You're using a reasoning-capable model (OpenAI o-series, Claude with extended thinking, DeepSeek-R1) that returns chain-of-thought in a separate `reasoning_content` field. The agent runs in a tool-use loop: model reasons → calls tool → sees result → reasons again → answers → new user message. Naive approaches either drop all CoT (losing continuity mid-episode) or carry it forward forever (accumulating stale reasoning across unrelated turns).
**Solution**: Define an episode as: from one user turn to the next user turn, inclusive of all intervening tool calls and tool results. Within an episode, preserve `reasoning_content` in context concatenation across all turns. At the next user turn boundary, drop `reasoning_content` from prior episodes. The user-visible content remains in history; only the reasoning trace is episode-scoped.



## Use Cases
- The model is a reasoning model that emits a separate reasoning trace (reasoning_content).
- Within an episode (one user turn through all tool calls and results), reasoning context must persist for CoT continuity.
- Reasoning traces should be dropped at user-turn boundaries to avoid stale carryover.






## Trade-offs


### Advantages

- Tool-using episodes get the full benefit of CoT continuity across multiple tool calls.

- Multi-turn dialogues don't accumulate stale reasoning from unrelated prior episodes.

- Cheaper than naive forever-preservation of all reasoning traces.




### Considerations & Drawbacks

- Episode boundary detection must be encoded in the agent loop, not the model — it's your responsibility.

- If the model expects its own past reasoning at a later turn, dropping it breaks that assumption.

- Provider-specific — DeepSeek-style `reasoning_content` needs adaptation per API.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/reasoning-trace-carry-forward/)

