State-Transition Framework for Efficient LLM Reasoning
This skill teaches Claude to structure complex multi-step reasoning as a state-transition process based on the framework from Zhang et al. (ICLR 2026). Instead of generating an unconstrained chain-of-thought where every token attends to every prior token, the approach segments reasoning into discrete steps, maintains a compressed reasoning state that accumulates conclusions from prior steps, and applies momentum-based correction to detect and dampen noisy or redundant reasoning. The result is reasoning that stays focused, avoids overthinking, and produces clearer intermediate conclusions.
When to Use
- When a user asks Claude to solve a complex multi-step math, logic, or coding problem that requires long reasoning chains (e.g., competitive programming, algorithm design, debugging multi-layered issues)
- When Claude's initial reasoning attempt produces verbose, repetitive, or circular thinking that wastes tokens without progress
- When the user requests "efficient reasoning" or wants Claude to avoid overthinking on a problem
- When solving problems that require tracking many intermediate results across steps (e.g., dynamic programming derivations, proof construction, multi-file refactoring plans)
- When the user explicitly asks for state-tracked or structured chain-of-thought reasoning
- When debugging a problem where prior reasoning steps have introduced confusion or contradictory conclusions
Key Technique
Reasoning as State Transitions
Standard chain-of-thought reasoning treats the entire generated sequence as a flat token stream. Every new token must (implicitly) attend to all prior tokens, which becomes costly and error-prone as reasoning grows long. The state-transition framework instead segments the reasoning into discrete steps, where each step produces a conclusion that gets folded into a compact reasoning state S_t. At step t, the reasoner only needs the current query and the accumulated state S_t -- not the raw text of all prior steps. This is analogous to how a programmer tracks variable values through a debugger rather than re-reading the entire execution log.
Momentum-Based Noise Correction
Not every reasoning step moves the solution forward. Some steps introduce noise -- wrong assumptions, unnecessary tangents, or redundant restatements. The framework detects this by computing the reasoning direction at each step: delta_t = S_t - S_{t-1}. It then maintains a running average of all prior directions delta_bar_{t-1}. Each step's direction is corrected via momentum blending: delta_hat_t = (1 - alpha) * delta_t + alpha * delta_bar_{t-1}, where alpha increases as reasoning progresses (starting at 0, capping at ~0.4). Early steps are trusted more; later steps are increasingly regularized toward the established reasoning trajectory. This prevents late-stage overthinking and circular reasoning.
Practical Application for Claude
Since Claude cannot modify its own attention mechanism at inference time, this skill operationalizes the framework as a structured reasoning protocol: explicitly maintain a state summary after each reasoning step, evaluate whether each new step is productive or noisy relative to the accumulated direction, and apply self-correction when reasoning drifts.
Step-by-Step Workflow
Parse the problem and identify the reasoning type. Determine whether the task is mathematical derivation, code debugging, logical deduction, planning, or another multi-step domain. Identify what a "step" means in this context (e.g., one equation transformation, one function analysis, one logical inference).
Initialize the reasoning state S_0. Write a concise summary of what is known from the problem statement: the givens, constraints, and goal. This is the initial state before any reasoning begins. Format it as a labeled block:
STATE S_0: [Known: ..., Goal: ..., Constraints: ...]
Execute reasoning step t. Perform one logical unit of reasoning -- a single derivation, deduction, or analysis. Keep the step focused on one sub-goal. Do not attempt multiple leaps in a single step.
Extract the conclusion and update state S_t. After each step, write the new state by appending the step's conclusion to the prior state. Drop the working details; keep only the result. Format:
STATE S_t: [S_{t-1} conclusions + new conclusion from step t]
Evaluate reasoning direction. Compare S_t to S_{t-1}. Ask: "Did this step produce new information that moves toward the goal?" If the delta is near-zero (restated something already known), tangential (explored an irrelevant path), or contradictory (conflicts with established conclusions), flag it as noisy.
Apply momentum correction for noisy steps. If a step is flagged noisy, do not simply discard it. Instead, blend: keep the portion that aligns with the overall reasoning trajectory and discard the divergent portion. Rewrite the state update to reflect only the productive component. Explicitly note the correction:
CORRECTION: Step t was partially noisy. Retaining [useful part], discarding [tangent/repetition].
Increase skepticism as reasoning lengthens. For early steps (steps 1-3), trust each step's output with high confidence. As step count increases beyond 5-6, apply greater scrutiny to each new step -- the equivalent of increasing alpha. Ask: "Is this step genuinely needed, or am I overthinking?"
Check for termination. After each state update, evaluate whether S_t contains sufficient information to answer the original question. If yes, proceed to formulate the answer. Do not continue reasoning past the point of sufficiency.
Synthesize the final answer from the terminal state. Construct the answer directly from the final state S_T, not by re-reading all intermediate steps. The state should contain everything needed.
Present the answer with optional reasoning trace. Give the user the final answer first, then optionally show the state progression as a compact trace for transparency.
Concrete Examples
Example 1: Multi-step mathematical reasoning
User: "What is the remainder when 2^100 is divided by 7? Use state-transition reasoning."
STATE S_0: [Known: compute 2^100 mod 7, Goal: find remainder]
Step 1: Compute small powers of 2 mod 7 to find a cycle.
2^1 mod 7 = 2, 2^2 mod 7 = 4, 2^3 mod 7 = 1
STATE S_1: [2^k mod 7 cycles with period 3: {2, 4, 1, 2, 4, 1, ...}]
Step 2: Express 100 in terms of the cycle length.
100 = 3 * 33 + 1, so 2^100 mod 7 = 2^1 mod 7 = 2
STATE S_2: [100 mod 3 = 1, therefore 2^100 mod 7 = 2]
Termination check: S_2 contains the answer.
ANSWER: The remainder is 2.
Example 2: Debugging a multi-layered code issue
User: "My API returns 500 errors intermittently. The endpoint calls a database, then a cache layer, then formats the response. Help me reason through this."
STATE S_0: [Known: intermittent 500s on API endpoint with 3 stages:
DB query -> cache layer -> response formatting. Goal: identify root cause]
Step 1: Intermittent failures rule out static bugs (syntax, logic).
Points to: resource exhaustion, timeouts, race conditions, or transient
external failures.
STATE S_1: [S_0 + Root cause category: transient/resource issue, not static bug]
Step 2: Analyze each stage for transient failure modes.
- DB: connection pool exhaustion, query timeout, deadlocks
- Cache: connection refused, eviction during read, serialization error
- Formatting: unlikely to be intermittent unless input-dependent
STATE S_2: [S_1 + Primary suspects: DB connection pool or timeout;
Cache connection or serialization; Formatting ruled low-probability]
Step 3: Intermittent pattern narrows further. If failures correlate with
load, connection pool exhaustion is most likely. If random, timeout or
deadlock.
STATE S_3: [S_2 + Key diagnostic: check if failure rate correlates with
request volume. If yes -> pool exhaustion. If no -> timeout/deadlock]
CORRECTION: Step 3 partially restated Step 2's suspects.
Retaining: the load-correlation diagnostic.
Discarding: repeated enumeration of failure modes.
Step 4: Recommend concrete investigation actions.
1. Check DB connection pool config (max connections, timeout settings)
2. Add structured logging at each stage boundary with latency
3. Check cache client retry/timeout configuration
4. Look for correlation between error timestamps and traffic spikes
STATE S_4: [S_3 + Action plan: 4 diagnostic steps prioritized by likelihood]
Termination: S_4 contains actionable diagnosis.
ANSWER:
Most likely cause: DB connection pool exhaustion under load.
Diagnostic steps:
1. Check your DB connection pool max size and wait timeout
2. Add timing logs between each stage (DB -> cache -> format)
3. Review cache client timeout and retry config
4. Correlate 500 error timestamps with traffic volume
Example 3: Algorithm design with self-correction
User: "Design an algorithm to find the longest increasing subsequence in O(n log n)."
STATE S_0: [Known: LIS problem, Goal: O(n log n) algorithm]
Step 1: The naive DP approach is O(n^2) -- for each element, scan all
prior elements. The bottleneck is finding the best predecessor.
STATE S_1: [S_0 + Naive DP is O(n^2), bottleneck: finding best predecessor
for each element]
Step 2: Replace linear scan with binary search. Maintain an array `tails`
where tails[i] = smallest tail element of all increasing subsequences
of length i+1.
STATE S_2: [S_1 + Key insight: maintain `tails` array, use binary search
to find insertion point. tails is always sorted.]
Step 3: For each element x in the input:
- If x > tails[-1]: append x (extends longest subsequence)
- Else: binary search for leftmost tails[j] >= x, set tails[j] = x
STATE S_3: [S_2 + Complete algorithm: iterate + binary search on tails.
O(n) iterations * O(log n) binary search = O(n log n)]
Termination: S_3 contains the complete algorithm and complexity proof.
ANSWER:
Maintain a `tails` array where tails[i] holds the smallest possible
tail element for an increasing subsequence of length i+1. For each
element, binary search `tails` to find where it fits. This gives
O(n log n) time, O(n) space.
Best Practices
Do:
- Keep each reasoning step atomic -- one inference, one derivation, one sub-conclusion per step
- Write state updates as cumulative summaries, not append-only logs; drop superseded information
- Flag and correct noisy steps explicitly rather than silently continuing with confusion
- Increase self-scrutiny as step count grows; if you're past step 6-7, strongly question whether each new step is necessary
- Terminate as soon as the state contains enough to answer the question
Avoid:
- Do not carry forward the full text of prior steps; the state summary replaces them
- Do not skip the state update after a step -- an unrecorded conclusion is a lost conclusion
- Do not continue reasoning after the answer is derivable from the current state (this is the overthinking the framework corrects)
- Do not use this framework for simple one-step questions; it adds overhead that is only justified for 3+ step reasoning chains
- Do not treat every step as equally trustworthy; later steps in long chains deserve more skepticism
Error Handling
- Circular reasoning detected: If S_t is essentially identical to S_{t-2} or earlier, halt and reframe the sub-problem. The reasoning has entered a loop. Explicitly state the loop and try an alternative approach.
- Contradictory state: If a new step's conclusion contradicts an established conclusion in S_{t-1}, do not silently overwrite. Flag the contradiction, determine which conclusion has stronger support, and update the state with a resolution note.
- State explosion: If the state summary grows beyond 5-6 key facts, compress by identifying which conclusions subsume earlier ones. Keep the state lean.
- Premature termination: If the state appears complete but the answer derived from it is wrong or incomplete, add a verification step that cross-checks the answer against the original constraints in S_0.
Limitations
- This framework adds structural overhead that is counterproductive for simple questions answerable in 1-2 reasoning steps
- The momentum correction heuristic (increasing alpha) is a rough approximation; it may over-dampen genuinely novel late-stage insights in some problems
- Claude cannot literally implement linear attention at inference time; this skill operationalizes the paper's insights as a structured reasoning protocol, which captures the benefits of state compression and noise correction but not the raw computational speedup
- Problems requiring heavy backtracking (e.g., search problems with many dead ends) may need the full reasoning trace rather than a compressed state
- The framework works best for sequential reasoning; problems requiring parallel exploration of multiple hypotheses need adaptation (maintain multiple state branches)
Reference
Paper: A State-Transition Framework for Efficient LLM Reasoning -- Zhang et al., ICLR 2026. Key sections: Section 3 (Mixed Attention Module and state update formulas), Section 4 (state-based reasoning strategy with momentum correction), Table 1 (benchmark results showing 16-18% efficiency gains with maintained or improved accuracy).
1---2name: state-transition-framework-reasoning3description: Applies a state-transition reasoning framework that models multi-step reasoning as an evolving state, compressing historical reasoning into a compact state representation and correcting noisy intermediate steps via momentum-based smoothing. Improves efficiency and accuracy on long reasoning chains. Trigger phrases: "reason step by step with state tracking", "use state-transition reasoning", "solve this with efficient chain-of-thought", "break this into reasoning states", "apply state-based reasoning", "reason efficiently without overthinking"4---56# State-Transition Framework for Efficient LLM Reasoning78This skill teaches Claude to structure complex multi-step reasoning as a **state-transition process** based on the framework from Zhang et al. (ICLR 2026). Instead of generating an unconstrained chain-of-thought where every token attends to every prior token, the approach segments reasoning into discrete steps, maintains a compressed **reasoning state** that accumulates conclusions from prior steps, and applies **momentum-based correction** to detect and dampen noisy or redundant reasoning. The result is reasoning that stays focused, avoids overthinking, and produces clearer intermediate conclusions.910## When to Use1112- When a user asks Claude to solve a complex multi-step math, logic, or coding problem that requires long reasoning chains (e.g., competitive programming, algorithm design, debugging multi-layered issues)13- When Claude's initial reasoning attempt produces verbose, repetitive, or circular thinking that wastes tokens without progress14- When the user requests "efficient reasoning" or wants Claude to avoid overthinking on a problem15- When solving problems that require tracking many intermediate results across steps (e.g., dynamic programming derivations, proof construction, multi-file refactoring plans)16- When the user explicitly asks for state-tracked or structured chain-of-thought reasoning17- When debugging a problem where prior reasoning steps have introduced confusion or contradictory conclusions1819## Key Technique2021### Reasoning as State Transitions2223Standard chain-of-thought reasoning treats the entire generated sequence as a flat token stream. Every new token must (implicitly) attend to all prior tokens, which becomes costly and error-prone as reasoning grows long. The state-transition framework instead **segments** the reasoning into discrete steps, where each step produces a **conclusion** that gets folded into a compact **reasoning state** `S_t`. At step `t`, the reasoner only needs the current query and the accumulated state `S_t` -- not the raw text of all prior steps. This is analogous to how a programmer tracks variable values through a debugger rather than re-reading the entire execution log.2425### Momentum-Based Noise Correction2627Not every reasoning step moves the solution forward. Some steps introduce noise -- wrong assumptions, unnecessary tangents, or redundant restatements. The framework detects this by computing the **reasoning direction** at each step: `delta_t = S_t - S_{t-1}`. It then maintains a running average of all prior directions `delta_bar_{t-1}`. Each step's direction is corrected via momentum blending: `delta_hat_t = (1 - alpha) * delta_t + alpha * delta_bar_{t-1}`, where `alpha` increases as reasoning progresses (starting at 0, capping at ~0.4). Early steps are trusted more; later steps are increasingly regularized toward the established reasoning trajectory. This prevents late-stage overthinking and circular reasoning.2829### Practical Application for Claude3031Since Claude cannot modify its own attention mechanism at inference time, this skill operationalizes the framework as a **structured reasoning protocol**: explicitly maintain a state summary after each reasoning step, evaluate whether each new step is productive or noisy relative to the accumulated direction, and apply self-correction when reasoning drifts.3233## Step-by-Step Workflow34351. **Parse the problem and identify the reasoning type.** Determine whether the task is mathematical derivation, code debugging, logical deduction, planning, or another multi-step domain. Identify what a "step" means in this context (e.g., one equation transformation, one function analysis, one logical inference).36372. **Initialize the reasoning state S_0.** Write a concise summary of what is known from the problem statement: the givens, constraints, and goal. This is the initial state before any reasoning begins. Format it as a labeled block:38 ```39 STATE S_0: [Known: ..., Goal: ..., Constraints: ...]40 ```41423. **Execute reasoning step t.** Perform one logical unit of reasoning -- a single derivation, deduction, or analysis. Keep the step focused on one sub-goal. Do not attempt multiple leaps in a single step.43444. **Extract the conclusion and update state S_t.** After each step, write the new state by appending the step's conclusion to the prior state. Drop the working details; keep only the result. Format:45 ```46 STATE S_t: [S_{t-1} conclusions + new conclusion from step t]47 ```48495. **Evaluate reasoning direction.** Compare S_t to S_{t-1}. Ask: "Did this step produce new information that moves toward the goal?" If the delta is near-zero (restated something already known), tangential (explored an irrelevant path), or contradictory (conflicts with established conclusions), flag it as noisy.50516. **Apply momentum correction for noisy steps.** If a step is flagged noisy, do not simply discard it. Instead, blend: keep the portion that aligns with the overall reasoning trajectory and discard the divergent portion. Rewrite the state update to reflect only the productive component. Explicitly note the correction:52 ```53 CORRECTION: Step t was partially noisy. Retaining [useful part], discarding [tangent/repetition].54 ```55567. **Increase skepticism as reasoning lengthens.** For early steps (steps 1-3), trust each step's output with high confidence. As step count increases beyond 5-6, apply greater scrutiny to each new step -- the equivalent of increasing alpha. Ask: "Is this step genuinely needed, or am I overthinking?"57588. **Check for termination.** After each state update, evaluate whether S_t contains sufficient information to answer the original question. If yes, proceed to formulate the answer. Do not continue reasoning past the point of sufficiency.59609. **Synthesize the final answer from the terminal state.** Construct the answer directly from the final state S_T, not by re-reading all intermediate steps. The state should contain everything needed.616210. **Present the answer with optional reasoning trace.** Give the user the final answer first, then optionally show the state progression as a compact trace for transparency.6364## Concrete Examples6566**Example 1: Multi-step mathematical reasoning**6768User: "What is the remainder when 2^100 is divided by 7? Use state-transition reasoning."6970```71STATE S_0: [Known: compute 2^100 mod 7, Goal: find remainder]7273Step 1: Compute small powers of 2 mod 7 to find a cycle.74 2^1 mod 7 = 2, 2^2 mod 7 = 4, 2^3 mod 7 = 17576STATE S_1: [2^k mod 7 cycles with period 3: {2, 4, 1, 2, 4, 1, ...}]7778Step 2: Express 100 in terms of the cycle length.79 100 = 3 * 33 + 1, so 2^100 mod 7 = 2^1 mod 7 = 28081STATE S_2: [100 mod 3 = 1, therefore 2^100 mod 7 = 2]8283Termination check: S_2 contains the answer.8485ANSWER: The remainder is 2.86```8788**Example 2: Debugging a multi-layered code issue**8990User: "My API returns 500 errors intermittently. The endpoint calls a database, then a cache layer, then formats the response. Help me reason through this."9192```93STATE S_0: [Known: intermittent 500s on API endpoint with 3 stages:94 DB query -> cache layer -> response formatting. Goal: identify root cause]9596Step 1: Intermittent failures rule out static bugs (syntax, logic).97 Points to: resource exhaustion, timeouts, race conditions, or transient98 external failures.99100STATE S_1: [S_0 + Root cause category: transient/resource issue, not static bug]101102Step 2: Analyze each stage for transient failure modes.103 - DB: connection pool exhaustion, query timeout, deadlocks104 - Cache: connection refused, eviction during read, serialization error105 - Formatting: unlikely to be intermittent unless input-dependent106107STATE S_2: [S_1 + Primary suspects: DB connection pool or timeout;108 Cache connection or serialization; Formatting ruled low-probability]109110Step 3: Intermittent pattern narrows further. If failures correlate with111 load, connection pool exhaustion is most likely. If random, timeout or112 deadlock.113114STATE S_3: [S_2 + Key diagnostic: check if failure rate correlates with115 request volume. If yes -> pool exhaustion. If no -> timeout/deadlock]116117CORRECTION: Step 3 partially restated Step 2's suspects.118 Retaining: the load-correlation diagnostic.119 Discarding: repeated enumeration of failure modes.120121Step 4: Recommend concrete investigation actions.122 1. Check DB connection pool config (max connections, timeout settings)123 2. Add structured logging at each stage boundary with latency124 3. Check cache client retry/timeout configuration125 4. Look for correlation between error timestamps and traffic spikes126127STATE S_4: [S_3 + Action plan: 4 diagnostic steps prioritized by likelihood]128129Termination: S_4 contains actionable diagnosis.130131ANSWER:132Most likely cause: DB connection pool exhaustion under load.133Diagnostic steps:1341. Check your DB connection pool max size and wait timeout1352. Add timing logs between each stage (DB -> cache -> format)1363. Review cache client timeout and retry config1374. Correlate 500 error timestamps with traffic volume138```139140**Example 3: Algorithm design with self-correction**141142User: "Design an algorithm to find the longest increasing subsequence in O(n log n)."143144```145STATE S_0: [Known: LIS problem, Goal: O(n log n) algorithm]146147Step 1: The naive DP approach is O(n^2) -- for each element, scan all148 prior elements. The bottleneck is finding the best predecessor.149150STATE S_1: [S_0 + Naive DP is O(n^2), bottleneck: finding best predecessor151 for each element]152153Step 2: Replace linear scan with binary search. Maintain an array `tails`154 where tails[i] = smallest tail element of all increasing subsequences155 of length i+1.156157STATE S_2: [S_1 + Key insight: maintain `tails` array, use binary search158 to find insertion point. tails is always sorted.]159160Step 3: For each element x in the input:161 - If x > tails[-1]: append x (extends longest subsequence)162 - Else: binary search for leftmost tails[j] >= x, set tails[j] = x163164STATE S_3: [S_2 + Complete algorithm: iterate + binary search on tails.165 O(n) iterations * O(log n) binary search = O(n log n)]166167Termination: S_3 contains the complete algorithm and complexity proof.168169ANSWER:170Maintain a `tails` array where tails[i] holds the smallest possible171tail element for an increasing subsequence of length i+1. For each172element, binary search `tails` to find where it fits. This gives173O(n log n) time, O(n) space.174```175176## Best Practices177178**Do:**179- Keep each reasoning step atomic -- one inference, one derivation, one sub-conclusion per step180- Write state updates as cumulative summaries, not append-only logs; drop superseded information181- Flag and correct noisy steps explicitly rather than silently continuing with confusion182- Increase self-scrutiny as step count grows; if you're past step 6-7, strongly question whether each new step is necessary183- Terminate as soon as the state contains enough to answer the question184185**Avoid:**186- Do not carry forward the full text of prior steps; the state summary replaces them187- Do not skip the state update after a step -- an unrecorded conclusion is a lost conclusion188- Do not continue reasoning after the answer is derivable from the current state (this is the overthinking the framework corrects)189- Do not use this framework for simple one-step questions; it adds overhead that is only justified for 3+ step reasoning chains190- Do not treat every step as equally trustworthy; later steps in long chains deserve more skepticism191192## Error Handling193194- **Circular reasoning detected:** If S_t is essentially identical to S_{t-2} or earlier, halt and reframe the sub-problem. The reasoning has entered a loop. Explicitly state the loop and try an alternative approach.195- **Contradictory state:** If a new step's conclusion contradicts an established conclusion in S_{t-1}, do not silently overwrite. Flag the contradiction, determine which conclusion has stronger support, and update the state with a resolution note.196- **State explosion:** If the state summary grows beyond 5-6 key facts, compress by identifying which conclusions subsume earlier ones. Keep the state lean.197- **Premature termination:** If the state appears complete but the answer derived from it is wrong or incomplete, add a verification step that cross-checks the answer against the original constraints in S_0.198199## Limitations200201- This framework adds structural overhead that is counterproductive for simple questions answerable in 1-2 reasoning steps202- The momentum correction heuristic (increasing alpha) is a rough approximation; it may over-dampen genuinely novel late-stage insights in some problems203- Claude cannot literally implement linear attention at inference time; this skill operationalizes the paper's insights as a structured reasoning protocol, which captures the benefits of state compression and noise correction but not the raw computational speedup204- Problems requiring heavy backtracking (e.g., search problems with many dead ends) may need the full reasoning trace rather than a compressed state205- The framework works best for sequential reasoning; problems requiring parallel exploration of multiple hypotheses need adaptation (maintain multiple state branches)206207## Reference208209**Paper:** [A State-Transition Framework for Efficient LLM Reasoning](https://arxiv.org/abs/2602.01198v1) -- Zhang et al., ICLR 2026. Key sections: Section 3 (Mixed Attention Module and state update formulas), Section 4 (state-based reasoning strategy with momentum correction), Table 1 (benchmark results showing 16-18% efficiency gains with maintained or improved accuracy).