TL;DR

Give an agent a bounded task and explicit completion checks, then budget the entire run rather than one response. Limit repeated attempts and oversized tool output while retaining the evidence needed to recover from failure. Reserve enough capacity to test the final result. Repeating the same unsuccessful action should trigger a change of approach or a clear stop, not another open-ended loop.

01 / Agent task scope: define a bounded outcome

Fixing a particular failing test is easier to evaluate than optimizing an entire project. Specify the permitted scope and a concrete definition of success before starting the agent.

02 / Agent token budgets: plan context and tool usage

Set appropriate limits for retries, tool output, and total usage. Keep error details and supporting evidence. Summarize or paginate long outputs instead of repeatedly including the full result.

03 / Agent retry limits: detect repeated failures

Identical tool calls, repeated failed commands, and rewrites without new evidence suggest a stalled loop. Inspect recent actions and change the approach before continuing.

04 / Agent verification: reserve budget for tests

The task is not finished when an edit is generated. Keep enough budget to run relevant checks, review the change, and report what remains unverified.

Sources and further reading

DS-V4-HUUB · DeepSeek OpenCode Setup & Model Selection ↗api-docs.deepseek.com · Official documentation ↗api-docs.deepseek.com · Official documentation ↗

Adapted from the source guide, last updated 2026-06-17. Savings depend on your workload and must be measured.