Agents

Agent failures hide in the gaps between logged steps

Reviewing Securing and Auditing Long-Horizon LLM Agents: State-Transfer Auditing and Controls in the Agent Harness · Deep Shah and Nehal Kathrotia

Agent failures hide in the gaps between logged steps

Researchers show that many agent security failures happen when state moves between context, memory and the outside world, where conventional logs never look. Small hash-chained records at each boundary pinpoint where things went wrong and give runtime controls somewhere outside the prompt to live, though the design assumes the harness itself is trustworthy.

Picture a long-running coding agent whose context window fills up. The harness summarises old turns to make room, and the summary quietly drops the line where the user said not to touch the deployment config. The trace looks fine. The constraint simply stopped existing between two logged steps.

That gap is the subject of this research. An agent harness constantly moves state: from working context into session history, from history into persistent memory, and from the outside world back into context. Conventional logs record prompts and tool calls. They do not record what crossed those boundaries, or what changed on the way.

The researchers sort the failures into three kinds. A transfer can admit content nobody checked, which is how indirect prompt injection and poisoned memory writes arrive. It can rewrite state lossily, dropping a user constraint or stripping the note of where a fact came from. Or it can restore state incompletely: roll back the workspace, and the inference server's cache may still hold the aborted run.

Their answer is a small record at every boundary. It says what went in, what came out, who was responsible, which approvals were active and which checks ran. Each record carries a hash of the one before, so a deleted or altered entry breaks the chain. Cheap deterministic checks run on every transfer, kept separate from slower checks that ask a model to judge meaning. The overhead is measured in microseconds.

The audit trail becomes the control plane

What interests me most is not the logging. It is that the same records give runtime controls somewhere durable to stand. Approvals live in counters outside the prompt, so an injected instruction cannot claim permission it was never given, and a real approval cannot be replayed. Labels follow content into memory, so text from a web page does not quietly become trusted fact. This matters because the prompt is exactly where the attacker writes.

The attribution result is strong. Across 240 multi-step runs, half with injected faults, the records identified the exact step where things went wrong 98.3 per cent of the time. Ordinary lifecycle and tool logs managed fewer than one in five.

Now the caveats. The faults were injected by the researchers, not chosen by an attacker who knew the audit was there. The design assumes an intact harness and an audit store nobody can rewrite; lose either and the chain proves nothing. The model-based checks are a new target, because an attacker can try to make them omit the field that matters. Commercial model APIs hide their cache state, which limits the rollback binding. And the records hold user data, so they need protecting too.

None of that undoes the core observation. Agents fail between steps, and we have been logging the steps.

Further analysis

Problem

The paper studies security and reliability failures that arise when long-horizon LLM agents move state between the working context, session history, persistent memory and the external environment. Conventional traces record prompts and tool calls but omit what crosses these boundaries, so attacks and faults that exploit state transfers go undetected or are misattributed. Transfer failures include admitting unchecked content (indirect prompt injection and unverified memory writes), lossy rewriting (compaction or consolidation that drops user constraints or provenance), and incomplete restoration (rollbacks that leave inference-server KV state or uncommitted memory active). This matters because multi-step trajectories propagate faults, runtime monitors lack the transfer evidence they need, and operators cannot reconstruct causal chains for recovery or accountability.

Approach

The authors propose a state-transfer audit architecture that treats each harness boundary as an audit point. At every transfer the harness emits a minimal, hash-chained record that links input and output segments, timestamps, responsible principals, active authorisations, integrity and confidentiality labels, checks run, and pointers to backing-store content. The design separates low-overhead deterministic checks from model-based semantic checks, and it binds internal context, memory and inference-server cache state to external actions. They implemented a Python reference middleware that wraps eight transfers, uses SHA-256 hash chaining, carries integrity/confidentiality labels and durable approval counters, and binds snapshots to cache identifiers. The implementation was evaluated with 20,000 deterministic wrapper invocations for latency and 240 multi-step trajectories (120 benign, 120 fault-injected across six fault families) for detection and attribution.

Key Findings

  • Transfer failure taxonomy: failures cluster into three modes: admitting unchecked content, lossy rewriting, and incomplete restoration; these explain many observed attacks such as memory poisoning, authority collapse and KV-cache leakage.
  • Practical record format: a compact, common record per transfer can carry identifiers, hashes, labels, approvals, checks and pointers to full content; most fields are small so storage overhead is modest (records average 524 bytes).
  • Low deterministic overhead: seven transfers exhibit median wrapper latencies of 12.5–22.1 microseconds, compaction median 81.6 microseconds, and serialized records match the predicted roughly 0.5 MB per 1000 transfers.
  • Strong detection and attribution gains: deterministic transfer checks alone reached 91.7% recall (95.7% F1) on injected faults; full transfer records achieved 98.3% recall (99.2% F1) at 0.0% false positive rate. Exact root-cause step attribution rose from about 11–17% to 98.3% when using the emitted records; ablating lineage, auth/cache bindings or rewrite diffs reduced step accuracy substantially.
  • Enables runtime controls: the same transfer records support least-privilege capabilities, replay-resistant authorisation outside the prompt, information-flow labels, obligation monitors and transactional recovery across multi-agent pipelines.

Limitations

The approach assumes an untampered harness and an append-only audit store; a compromised harness or operator who can rewrite the store is out of scope. Model-based checks add runtime cost and create additional attack surface because extractors themselves can be targeted. Multimodal GUI settings pose extra challenges: screenshots are large, cannot be re-fetched, and visual compaction effects are under-measured. Commercial model APIs that hide internal KV-cache state limit direct cache bindings. Some checks, such as constraint retention, require model calls whose real-world recall and cost remain unmeasured. Audit records also store user data, requiring retention and access controls.

Implications

An attacker who controls observations or telemetry can plant instructions, spoof provenance, poison shared memories, trigger authority collapse during consolidation, or exploit incomplete rollbacks by leaving KV-cache state that later influences protected decisions. Attackers can also flood or steer agents onto unlogged side channels, or target model-based extractors to omit critical fields. The proposed transfer records would make such chains observable, enabling precise causal attribution and facilitating runtime interventions, but they do not prevent harness compromise or attacks that exploit unlogged channels.

The paper title, authors and abstract

Securing and Auditing Long-Horizon LLM Agents: State-Transfer Auditing and Controls in the Agent Harness

Deep Shah, Nehal Kathrotia

Long-horizon LLM agents across codebases, web browsers, and enterprise infrastructure rely on an execution harness to move state between the working context, session history, persistent memory, and external environment. While conventional execution traces log model prompts and tool calls, critical security and reliability failures occur during state transfers: a transfer can admit unchecked content (indirect prompt injections, unverified memory writes), rewrite state lossily (context compaction dropping user constraints, memory consolidation stripping source authority), or restore state incompletely (workspace rollbacks leaving aborted KV state active on the inference server). Because current traces omit what crosses these boundaries, failure attribution and runtime monitors fail on multi-step trajectories. We present a state-transfer audit architecture for the agent harness. At each transfer boundary, we define an audit point specifying the minimal hash-chained record the harness emits, separating low-overhead deterministic checks from model-based semantic checks and binding internal context, memory, and inference-server cache state to external actions. We show that the same transfer records required for causal failure attribution supply the durable state needed by runtime security controls, including least-privilege capabilities, replay-resistant authorization outside the prompt, information flow control, obligation monitors, and transactional recovery across multi-agent and infrastructure pipelines. Finally, we analyze multimodal GUI adaptations and implement and evaluate a reference harness middleware across 240 multi-step fault-injection trajectories, showing that transfer records localize root causes and catch cross-transfer violations missed by lifecycle and tool-only logs at microsecond deterministic overhead.