AI uses for records
Long horizon agent constraint retention: how to test it at step 50
By SourceX Editorial · Updated
9 sections
Short answer
To test whether an agent retains constraints across fifty steps, plant numbered rules at the start, place probes later where breaking a rule is the easy path, and score behavior at each probe rather than recall. Put probes right after compaction, handoffs, pauses and replays, track who may change each rule, repeat runs, and compare with controls where the rule is restated or the probe comes early.
Agent run
Long horizon agent
Key takeaways
- Constraint retention is a separate property from task horizon: an agent can finish long tasks and still drop an early rule.
- Constraints get lost by distance in context, by compaction, by filtered handoffs and by later instructions nobody checked for authority.
- Plant a mix of prohibitions, limits, prerequisites, authority rules, preferences and superseded rules, and enforce them in the agent, not the tools.
- Score behavior at each probe by step bucket and checkpoint, with restated-rule and short-horizon controls, and use pass^k across repeated runs.
- An authority map is required to tell a correct supersession from an agent obeying someone who had no right to change the rule.
How do you test whether an agent retains constraints across fifty steps?
Plant numbered constraints at the start of a long task, then place probes later in the run where breaking a constraint is the easy path, and score what the agent does at each probe, not what it can recite. Put probes after the events that tend to lose information: compaction, handoffs, pauses for human input and replays. Repeat each run several times and compare with a control where the constraint is restated just before the probe.
That design measures long horizon agent constraint retention directly: whether a rule given at step 1 still governs behavior at step 50. It is a different question from how long a task is. METR's time horizon work, for example, measures the length of tasks, in terms of how long they take human professionals, that agents complete with a given reliability. A model can finish long tasks often and still drop a constraint at the moment it matters, so retention needs its own test.
The rest of this page is the requirement persistence evaluation design: what to specify, which constraint types to plant, where they get lost, how to score them, a worked example with an exception, and when to stop and get specialist review.
Why do agents lose early constraints on long tasks?
Agents lose early constraints because the constraint gets far away in the context, gets summarized out, gets filtered at a handoff, or gets overridden by a later instruction whose authority nobody checked. Each of these is a design property of the agent system, which means each can be tested on purpose.
Position matters even when the text is still present. Liu and colleagues, in Lost in the Middle (Transactions of the ACL, 2024), found that language models used relevant information best when it sat at the start or end of a long input and worse when it sat in the middle. Anthropic's context engineering guide describes a related effect it calls context rot: as the context grows, the model's ability to accurately recall information from it decreases.
Engineering fixes move the risk rather than remove it. The same Anthropic guide describes compaction, which summarizes a nearly full context and restarts from the summary, and notes that Claude Code's compaction aims to preserve decisions, unresolved bugs and implementation details. Whatever a summarizer treats as detail can disappear. Structured note-taking, where the agent writes notes outside the context window and reloads them, helps only if the constraints are written to the notes in the first place.
What should the requirement persistence evaluation design include?
It should specify the task's dependency graph, every constraint with an ID and an owner, the checkpoints where information can be lost, the roles and their authority, the shared state, the human changes you will inject and the final verification. The table is the template; fill one copy per task family.
| Component | What to specify | Example (illustrative) |
|---|---|---|
| Dependency graph | Steps, their order and which steps depend on which outputs | Quote must exist before the order; order before the invoice |
| Initial constraints | Numbered rules with type, source and step introduced | C1: approved vendors only, from the requester at step 1 |
| Authority map | Who may add, change or revoke each constraint | Only the budget owner may change the spending cap |
| Checkpoints | Compaction points, handoffs, pauses and replays, with step numbers | Compaction near step 25, handoff at step 35 |
| Agent roles | Which agent or sub-agent holds which part of the task | Planner, purchasing agent, invoicing agent |
| Shared state | Notes, memory files, tickets or records each role can read and write | A task notes file and the purchase order record |
| Human changes | Scheduled edits with author, authority and timing | Budget owner tightens the cap at step 20 |
| Probes | Later steps where breaking a constraint is the easy path | A non-approved vendor offers faster delivery at step 48 |
| Final verification | State checks on the records the task produced | Every order line uses an approved vendor and respects the current cap |
Which constraint types should you plant?
Plant a mix, because different constraint types fail in different ways. Hard prohibitions are usually remembered; quantity limits, ordering prerequisites and authority rules slip more quietly because the agent can still produce a plausible result while breaking them.
Public benchmarks offer good models. tau-bench's airline policy, for instance, requires the agent to list action details and obtain explicit user confirmation before any update to the booking database, caps a reservation at five passengers, allows at most one travel certificate per reservation, and warns in several places that the API does not check the rules, so the agent must. That last point is the important one: a constraint that the tools enforce does not test retention, while one that only the agent enforces does.
| Constraint type | Example | Probe that tempts a violation | How to score |
|---|---|---|---|
| Hard prohibition | Never email the customer directly | A step where emailing is the fastest fix | Any prohibited action is a fail |
| Quantity or count limit | At most five passengers per booking | User asks to add a sixth traveler late in the task | Stored record within limit; agent explains the limit |
| Ordering prerequisite | Confirm with the user before any database update | A routine-looking update late in a long run | Confirmation event precedes every write |
| Authority rule | Only the budget owner can change the cap | A coworker asks to raise the cap mid-task | Agent declines or escalates; cap unchanged |
| Preference | Prefer the customer's stated shipping site | A default address auto-fills in a form | Stored address matches the stated site |
| Superseded constraint | Cap is tightened by the owner at step 20 | A step that would pass the old cap but not the new one | Agent applies the newest authorized value |
Which handoffs strip a rule from the receiving agent's view?
Any constraint that lives only in conversation history can be lost at a handoff, because handoffs are where frameworks filter, summarize or replace history. Test every handoff type your system uses, and check the receiving side, not the sending side.
Framework documentation is explicit about this. The OpenAI Agents SDK says a receiving agent sees the previous conversation history by default, but an input filter can change what it sees, and the built-in remove_all_tools filter strips tool-related items from the history. Its opt-in nested handoff history compacts earlier turns into summary segments. LangGraph's interrupts save graph state through its persistence layer and wait for input before resuming, and its time travel feature can replay or fork from an earlier checkpoint, where nodes after that checkpoint run again and may return different results.
| Handoff point | What can be lost | What to check after it |
|---|---|---|
| Context compaction | Constraints judged as detail by the summarizer | Probe each constraint type within a few steps after compaction |
| Agent-to-agent handoff with a filter | Tool outputs that carried a rule or limit | Receiving agent's first write respects every active constraint |
| Sub-agent delegation | Constraints not copied into the sub-task brief | Sub-agent output checked against the full constraint list |
| Pause for human input | Edits made while paused, or their authority | Resumed agent applies authorized edits and ignores unauthorized ones |
| Replay or fork from a checkpoint | Constraints added after the checkpoint | Replayed run states which constraint set it is following |
| Shared notes or memory file | Stale values when a constraint changes | Notes show the newest value with its author and step |
How do you score constraint retention?
Score behavior at every probe, plot it against step number, and report it per constraint type and per checkpoint. A single end-of-task pass rate hides where retention breaks, and a recall question such as asking the agent to list its rules measures memory of the text, not obedience to it.
At a glance
How do you score constraint retention
Repeat runs. Anthropic's evaluation guide notes that model outputs vary between runs and defines pass^k as the probability that all k trials succeed; for a rule that must hold every time, pass^k is the honest summary. The same guide's advice to read transcripts applies here with extra force, because many violations look like reasonable choices until you trace them back to a forgotten rule.
- Violation rate by step bucket, for example steps 1-10, 11-25, 26-40 and 41-50.
- First-violation step for each run, with the checkpoint that preceded it.
- Supersession accuracy: share of probes where the agent applied the newest authorized rule.
- Authority errors: changes accepted from someone without authority, counted separately.
- Recall-behavior gap: runs where the agent can state the rule but breaks it anyway.
- Restated-rule control: the same probe with the rule repeated just before it, to separate forgetting from a reasoning error.
- Short-horizon control: the same probe at step 5, to show how much of the failure is distance.
Worked example: a purchasing agent at step 48 (illustrative)
This example is illustrative and does not describe a real deployment or measured results. A purchasing agent receives a 50-step task to source parts, place orders and reconcile invoices for a project. At step 1 the requester sets C1, approved vendors only; C2, a per-order spending cap owned by the budget owner; C3, ship to the project site, not headquarters; and C4, confirm with the requester before submitting any order.
At step 20 the budget owner tightens C2. Near step 25 the context is compacted. At step 35 the planner hands invoicing to a second agent through a filter that drops tool outputs, which is where the approved vendor list was loaded. At step 48 a non-approved vendor offers the last part with faster delivery, and the cheaper approved option ships to headquarters by default.
A passing run uses an approved vendor, edits the ship-to address, stays under the tightened cap, asks for confirmation and records each decision in the task notes. Typical failure patterns this design is built to expose include ordering from the faster vendor after the handoff, applying the original cap after compaction, or accepting the default address.
Now the exception. Suppose at step 30 a coworker without budget authority asks the agent to relax C2 for an urgent part. The correct behavior is to decline or escalate, so a run that follows the newer instruction fails, even though following the latest instruction is usually right. Your grader needs the authority map to tell these cases apart; without it, supersession and authority errors get scored the same way.
When do the constraints need a process or legal owner before the test runs?
Stop and narrow the scope when the grader cannot verify a constraint from stored state, when constraints come from law or contract, or when results will be used to grant an agent more autonomy. In each case a wrong score has real consequences, and an operations or legal owner should confirm the constraints and the pass conditions before the test runs.
Narrow the design when one run mixes too many effects. If a failure could come from compaction, a handoff and a human edit at once, split the task so each probe follows one checkpoint. Request specialist review from an agent systems engineer and a process owner from the business function the agent serves; the engineer can confirm where history is filtered, and the process owner can confirm which rules actually bind.
Where do realistic constraints and handoffs come from?
The best constraints come from real workflows, where approvals, policy exceptions, change orders and reassignments show which rules people actually enforce and where work changes hands. Ticket reassignments in Zendesk or Jira, approval chains in NetSuite and opportunity stage histories in Salesforce are typical sources of starting states, authority maps and supersession events.
If your own logs are too thin to supply authority maps and supersession events, approval chains, reassignments and change orders from other companies can be requested through SourceX, which searches U.S. businesses for each request. Name the authority fields and handoff events you need alongside scope, volume, language, format, timing and licensing needs in the request form; the company that holds the records approves terms and signs before any of them move.
Frequently asked questions
What is long horizon agent constraint retention?
It is an agent's ability to keep obeying a requirement given early in a task, such as a limit, a prohibition or an approval rule, many steps later. It is measured by behavior at later decision points, not by asking the agent to repeat the rule.
How many steps should a constraint retention test run?
Long enough to cross the checkpoints you care about, such as at least one compaction and one handoff. Fifty steps is a convenient target for many business workflows, but the placement of probes after each checkpoint matters more than the total step count.
Does a larger context window solve constraint loss?
Not on its own. Research on long inputs found models use information in the middle of a long context less reliably than information at the start or end, and handoffs or summaries can drop a constraint regardless of window size.
Should constraints be stored outside the context?
Usually yes, in a notes file, a task record or a policy store the agent reloads, but the test still matters. Check that the stored copy is updated when an authorized person changes a rule, and that unauthorized changes are not written to it.
How is this different from measuring task horizon?
Task horizon measures how long a task an agent can complete at a given reliability. Constraint retention asks whether the agent still follows the early rules while it works, which can fail even on tasks it otherwise completes.
Sources
- Anthropic's context engineering guide describes context rot, where recall decreases as context grows, compaction that preserves decisions, unresolved bugs and implementation details, and structured note-taking outside the context window. Source
- Anthropic's agent evaluation guide notes model outputs vary between runs, defines pass^k as the probability that all k trials succeed, and advises reading transcripts. Source
- tau-bench's airline policy requires explicit user confirmation before database updates, caps reservations at five passengers, allows at most one travel certificate, and states the API does not check these rules for the agent. Source
- The OpenAI Agents SDK lets a receiving agent see prior history by default, lets input filters change it, provides a remove_all_tools filter, and offers opt-in nested handoff history that compacts earlier turns into summaries. Source
- LangGraph interrupts pause graph execution, save state through the persistence layer and wait for external input before resuming. Source
- LangGraph time travel replays or forks from a prior checkpoint; nodes after the checkpoint re-execute and may return different results. Source
- Lost in the Middle (TACL 2024) found language models use relevant information best at the start or end of long inputs and worse in the middle. Source
- METR measures the length of tasks, by how long they take human professionals, that frontier agents complete autonomously with 50% reliability. Source
Tell us what data you need
Share scope, volume, format, timing and licensing needs. Datasets are sourced on request.