Applied Intelligence
Module 2: The Agent Mental Model

Conversation as Collaboration

Session management; the feedback loop; when to provide context vs let agents explore

The interaction between developer and agent is not command-and-response it resembles collaboration between colleagues where both parties contribute to outcomes. Understanding this collaborative dynamic transforms how developers approach agent work.

Session lifecycle

Agent sessions have distinct phases that require different management strategies:

  • Initiation Establishes working context. Claude Code loads CLAUDE.md files automatically; Codex scans for AGENTS.md files.
  • Active conversation Builds shared understanding through turns. Each exchange adds to context: files read, commands executed, decisions made.
  • Degradation The "lost in the middle" effect reduces attention to mid-context information. Long sessions accumulate contradictory instructions.
  • Termination Intentional resets preserve momentum by capturing decisions. Forced termination risks losing ephemeral context.

Session commands

Resume the most recent conversation:

claude -c
claude --continue

Resume by session ID:

claude -r abc123
claude --resume abc123
claude --resume  # Interactive session picker

Managing context

CommandEffect
/clearWipes conversation history while maintaining the session
/compactSummarizes history and preloads it as new context
/rewindRestores previous states (or press Escape twice)

Manual compaction is preferable to waiting for automatic compaction choosing when to compress provides control over what survives.

The feedback loop

Agent interaction follows an iterative pattern: request → response → evaluation → feedback → refined response.

Effective corrections:

  • Include file path and location
  • Describe what is wrong AND what should happen
  • Provide context for why the change matters
  • Keep scope focused to one issue

Ineffective corrections:

  • "Fix the bugs" without specifying behaviors
  • "Make it better" without criteria
  • Multiple unrelated issues bundled together

Boris Cherny emphasizes: "Give Claude a way to verify its work. If Claude has that feedback loop, it will 2-3x the quality of the final result."

Context provision strategies

Upfront context accelerates initial responses but risks overwhelming the agent. Works well for stable project knowledge architecture patterns, coding conventions, key file locations.

Autonomous exploration lets the agent navigate using search and read tools. Suits discovery tasks where relevant files are not known in advance. Adds latency but produces targeted context.

Anthropic's guidance: "Most effective agents retrieve some data up front for speed, then pursue autonomous exploration at discretion." Neither extreme optimizes outcomes.

Strategy selection

ScenarioStrategy
Small, stable projectFront-load context via CLAUDE.md
Large monorepoLet agent explore with search tools
Unclear requirementsUse Plan mode for discovery first
Multi-file changesPre-load related files for better cross-referencing
Production systemsHybrid with light preload and just-in-time discovery

When to reset versus continue

Continue the session when:

  • Working on the same feature or related tasks
  • Building on established context and prior decisions
  • Maintaining momentum on multi-step work
  • The context contains accurate, relevant information

Start fresh when:

  • Completing a task and moving to unrelated work
  • Context window fills with outdated or irrelevant history
  • The agent starts "forgetting" instructions or reverting to corrected patterns
  • Debugging sessions have accumulated failed approaches
  • Context utilization exceeds roughly 80% of practical limits

The 80% guideline reflects empirical observation: performance degrades disproportionately as context windows fill.

Session transition technique

Before ending productive sessions, capture value:

  1. Ask the agent to summarize key decisions, implementation details, and open questions
  2. Copy the summary to a scratchpad file or directly into the new session
  3. Clear or exit the session
  4. Start fresh with the summary as initial context

A useful prompt for handoffs:

"Write a summary of our session including all decisions made, changes implemented, and open issues. Another engineer will pick this up."

Codex task management

Codex approaches sessions differently through its task-based model. Each task runs in an isolated sandbox preloaded with repository content. Tasks complete independently, producing reviewable results.

Task isolation means context does not accumulate across tasks. Each new task starts from repository state plus AGENTS.md context, without conversational history. This design trades continuity for consistency.

The philosophical difference: Claude Code treats sessions as extended collaborations; Codex treats tasks as discrete units of work. Long exploratory sessions favor Claude Code's model; batched independent tasks favor Codex's isolation.

On this page