Skip to content

[Bug]: "Message ID alias capacity exceeded" persists in v3.1.12 — regression of #452, session permanently unusable past 9999 messages #549

@ricardo-js-santos

Description

@ricardo-js-santos

[Bug]: "Message ID alias capacity exceeded" persists in v3.1.12 — regression of #452, session permanently unusable past 9999 messages

Bug Description

After ~10,000 messages in a single long-running opencode session, every new user message is rejected with the error originally reported in #452:

Message ID alias capacity exceeded. Cannot allocate more than m9999 aliases in this session.

Issue #452 was closed as COMPLETED on 2026-03-25 after the fix shipped in v3.0.5, but the same user (jiwangyihao) immediately commented that the issue still reproduces in v3.1.0 with a continuously-working session. There was no follow-up reply on that thread.

I'm now hitting it in DCP v3.1.12 with the same symptom. My affected session has exactly 10,028 messages in the message table at ~/.local/share/opencode/opencode.db (range 2026-05-01 → 2026-05-24, ~3 weeks of continuous work). The session itself is otherwise healthy on disk — the cap is enforced purely by the DCP plugin at chat-time.

Root cause (verified locally):

The alias allocator at node_modules/@tarquinen/opencode-dcp/dist/index.js lines 1833–1945 (in the bundled output) hard-codes:

MESSAGE_REF_WIDTH = 4
MESSAGE_REF_MIN_INDEX = 1
MESSAGE_REF_MAX_INDEX = 9999

allocateNextMessageRef() walks state.messageIds.byRef, and once 9999 aliases are taken it throws. There is no environment variable, config flag, or runtime knob to widen the range. The previous fix in v3.0.5 evidently did not address the underlying constraint — it likely only addressed alias re-use across compactions, not the hard 4-digit ceiling.

Impact: Once a session crosses 9,999 messages, it becomes permanently unwriteable as long as DCP is loaded. The only workaround is to disable the DCP plugin (opencode.json) and restart, at which point the session works fine again — confirming the underlying opencode session is intact and the constraint is purely in DCP.

Expected Behavior

Either:

  1. Widen the alias space to 5+ digits (e.g. MESSAGE_REF_WIDTH = 5m00001..m99999), or
  2. Make the width configurable in dcp.jsonc (e.g. messageRefs.maxIndex or messageRefs.width), or
  3. Recycle/garbage-collect aliases once their underlying message has been folded into a compressed block and is no longer referenced.

At minimum, the error should suggest the workaround (disable DCP for that session) rather than just throwing.

Debug Context Logs

Note: "debug": true was not previously enabled on this machine, so no logs were captured at the moment of failure. The bug, however, is deterministic and easily reproducible — any session that crosses 9,999 messages with DCP loaded will hit it. The constraint is in the source code, not in any conditional/race-condition path. I'm happy to attach logs from a reproducer session on request, but I'd rather not generate another 10k-message session just to capture them.

{
  "note": "Reproducer is deterministic: any DCP-enabled session that allocates a 10000th alias hits the cap. See referenced source location for the throw site."
}

Tool Call Details

The failure is not triggered by a specific tool call — it occurs on every subsequent user message after the alias pool is exhausted. The stack trace from #452 still applies (paths shifted slightly between versions):

at allocateNextMessageRef (.../node_modules/@tarquinen/opencode-dcp/dist/index.js [bundled])
at assignMessageRefs (...)
at <hook handler invoked at session load / per message>

DCP Version

3.1.12

Opencode Version

1.15.5 (also reproduces on 1.15.6 — same DB-backed session storage; the constraint is independent of opencode version)

Model

Other (specify in description)

I've reproduced with anthropic/claude-sonnet-4-6 (Sonnet 4.6, 1M context) and anthropic/claude-opus-4-7 (Opus 4.7, 1M context). The model is irrelevant — the throw happens in the DCP plugin's pre-chat hook before any model is invoked.

Additional Context

  • This is a regression of / follow-up to [Bug]: "Message ID alias capacity exceeded. Cannot allocate more than m9999 aliases in this session" when using with a long-term running session #452, which was closed as completed but the in-thread comment from @jiwangyihao reporting recurrence in v3.1.0 went unanswered.
  • My session pattern is "one long maintenance session per project that runs for weeks" — exactly the scenario v3.0.5 was meant to fix.
  • Affected session has 10,028 messages over 23 days (~436 messages/day average; not unusually high for an ultrawork-mode workflow).
  • dcp.jsonc config used:
    {
      "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
      "compress": { "protectUserMessages": true },
      "turnProtection": { "enabled": true }
    }
  • Proposed minimum fix: bump MESSAGE_REF_WIDTH to 5 (m00001..m99999) — gives 10× headroom with one-character TUI cost; no schema change required.
  • Proposed proper fix: make the width configurable in the schema, default it to 5, log a one-line warning at startup when a session crosses 50% of the configured ceiling.

Thanks for the great plugin — it's been very useful right up until the wall.

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