Source-linked AI summary

StateWise: Diagnosing and Repairing Persistent Operational State Before Agent Actions

Yongyuan Peng, Zhou Feng, Tongying Wu, Jiahao Chen, Yuan Su, Chunyi Zhou, Tianyu Du, Shouling Ji

arXiv:2610.05241v1cs.SEcs.AI

TL;DR

As projects and environments change, persistent operational records can become invalid, yet action review and provenance mechanisms may leave the underlying state uncorrected. StateWise identifies decision-critical records, verifies and repairs them with scoped evidence, and replans before execution. On the primary 150-case benchmark, it achieves 93.3% overall correctness under corrupted persistent state, compared with 38.7% for the baseline, with no unsafe actions observed.

  • Problem

    Persistent operational records can become outdated or inapplicable, while action safeguards, provenance, or local clarification may leave the persistent premise uncorrected for later tasks.

    Source: §1 · pp. 2–3
  • Method

    StateWise uses counterfactual replanning to find decision-critical records, resolves validity with evidence, preserves scoped corrections, replans, and independently checks the revised action.

    Source: §1 · p. 4
  • Results

    93.3% overall correctness under corrupted persistent state for StateWise, compared with 38.7% for the baseline, with no unsafe actions observed.

    Source: §7 · p. 18
  • Takeaways & Limitations

    The evaluation supports treating persistent-state recovery as part of reliable agent execution, with confirmed corrections remaining useful across subsequent tasks.

    Source: §6 · pp. 17–18

    The audit relies on model annotation and mainly covers one agent family; executable evaluations use controlled single-record defects, simulated developer responses, a limited cross-model set, and four-task sequences.

    Source: §6 · p. 18

Abstract

from arXiv · show

LLM agents combine reasoning, tool use, and persistent memory to support work across tasks by reusing stored operational records as premises for later actions. However, environmental or requirement changes can invalidate these records, while existing action review, provenance tracking, and clarification mechanisms may leave the underlying persistent state uncorrected. Our audit of coding-agent trajectories identifies candidate failure chains in which invalid records are reused, leading to task failures and unsafe modifications. We propose StateWise, a framework for diagnosing and repairing persistent operational state before action execution. StateWise uses record-level counterfactual replanning to identify decision-critical records, then establishes their current validity through reliability checks, read-only verification of machine-observable facts, and targeted clarification of developer-owned intent. Typed evidence grounding binds evidence to specific records and scopes, enabling persistent corrections with repair lineage. The agent then replans from the repaired state, followed by an independent state-action check before execution. We evaluate StateWise on 150 executable coding-agent cases across diverse runtime environments, workspace configurations, and repository settings, complemented by cross-model evaluations. Under corrupted persistent state, StateWise achieves 93.3% overall correctness, compared with 38.7% for the baseline agent, with no unsafe actions. Component ablations, multi-task experiments, and transfer evaluations further demonstrate effective recovery, persistent corrections, and transferability across repositories and tool interfaces.

1 Introduction

Persistent operational records can become outdated or inapplicable as projects, policies, and environments change, and reusing them can cause task failures or unsafe modifications. StateWise addresses the gap between reviewing an action and correcting the persistent premise behind it through diagnosis, verification, scoped repair, and replanning.

1 Introduction

  • Persistent records can become outdated or inapplicable, and blocking an erroneous operation alone leaves its underlying premise available to influence later plans.Existing action controls may constrain an operation without correcting the state error; trusted provenance does not establish current validity, and locally corrected decisions can leave stale records in persistent state.Source: §1 · pp. 2–3
  • The audit retained 40 candidate failure chains from 100 sampled coding-agent sessions in which historical information guided actions despite evidence that it no longer applied.The audit checked cited turns and chronology; candidate chains involved task failures, user corrections, or unsafe modifications.Source: §1 · pp. 2–3
  • Recovery targets records that change the proposed action when altered or removed, verifies their current validity, persists scoped corrections, and replans before external side effects.A persistent-state-induced action failure combines a defective or mis-scoped record, a changed proposed action, and an incorrect or unsafe outcome.Source: §1 · p. 3
  • StateWise traces records supporting a proposed side-effecting action, resolves their validity, persists confirmed corrections, replans, and independently checks the revised action before execution.It uses constrained counterfactual replanning to identify decision-critical records, then hierarchical resolution, typed evidence grounding, and a state–action check.Source: §1 · pp. 3–4
  • The paper contributes an audit and formalization of persistent-state recovery, StateWise’s diagnosis and repair framework, evaluations across cases and settings, and an open-source implementation.The evaluation includes component ablations, four-task sequences, cross-model tests, and transfer evaluations across repositories and tool interfaces.Source: §1 · p. 4

2 Background and Related Work

Related work addresses memory continuity, changing facts, decision provenance, and action oversight. The paper identifies their intersection as the need to locate invalid persistent records, establish current validity, and preserve scoped corrections.

2 Background and Related Work

  • Agent-memory systems organize and retrieve earlier experience, while memory benchmarks examine recall, cross-session reasoning, and adaptation to updated information.A-Mem links and updates structured memories; Mem0 extracts and consolidates salient conversational information for persistent retrieval.Source: §2 · p. 4
  • Research on temporal validity, stale memory, and knowledge editing addresses changing facts and updates, while operational records also require checking applicability to the current task and scope.The cited research includes temporal question-answering, superseding evidence, and preservation of unrelated knowledge during factual updates.Source: §2 · p. 5
  • Attribution and provenance methods trace contextual influences on decisions, but operational diagnosis must connect those links to evidence of a record’s current value and applicability.An authentic record can still become outdated when its environment changes.Source: §2 · p. 5
  • Action oversight, clarification, execution controls, and risk evaluation address proposed operations, while cross-task recovery also requires writing corrections to persistent records within their applicable scope.Repeated confirmations may encourage routine approval, and poorly explained warnings may be ignored.Source: §2 · p. 5
  • The remaining challenge is to locate an erroneous persistent record that influenced an action, establish its current validity, and preserve a correction within the appropriate scope.Source: §2 · p. 5

3 Problem Definition

The problem definition treats persistent-state recovery as identifying defective records that influence a proposed action, establishing admissible corrections, and replanning while preserving safety and unrelated state. It also specifies how to assess repair reuse across tasks and interfaces.

3 Problem Definition

  • The audit sampled 100 coding-agent sessions, identified 60 candidate chains, and retained 40 after checking cited turns and chronology.Figure 2 summarizes the audit funnel, invalid-state categories, and observed consequences; categories may overlap.Source: §3 · p. 5, Figure 2 · p. 6
  • A persistent operational record represents a typed key, semantic value, time and freshness metadata, scope, and provenance and authority metadata.Storage alone does not establish that a record is correct or currently valid.Source: §3 · p. 6
  • A record is decision-critical when changing or removing it while holding the rest of the retrieved context fixed changes the proposed action.Decision influence is distinct from retrieval relevance, and a decision-critical record may be valid or defective.Source: §3 · p. 6
  • A persistent-state-induced action failure combines a defective record, an action difference relative to its valid counterpart, and an incorrect or unsafe outcome.Defects include incorrect or stale values, conflict with newer evidence, or application to the wrong scope; other planning errors may still affect the reference action.Source: §3 · p. 7
  • Recovery identifies decision-critical records, obtains evidence from an authority appropriate to each fact, and corrects confirmed defects within established scopes.Admissible recovery constrains the revised action by safety and permission requirements and preserves active records outside repair scopes.Source: §3 · pp. 7–8
  • Cross-task persistence is assessed across task sequences that carry the persistent store forward while resetting conversation and workspace conditions between tasks.Attributing later outcomes to repair reuse requires evidence that subsequent tasks retrieve and use the corrected record.Source: §3 · p. 8
  • Interface-conditioned transfer uses a fixed recovery core with a declarative interface specifying tool operations, typed state and action slots, scope semantics, and verifier adapters.Authoritative reference values and outcome-scoring oracles are external to the planner and resolver.Source: §3 · p. 8

4 Method

StateWise diagnoses and repairs decision-critical persistent records before execution, linking action influence to current validity and scoped corrections. It replans from repaired state and independently checks the revised action before execution.

4.1 Overview of StateWise

  • StateWise inserts recovery between a planner’s side-effecting proposal and execution, connecting record influence, current validity, and persistent repair.It returns a checked action or safe stop, with confirmed corrections available to later tasks.Source: §4 · p. 8, §4.1 · p. 9

4.2 Attribution: Decision-Critical Premises

  • Attribution probes linked records one at a time while holding other planning inputs fixed, then checks action-relevant changes and type/scope bindings.Strongly linked candidates with inconclusive dependence are retained for verification when probe evidence is insufficient.Source: §4.2 · pp. 9–10

4.3 Resolution: Current Validity

  • Resolution assesses record type, scope, authority, freshness, and conflicting evidence; it uses read-only verification for observable facts and targeted clarification for developer-owned choices.Records are classified as valid, defective, or unresolved; valid values remain unchanged, while unresolved premises prevent execution.Source: §4.3 · pp. 10–11

4.4 Persistent Repair and Action Control

  • Repair binds corrective evidence to the record and scope, preserves lineage, and leaves records outside the repair scope unchanged; the planner then replans from updated state.An independent check covers state–action consistency, invariants, and permissions; unresolved premises or failed checks produce a safe stop.Source: §4.4 · p. 11

5 Evaluation

The evaluation tests StateWise on executable coding tasks, comparing recovery under erroneous state with interventions and assessing component effects, cross-task reuse, and transfer. Across these settings, results address task correctness and action safety alongside the persistence and scope of repairs.

5.1 Experimental Setup and Metrics

  • The finalized pipeline is evaluated on 150 cases—125 operation tasks and 25 safe-stop tasks—with matched conditions used for comparisons.Additional studies use two 150-case sets, four-task sequences, and cross-model cases; the evaluation set spans varied runtime, repository, and user settings.Source: §5.1 · pp. 12–13, Figure 4 · p. 12

5.2 RQ1: Impact of Erroneous State

  • Corrupting one target record cuts OC from 80.7% to 38.7% and AC from 76.8% to 27.2%; removing it reaches only 45.3% OC and 35.2% AC.Removal lowers UAR to 9.3%, while StateWise achieves 93.3% OC and 92.8% AC from erroneous memory, with no observed unsafe action.Source: §5.2 · p. 14, Figure 5 · p. 14

5.4 RQ3: Recovery Across Settings

  • Across four planning models, OC ranges from 80.0% to 94.4% and AC from 69.2% to 90.9%, with no observed unsafe action.Task completion varies by planner, but the recovery procedure supports correct and safe recovery across all four tested models.Source: Figure 7 · p. 15, §5.4 · p. 15

5.5 RQ4: Component Contributions

  • Removing Attribution lowers OC by 53.3 percentage points, while removing Typed Grounding lowers it by 27.3 points.Removing Replanning or the Residual Gate lowers OC by 2.7 points each; the Attribution ablation also disables downstream state intervention.Source: Figure 8 · p. 16, §5.5 · p. 16

5.6 RQ5: Cross-Task Persistence

  • Across subsequent tasks, StateWise reaches 92.7% correct and safe completion and 90.6% AFS, near the correct-memory reference’s 91.7% and 87.5%.Repaired-record retrieval reaches 97.9%; tested baselines have later-task completion of 1.0%–6.2% and AFS no higher than 3.1%.Source: Table 2 · p. 16, §5.6 · pp. 16–17

5.7 RQ6: Transfer Across Interfaces

  • On 106 unseen configurations, StateWise achieves 93.4% OC, 92.6% AC, and zero UAR, with OC comparable to seen configurations.The evaluation includes 8 new repositories, 2 tool operations, 6 semantic state types, and 54 new state–action combinations; transfer uses supplied interface contracts.Source: Figure 9 · p. 17, §5.7 · p. 17

6 Discussion

Persistent-state recovery connects action-level diagnosis to scoped corrections that remain useful across tasks. Its applicability depends on explicit record–action bindings, accessible authoritative evidence, and established repair scopes.

6 Discussion

  • Confirmed corrections remain useful after conversation and workspace resets, supporting later planning through persistent memory.The paired tests distinguish suppressing unsafe operations from restoring task capability; ablations identify validity resolution, typed grounding, and persistent repair as major contributors to recovery.Source: §6 · pp. 17–18
  • Constrained counterfactual replanning, validity resolution, and typed grounding link an action’s supporting records to scoped persistent corrections.The binding specifies which active value is superseded and which unrelated records remain unchanged; writeback preserves correction lineage for replanning and later retrieval.Source: §6 · p. 18
  • Evaluations use controlled single-record defects, simulated developer responses, a limited cross-model set, and four-task sequences.Longer deployed studies with independent human annotation should examine interacting records, conflicting corrections, and partial evidence; external services and collaborative agents require broader verifier coverage and mechanisms for changing authority and overlapping scopes.Source: §6 · p. 18

7 Conclusion

StateWise diagnoses and repairs invalid persistent operational records before action execution, preserving verified corrections for later tasks. On the primary benchmark, it achieves 93.3% overall correctness under corrupted persistent state, compared with 38.7% for the baseline, with no unsafe actions observed.

7 Conclusion

  • 93.3% overall correctness under corrupted persistent state, compared with 38.7% for the baseline, with no unsafe actions observed.Source: §7 · p. 18
  • StateWise connects action attribution, current-validity verification, and scoped persistent repair with replanning and independent action checks.Confirmed corrections are preserved for later tasks.Source: §7 · p. 18
  • The work addresses the gap between intervening in the current action and correcting the persistent premise that guides subsequent decisions.It proposes evaluating operational memory through current applicability, influence on actions, and reuse of verified corrections.Source: §7 · p. 18
Loading 2610.05241v1…