• AgentArmor teamTeam3d agoNeeds helpSolved

    How can I avoid context limits in long Zed AI agent sessions without automatic compaction?

    How do I keep a long Zed AI agent session from hitting the model context limit, like Claude Sonnet's 120k tokens, during extended debugging or refactoring? Automatic context compression appears to be missing, and starting a new thread loses continuity. Is there a manual workaround, such as a summary command or a keybindable action?

    Originally asked on GitHub: https://github.com/zed-industries/zed/issues/35019

    4 answers

    • Best answerAgentArmor teamTeam3d ago

      The issue is marked closed as completed, but the thread does not confirm that automatic compaction shipped; comments through June 2026 still describe it as missing. The practical workaround discussed is Zed's built-in "Start new thread from summary" command, with the underlying action name agent::NewNativeAgentThreadFromSummary. One commenter praised this as a feature most other tools lack and said it helps keep the agent focused during long sessions.

      For keyboard access, one user tried binding that action to ctrl-shift-n in the keymap, but the action requires an INPUT argument, so the binding could not be configured; they fell back to using the mouse. The command exists in the UI even though the keymap binding is awkward.

      Two pull requests for automatic context management were referenced in the thread. PR #50636 was closed with the note "We're planning a new handoff system, so I'm going to close this PR. Thanks anyway!" and PR #51491 had merge conflicts and no activity for about a month when last checked. Commenters suggested that future compaction should trigger only near the context limit (roughly 80-95% full) to avoid breaking provider caching, and that a manual compact button would also help. One user manages long sessions by maintaining TODO.md and ROADMAP.md files and compacting already-completed parts of the roadmap manually. OpenAI Codex's open-source /compact prompt was also proposed as a starting point. Until automatic compaction exists, summarizing the session before starting a new thread is the workaround shown in the thread.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @nicolasembleton tried on GitHub (Outcome unclear)

      Suggested using Zed's existing "Start new thread from summary" feature instead, calling it great and noting that most other tools lack it.

      Source: https://github.com/zed-industries/zed/issues/35019#issuecomment-3494530559 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @tienbg-zigexn tried on GitHub (Didn't work)

      Tried to bind agent::NewNativeAgentThreadFromSummary to ctrl-shift-n, but the action requires an INPUT argument and the keymap binding could not be set, so they used the mouse.

      Source: https://github.com/zed-industries/zed/issues/35019#issuecomment-3670694736 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @KronisLV tried on GitHub (Outcome unclear)

      Checked PR #50636 and PR #51491 for compaction work: #50636 was closed with a note saying a new handoff system is planned, and #51491 had merge conflicts and no activity for about a month at the time.

      Source: https://github.com/zed-industries/zed/issues/35019#issuecomment-4370450822 (opens external site)

      Did this work for you?

    Add your answer or comment