anomalyco / anomalyco/opencode

[Bug]: DeepSeek-V4-Flash-0731 consumed ~22M tokens in prolonged agent loop and failed to complete an Excel engineering task

Open
#47,253 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 4, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Description

I used OpenCode Desktop 1.18.25 with DeepSeek-V4-Flash-0731 for a bounded engineering task: creating and validating a production-oriented ICU Antibiotic Stewardship Excel workbook.

The task required generating an XLSX workbook with multiple relational sheets, formulas, validation rules, conditional formatting, dashboards/worklists, demo data, and automated validation/testing.

The model initially generated a substantial workbook and performed multiple iterations of testing and debugging. However, the session became extremely long and consumed 21,955,093 tokens according to the token provider's usage dashboard.

Despite extensive iterative debugging, the requested final workbook was not successfully delivered.

Environment

  • OpenCode Desktop: 1.18.25
  • OS: Windows 11
  • Model: DeepSeek-V4-Flash-0731
  • Project: workbook-icu-excel

Observed behavior

The model repeatedly entered long generate → test → diagnose → modify → retest cycles.

During debugging, the following was established:

  1. The generated XLSX was a valid ZIP/OOXML package and could be read by openpyxl.

  2. Excel COM validation initially failed to open the workbook.

  3. A bisect process isolated one failure to Data Validation in the Antibiotic Therapy sheet.

  4. The model replaced cross-sheet Data Validation references with workbook-level Named Ranges.

  5. The targeted Data Validation test then passed.

  6. Full workbook validation still failed.

  7. A further bisect showed that the first 10 data sheets opened successfully in Excel COM.

  8. The remaining failure was narrowed to one of:

    • Alerts-Flags
    • Dashboard
    • Worklist
    • Instructions
  9. The session was stopped before the remaining failure was isolated and the final workbook was delivered.

Impact

The task was bounded and had a clearly defined deliverable, but the agent consumed:

21,955,093 tokens (~21.96M)

without reaching a completed final artifact.

This is particularly concerning because the model demonstrated meaningful debugging progress, including successfully isolating and fixing one Excel compatibility problem, but continued execution did not converge to a completed result.

Related OpenCode reports

This appears potentially related to existing DeepSeek-V4-Flash issues involving repetition, looping, or excessive token consumption:

  • #43146 — DeepSeek V4 Flash enters an endless reply loop.
  • #43661 — DeepSeek V4 Flash repeatedly generates code and consumes tokens.
  • #41801 — DeepSeek V4 Flash enters a severe repetition loop during compaction.

The current report differs in that the failure occurred during a substantial multi-step engineering task involving tool calls, file generation, Excel validation, and iterative debugging.

Evidence

OpenCode shared session:

https://opncd.ai/share/aHlGUPVV

The complete OpenCode session was also exported as JSON.

Token usage:

21,955,093 tokens

according to the token provider's usage dashboard.

Expected behavior

For a bounded engineering task, the agent should either:

  1. complete the requested artifact and validate it successfully, or
  2. detect that progress is no longer converging and stop with a clear failure state.

It should not consume tens of millions of tokens through prolonged iterative execution without completing the task.

Request

Please investigate whether this behavior is related to the known DeepSeek-V4-Flash repetition/looping issues in OpenCode, particularly when the model is performing long-running tool-assisted engineering tasks.

I would also like to know whether OpenCode has any safeguards for detecting non-convergent agent behavior, excessive repeated tool execution, or unusually high token consumption.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.