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
- Start an OpenCode session with Magic Context enabled
- Use a model that triggers
ctx_expand (e.g., free-tier models)
- Observe assistant output ā
§number§ tags appear normally at first
- 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
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
@cortexkit/opencode-magic-context@0.17.2opencode-ai@1.14.48(also confirmed on1.14.39)@grinev/opencode-telegram-bot@0.20.3)Reproduction
ctx_expand(e.g., free-tier models)§number§tags appear normally at firstObserved Behavior
In the session log, the pattern is clear:
The raw output looks like:
The assistant never actually completes its intended task. The entire response budget was consumed by tag duplication.
Session Log Progression (sanitized)
Impact
Additional Context
This is distinct from the previously reported issue where
§number§tags had empty content (source_contents=NULL). In this case:Related Issues
§number§empty content issue (tags withsource_contents=NULL)Agent not found: "historian"on OpenCode 1.14.41Ā #62 ā Agent registration issues on newer OpenCode versions