Skip to content

[Feature] Auto-tune or warn on session.parentForkMaxTokens instead of silent skip #63141

@Hugo0

Description

@Hugo0

Problem

session.parentForkMaxTokens defaults to 100000. When a parent session exceeds this, session-init silently skips the fork with a WARN-level log line:

[session-init] skipping parent fork (parent too large):
  parentKey=agent:main:discord:channel:1234
  → sessionKey=agent:main:discord:channel:5678
  parentTokens=154551
  maxTokens=100000

The child session starts with no context from the parent. For a Discord channel used as the agent's "home" channel, this manifests as the agent suddenly forgetting recent conversations at seemingly random intervals.

Observed in production

Today on 2026.4.8: our #chat parent session grew to 154,551 tokens vs the 100k cap. 4 child threads opened over a morning all started cold. Users experienced the agent as "amnesiac" — forgetting things it was told 30 min ago.

Current workaround

Raised session.parentForkMaxTokens to 200000. Opus has ~1M context so 200k is still conservative, but this is a manual tuning exercise per deployment. When the session grows past 200k we'll hit the same silent fork skip again.

Proposed solutions (pick one or more)

  1. Auto-compact the parent before forking — if parentTokens > maxTokens, trigger a compaction pass on the parent session before forking, instead of silently skipping. This feels like the right default given the new pluggable compaction provider (feat: add pluggable compaction provider registry #56224) and memoryFlush (2026.4.7).

  2. Promote the WARN to a visible signal — post a one-time message to the originating channel ("⚠️ context window full, starting fresh — previous conversations not carried over") so users understand why the agent forgot things. Currently only logged.

  3. Auto-scale the default — default maxTokens to e.g. min(500_000, modelContextWindow × 0.25) instead of the static 100_000. For Opus/Sonnet/GPT-5 the 100k default is now extremely conservative.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions