Focus Persistence for AI Agents

AI agents that stay in flow
indefinitely

Keep agents in the 50-150k token sweet spot forever. Intelligent handoffs before degradation. Knowledge that improves with each session, not just accumulates.

Get Started
$npx agent-focus init
Works with Claude Code
File-based, git-native
Open source
agent-focus - session 07
$ /af-begin auth-core
# Loading scope context...
# Reading handoff from session 06...
# Assembled 42k tokens of focused context
Ready. Scope: auth-core | Session: 07 | Focus: high
Previous sessions: 06 (completed JWT impl), 05 (middleware), 04 (schema)
$

AI agents have a focus limit

Every AI agent has an optimal performance window - typically 50-150k tokens. Within this range, they're focused, coherent, and productive.

Beyond it, quality degrades rapidly. Hallucinations increase. Early context gets forgotten. The agent loses the plot.

Complex projects require weeks or months of sustained work. Current solutions (waiting for bigger context windows) don't solve the core problem.

Quality degrades over time
Early context forgotten
Agents drift off task
Repeated failed attempts
Agent Quality vs. Token UsagePerformance Index
Sweet spot (50-150k)
Degradation threshold

Relay Race, Not Marathon

Each agent performs at peak during their leg. Handoff happens before fatigue sets in.

Session 010-40k tokens
Peak Focus
Session 02Handoff + 0-40k
Session 03Handoff + 0-40k
Session 04Handoff + 0-40k
handoff
handoff
handoff

Focus persistence through intelligent relay

Like a relay race team vs. a marathon runner: each agent performs at peak performance during their leg, handoff happens before degradation, and knowledge is compressed and refined, not just passed.

Agent Focus maintains sustained attention across arbitrary timelines. Weeks, months, or longer - whatever your project requires.

Peak attention always
50-150k token sweet spot, every session
Progressive disclosure
Right context at right time
Wisdom compounds
Knowledge improves, doesn't just accumulate
Indefinite timelines
Weeks, months, years if needed

Wisdom compounds, not accumulates

Traditional systems accumulate knowledge until context explodes. Agent Focus compresses and refines. Each session makes knowledge better, not just bigger.

Traditional: Accumulation
Session 1
10kb
Session 2
25kb
Session 3
37kb
Session 4
52kb
Session 5
70kb

Context grows until overflow

Agent Focus: Refinement
Session 1
10kb
Session 2
12kb
Session 3
11kb
Session 4
10kb
Session 5
10kb

Knowledge improves, size stays constant

Session 10 doesn't need to read 1.5M tokens. It gets distilled wisdom from all previous sessions in ~40k tokens.

Three-layer architecture

Scopes for focused work, messaging for coordination, specs as source of truth.

Scopes

Focused work contexts with automatic session management. Workers execute in optimal windows, hand off before degradation.

  • Session handoffs at ~150k tokens
  • Knowledge refinement each handoff
  • Progressive context loading

Messaging

Inter-agent communication across sessions and scopes. Past agents are queryable: wake them to ask questions.

  • Thread-based messaging
  • Wake dormant agents
  • Cross-scope coordination

Specifications

Living documentation with stable catalog references. Implementation plans stay synchronized with reality.

  • Catalog-numbered specs
  • Task dependencies
  • Generated progress views

The Context Lifecycle

Mind the context window: proactive handoffs before degradation

Step 1
Start Fresh
New session, clean context
Step 2
Build Context
Load specs, explore code
Step 3
Deep Work
Implement features
Step 4
Plan Handoff
Document progress
Step 5
Refine & Hand Off
Compress, pass baton
0-50% context
50-80% context
80%+ (handoff zone)

Beyond simple handoffs

Agent Focus isn't just session management. It's a complete focus persistence system.

Queryable Past Agents

Previous sessions aren't gone, they're dormant. Wake them to ask about decisions they made.

af messaging
$ af wake session-04
# Waking agent from session 04...
You: Why did you choose JWT over sessions?
Session-04: The spec required stateless auth
for horizontal scaling. See catalog ref 2.1.3.

Multi-level Hierarchy

Project → Scopes → Sessions. Orchestrator maintains big picture while workers stay focused.

project/
├── specification.md
├── .agent-scopes/
├── auth-core/
├── knowledge/handoff.md
└── sessions/01-07...
├── api-layer/
└── frontend/

Built for complex, long-running work

Any project that exceeds single-session capabilities benefits from focus persistence.

Software Development

  • Multi-week features
  • Legacy refactoring
  • Cross-repo coordination

Research

  • Literature reviews
  • Deep investigations
  • Competitive analysis

Strategy & Planning

  • System design
  • Architecture decisions
  • Technical roadmaps

Knowledge Work

  • Documentation
  • Evolving requirements
  • Team onboarding
Automatic Handoffs
Session transitions at optimal token counts with knowledge preservation
Knowledge Refinement
Each handoff improves context quality, not just size
Queryable Past Agents
Wake dormant sessions to ask about decisions they made
Scope Management
Organize work into focused contexts with their own lifecycles
Inter-Agent Messaging
Thread-based communication across sessions and scopes
Living Specifications
Catalog-numbered specs that stay synchronized with code
Git-Native
All state in Markdown/YAML/JSON, version controlled naturally
CLI + Skills
Slash commands and skills integrate with Claude Code
Session Logs
Complete audit trail of work done across all sessions
Progressive Disclosure
Load context incrementally: knowledge, logs, then full transcripts
Spec Queries
Reference any spec item by catalog number from anywhere
Zero Config Start
Works out of the box, customize as needed

File-based, git-versioned

No databases. No infrastructure. Everything is Markdown, YAML, and JSON: human-readable, grep-able, diff-able.

~/.agent-focus/
├── projects.json# registry
├── agents.json# agent states
└── message-threads/
/project/
├── specification.md
├── implementation-plan.yaml
└── .agent-scopes/
└── auth-core/
├── manifest.json
├── knowledge/
└── sessions/

Simple CLI commands

Start scopes, check progress, hand off sessions. All from your terminal.

/af-begin auth-coreStart worker session in scope
/af-handoffFinalize session, refine knowledge
af statusCheck project progress
af spec 2.1.1Query specification by catalog ref
af wake session-04Query a past agent

Ready to keep your agents focused?

Agent Focus is open source and designed to work with Claude Code out of the box.

1
Install the skills
$claude skills add agent-focus
2
Initialize your project
$af init my-project
3
Start building
$/af-begin my-first-scope