Skip to content

Manual /compact with DeepSeek V4 Flash degenerates into thousands of repeated lines #41801

Closed

Description

@a-green-hand-jack

Description

A manual /compact request using opencode-go/deepseek-v4-flash entered an intra-response repetition loop. This differs from repeatedly triggering multiple Session compacted cycles: one compaction request itself generated a transcript-like prefix and then repeated the same short line 1,511 times.

The compaction never completed. I cancelled it after about 48 seconds, after which OpenCode recorded the message as Aborted. No HTTP, authentication, provider, or stream error was logged before cancellation.

Related, but not identical:

OpenCode version

1.18.16

Environment

  • Ubuntu Linux
  • TUI
  • Provider: opencode-go
  • Model: deepseek-v4-flash
  • Manual /compact, not automatic overflow compaction
  • No custom compaction agent or compaction prompt configured

Steps to reproduce

  1. Use opencode-go/deepseek-v4-flash in a long-running session containing normal assistant messages and tool calls.
  2. Wait for the active assistant turn to finish.
  3. Run /compact manually.
  4. Observe the compaction output.

Actual behavior

  • The compaction response began by reproducing part of the preceding transcript, including serialized assistant/tool-call text.
  • It then became stuck repeating one short line.
  • The persisted compaction text was 29,389 characters when cancelled.
  • The repeated line occurred 1,511 times in that single text part.
  • The final text was cut off mid-token because the request was cancelled.
  • OpenCode did not detect the high repetition or stop the compaction as failed.
  • The provider/model still completed a minimal normal text-generation request successfully after the incident.

Sanitized log sequence:

stream providerID=opencode-go modelID=deepseek-v4-flash agent=compaction
llm runtime selected ... provider=opencode-go model=deepseek-v4-flash
[about 48 seconds of streaming]
cancel session.id=<redacted>
process ... error=Aborted

Expected behavior

The compaction agent should produce a concise handoff summary. If its output becomes highly repetitive or fails to reduce the conversation meaningfully, OpenCode should stop the request, mark compaction as failed, and preserve the previous usable session state.

A repetition/degeneration guard on compaction output would prevent a model or provider backend from streaming thousands of duplicate lines and consuming usage indefinitely.

Additional context

This may involve an interaction between the DeepSeek model/backend and the compaction prompt, but OpenCode currently has no client-side guard for degeneration inside a single compaction response. This report intentionally omits the full session export because it contains private project content.

Activity

  1. joaomj commented on Aug 12, 2026

    @joaomj

    I am seeing the same general failure pattern, including internal-looking text leaking into the TUI and compaction not completing.

    My environment:

    • OpenCode 1.18.16
    • macOS 25.6.0 on arm64
    • Terminals: Ghostty 1.3.1 and the Zed integrated terminal
    • Session ID: ses_00a38fe1cffef3fdfqdS44708e
    • Models tested: Claude Sonnet and Haiku through AWS Bedrock and deepseek-v4-flash through OpenCode Zen Free.

    The issue appeared across both Ghostty and Zed, and across more than one provider, so it does not look specific to one terminal. When compaction triggered, the TUI started showing a large amount of internal/reasoning-like text and the compaction state did not finish. The session could remain stuck with the compaction indicator active.

    The example in my debug output showed text such as Thought: 16.5s, followed by internal planning text and tool-call payloads being displayed in the TUI. This looked similar to the behavior described in this issue, although my report also includes the compaction hang.

    I then retried compacting the same session using deepseek-v4-flash through the native DeepSeek API instead of OpenCode Zen, and that compaction completed successfully. This suggests there may be an interaction with the OpenCode/Zen route or with the compaction request format, rather than a terminal-only problem or a general inability of the session to compact.

    As a temporary mitigation, I am testing the compaction agent with reasoning disabled.

  2. joaomj commented on Aug 12, 2026

    @joaomj

    regarding (#41801 (comment)): its working with bedrock gpt oss.

        "compaction": {
          "model": "amazon-bedrock/openai.gpt-oss-120b-1:0",
          "reasoningEffort": "none" // see https://github.com/anomalyco/opencode/issues/41801
        },
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