Skip to content

[BUG] Excessive Context Compaction Causing Runaway Token Usage and Very Long Task Execution with Deepseek-v4-flash #1365

Description

@nicoadm-py

Problem (one or two sentences)

A relatively limited coding task, consisting of implementing an existing Markdown plan to optimize parts of the workflow, is taking over an hour and consuming tens of millions of tokens. The agent repeatedly performs operations and compacts its context instead of progressing efficiently toward completion.

Context (who is affected and when)

This happens while implementing an already-defined Markdown plan containing workflow optimization changes, rather than during an unusually large or open-ended task. The agent repeatedly reaches context compaction during the implementation, and this behavior has recently started occurring much more frequently.

Reproduction steps

  1. Create or provide an existing Markdown implementation plan containing a set of relatively limited workflow optimization changes.

  2. Ask the agent to implement the plan using deepseek-v4-flash.

  3. Let the agent work through the implementation normally.

  4. Observe the context usage as the agent performs file reads, edits, searches, and other coding operations.

  5. After some time, the agent starts compacting the context repeatedly while continuing the implementation.

  6. Observe that the cycle of operations followed by context compaction continues multiple times instead of the task reaching completion.

  7. Token usage and cost keep increasing significantly. In the observed run, the task ran for over an hour and exceeded 280 million cumulative tokens while still not completing.

Expected result

The agent should implement the changes described in an existing Markdown plan for optimizing parts of the workflow within a reasonable amount of time and token usage, with context compaction only when necessary.

Actual result

Despite the task being relatively limited in scope and already defined in a Markdown implementation plan, the agent has been running for over an hour. It repeatedly performs operations, fills and compacts the context, then continues rebuilding it, resulting in tens of millions of cumulative tokens and unusually high costs without completing the implementation.

Variations tried (optional)

No response

App Version

v3.80.0

API Provider (optional)

None

Model Used (optional)

deepseek-v4-flash via OpenCode Go

Zoo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions