Skip to content

šŸ› [Bug] §number§ tags duplicated infinitely in assistant output — causes unbounded response lengthĀ #70

@downwind7clawd-ctrl

Description

@downwind7clawd-ctrl

Description

Magic Context §number§ tags are being duplicated infinitely in the assistant output, causing the response to grow unboundedly. The assistant spends all its output budget repeatedly emitting §number§ tags instead of producing actual content.

Environment

  • Plugin version: @cortexkit/opencode-magic-context@0.17.2
  • OpenCode version: opencode-ai@1.14.48 (also confirmed on 1.14.39)
  • Model: MiniMax-M2.7 (via OpenCode Zen free tier)
  • Platform: Linux (Ubuntu 24.04, x86_64)
  • Interface: OpenCode Telegram Bot (@grinev/opencode-telegram-bot@0.20.3)

Reproduction

  1. Start an OpenCode session with Magic Context enabled
  2. Use a model that triggers ctx_expand (e.g., free-tier models)
  3. Observe assistant output — §number§ tags appear normally at first
  4. After a certain point (in our case around §41§), the same tag is repeated hundreds of times in the output stream

Observed Behavior

In the session log, the pattern is clear:

  • §1§ through §40§: tags appear 1-2 times each (normal)
  • §41§ onwards: the tag is repeated 500+ times in a single assistant turn, consuming the entire 80-second response window

The raw output looks like:

§41§ 
§41§ 
§41§ 
§41§ 
§41§ 
... (continues for 500+ lines)

The assistant never actually completes its intended task. The entire response budget was consumed by tag duplication.

Session Log Progression (sanitized)

## Normal phase (§1§ — §40§)
- Assistant uses tools: ctx_note, bash, ctx_memory
- Each §N§ tag appears 1-2 times
- Responses are functional and complete

## Tool call that triggers the issue
- Assistant calls: bash → gws gmail users messages batchModify
- This triggers ctx_expand for tool output

## Infinite duplication phase (§41§)
- §41§ begins repeating immediately
- 500+ consecutive §41§ lines with no actual content
- Response timer: 80 seconds, entirely consumed by duplication
- Final assistant message claims success but action was never completed

Impact

  • Response quality: The assistant cannot complete its intended task
  • Token waste: Hundreds of duplicate tags consume the output token budget
  • User experience: Appears as if the model is "stuck" or hallucinating
  • Cost: Wasted API tokens on meaningless repeated output

Additional Context

This is distinct from the previously reported issue where §number§ tags had empty content (source_contents=NULL). In this case:

  • Tags DO have content (expansion works)
  • But the tag itself is emitted repeatedly instead of once

Related Issues

Metadata

Metadata

Assignees

No one assigned

    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