Skip to content

Feature: Subagents should support auto compaction #3153

Closed as not planned
Closed as not planned

Description

Currently, if a subagent goes on a long task and goes over the models context limit, the whole subagent fails.

I think a good solution for this might be auto compaction for sub-agents. If a subagent goes over its context it should reject/remove items that are too big (the last tool/mcp call that sent it over context rejected?) and then auto compact in a way that allows it to continue. This makes subagents resilient and recoverable, because when they go on long tasks and fail it can cost a lot of tokens.

Appreciate all the hard work, opencode is great.

Activity

  1. github-actions commented on Oct 13, 2025

    @github-actions
    Contributor

    This issue might be a duplicate or closely related to existing issues. Please check:

    While your specific request for auto compaction in subagents is unique, these existing issues address related problems with subagent context management and compaction strategies. You might find useful insights or discussions there.

    Feel free to ignore if none of these address your specific case of automatic compaction for subagents hitting context limits.

  2. rekram1-node commented on Oct 14, 2025

    @rekram1-node
    Collaborator

    hmm I thought it would auto compact already will need to check

    The auto compact logic isn't fool proof though

  3. rekram1-node commented on Oct 14, 2025

    @rekram1-node
    Collaborator

    ofc and if you ever catch me not replying just @ me haha

    yeah that very well could be it, tool overloads context and it cant recover ftom it

  4. adpadillar commented on Feb 26, 2026

    @adpadillar

    i am pretty sure this exists (as of at least v1.2.14), i actually came here to open an issue caused by auto-compaction on subagents, but i think this means this can be closed since auto-compaction does work with subagents

  5. github-actions commented on Apr 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  6. yasirroni commented on Aug 1, 2026

    @yasirroni

    I'm using a hard-coded context-window limit for the new GPT-5.6. It seems that the subagents keep going.

    The setting:

      "provider": {
        "openai": {
          "models": {
            "gpt-5.6-terra": {
              "limit": {
                "context": 229376,
                "output": 16384
              }
            },
            "gpt-5.6-luna": {
              "limit": {
                "context": 229376,
                "output": 8192
              }
            }
          },
          "options": {
            "setCacheKey": true,
            "headerTimeout": 60000,
            "timeout": 600000,
            "chunkTimeout": 60000
          }
        }
      }
    

    The context window:

    Subagent(2 of 2)300.7K (131%)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions