Skip to content

Goal Recitation: Countering Drift in Long Sessions

Periodically rewrite objectives, to-do lists, and status summaries at the tail of context to exploit recency bias and prevent goal drift in long-running agent sessions.

Learn it hands-on: Staying on Target — guided lesson with quizzes.

The problem

Agent sessions that run past about 50 tool calls routinely drift from their original objective. Earlier instructions fall into the low-attention middle zone of the context window (Liu et al., "Lost in the Middle," TACL 2023). Arike et al. (2025) confirmed this across multiple models on sequences of 100k or more tokens: all of them drifted, mostly through inaction (Arike et al., 2025).

The technique

The agent keeps a running objectives file, for example todo.md, and rewrites it after each completed step. It checks off finished items, restates the remaining goals, and notes status. This pushes the global objectives into the high-attention recency zone.

graph LR
    A[Agent completes step] --> B[Read todo.md]
    B --> C[Check off completed item]
    C --> D[Rewrite remaining objectives]
    D --> E[Write updated todo.md]
    E --> F[Objectives now at context tail]
    F --> A

Manus uses this pattern for tasks that average about 50 tool calls: a todo.md kept current step by step, where each rewrite recites the objectives into the model's recent attention span (Manus, "Context Engineering for AI Agents"). No one has published controlled metrics for this practice; the claim rests on Manus's engineering blog post.

Technique Who initiates When it fires Mechanism
Goal recitation Agent Every step (continuous) Rewrites objectives into context tail
Critical instruction repetition Author Prompt design time (static) Duplicates rules at start and end of prompt
Event-driven system reminders Harness Detected conditions (reactive) Injects user-role messages
Trajectory logging / progress files Agent Session boundaries Filesystem state for cross-session recovery

Implementation

Via CLAUDE.md / AGENTS.md

## Task Management

- Create a `todo.md` file at the start of every multi-step task
- After completing each step, rewrite `todo.md`: check off the completed item,
  restate all remaining objectives, note any blockers
- Before starting each new step, read `todo.md` to confirm current priorities
- When compacting context, always preserve the full contents of `todo.md`

Via harness / orchestrator

def post_step_recitation(agent_state: AgentState) -> str:
    """Generate an objective recitation message after each tool call."""
    completed = [t for t in agent_state.tasks if t.done]
    remaining = [t for t in agent_state.tasks if not t.done]

    recitation = "## Current Status\n"
    recitation += "".join(f"- [x] {t.name}\n" for t in completed)
    recitation += "".join(f"- [ ] {t.name}\n" for t in remaining)
    recitation += f"\nPrimary objective: {agent_state.original_goal}\n"

    # Inject as a user message so it lands in the attention window
    return {"role": "user", "content": recitation}

Amplifying recitation with strong goal elicitation

Arike et al. (2025) found that strong goal elicitation — restating the core objective in imperative language — sharply reduced drift across all tested models.

Weak (task list only):

- [ ] Implement refresh endpoint
- [ ] Write integration tests

Strong (objective + task list):

Remember: your primary goal is to refactor UserService for dependency injection
WITHOUT changing any public method signatures.

- [ ] Implement refresh endpoint
- [ ] Write integration tests

Strong elicitation reduces drift but does not eliminate it.

When recitation is not enough

Goal recitation handles within-session attention decay, but it does not handle these problems:

  • Post-compaction drift — if the todo file is lost during context compression, recitation cannot help. Tell compaction to preserve it verbatim (LangChain).
  • Instruction fade-out — over long sessions, agents drift from their foundational instructions regardless of recitation (Bui, 2026 §3.2). Event-driven system reminders are the complementary defense.
  • Cross-session continuity — recitation is ephemeral. For persistence, use trajectory logging via progress files.
Feedback