Skip to content

perf: context window protection — reduce overhead and add agent guardrails#3

Merged
psklarkins merged 8 commits intomainfrom
feature/context-window-protection
Feb 14, 2026
Merged

perf: context window protection — reduce overhead and add agent guardrails#3
psklarkins merged 8 commits intomainfrom
feature/context-window-protection

Conversation

@psklarkins
Copy link
Owner

Summary

  • Remove 4 design philosophy @imports from always-loaded context (~14,000 tokens saved)
  • Deduplicate AGENTS.md by referencing already-loaded philosophy files (~2,000 tokens saved)
  • Archive 3 stale DISCOVERIES entries (~1,000 tokens saved)
  • Add universal context budget guardrails to all 30 agents (max 15 file reads, 300 line output)
  • Add specific limits to 7 high-risk agents (content-researcher, analysis-engine, bug-hunter, security-guardian, post-task-cleanup, amplifier-cli-architect, modular-builder)
  • Add Required Context to 7 design agents for on-demand philosophy file loading

Impact: Active @import chain reduced from ~21,200 words to 6,933 words (68% reduction). All agents now have context budget guardrails.

Test plan

  • Verified word count: 6,933 words (target ≤9,000)
  • Verified 30/30 agents have Context Budget
  • Verified 7/7 high-risk agents have specific limits
  • Verified 7/7 design agents have Required Context
  • Verified no broken markdown across all files

🤖 Generated with Claude Code

psklarkins and others added 8 commits February 13, 2026 22:19
Design to reduce main context consumption from 70-103k tokens (35-52%)
to 25-40k tokens (13-20%) before implementation starts.

Three priority tiers:
- P1: Remove always-loaded design @imports, deduplicate AGENTS.md (~17k saved)
- P2: Delegate brainstorming context gathering, writing-plans, and spec
  writing to subagents instead of running in main context (~18-45k saved)
- P3: Add context budget guardrails to all 30 agent definitions, with
  specific limits for 7 high-risk agents

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
12 tasks across 2 repos (amplifier + superpowers), 3 priority tiers:
- P1 (Tasks 1-3): Remove design @imports, deduplicate AGENTS.md, archive DISCOVERIES
- P2 (Tasks 4-7): Context scout subagent, delegate spec/plan writing, output discipline
- P3 (Tasks 8-10): Universal context budget for 30 agents, specific limits for 7 high-risk
- Verification (Tasks 11-12): Token savings, skill changes, agent guardrails, cleanup

Also aligned spec subagent_type references with 449100e pattern (general-purpose).

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Design files (DESIGN-PHILOSOPHY, DESIGN-PRINCIPLES, DESIGN-FRAMEWORK,
DESIGN-VISION) are now loaded on demand by design agents only.
Saves ~14,000 tokens per session for non-design tasks.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Implementation Philosophy and Modular Design Philosophy sections were
duplicated from ai_context/ files already loaded via CLAUDE.md @imports.
Replaced with references. Saves ~2,000 tokens per session.

Reduced file from 757 to 424 lines. All other sections preserved:
- Git commit message guidelines
- Sub-agent strategy
- Incremental processing pattern
- Partial failure handling
- Decision tracking system
- Configuration management
- Response authenticity guidelines
- Zero-BS principle
- Build/test/lint commands
- Code style and formatting
- Dev environment tips
- Testing instructions
- Documentation guidelines

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Moved DevContainer Setup, pnpm Global Bin, and OneDrive/Cloud Sync
entries to DISCOVERIES-archive.md. Kept Tool Generation Patterns and
LLM Response Handling (still actively relevant). Saves ~1,000 tokens.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Every agent now has file read limits (max 15), output size targets
(max 300 lines), stop conditions (10 reads without progress), and
no-replan instructions. Prevents agent context window exhaustion.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
content-researcher: max 20 scan, 5 deep-read
analysis-engine: mode-specific caps (30/3/5)
bug-hunter: 10 reads before hypothesis, 3 cycles max
security-guardian: require explicit scope, no unbounded scans
post-task-cleanup: summary review for >15 file changesets
amplifier-cli-architect: lazy-load references
modular-builder: return paths+summaries for large files

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
…loading

Design agents now read DESIGN-PHILOSOPHY, DESIGN-PRINCIPLES,
DESIGN-FRAMEWORK, and DESIGN-VISION on demand. These files were
removed from the always-loaded @import chain in Task 1 to save
~14,000 tokens per non-design session.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@psklarkins psklarkins merged commit ca0e706 into main Feb 14, 2026
@psklarkins psklarkins deleted the feature/context-window-protection branch February 15, 2026 17:24
psklarkins pushed a commit that referenced this pull request Feb 24, 2026
…subagents' (#3) from feature/readonly-research-agents into main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant