Repository navigation
Description
Description
A stop on limit_reached ends a run that is making progress, and a person finishes the work. A measurement of 14 days (2026-10-27 to 2026-11-10, repository devops-cli) shows it.
- 20 stops had the class
limit_reached, from 20 items. This is 13% of the 158 stops with a class. - 16 of the 20 items ended in a merged pull request on the branch of the run. A person added the last commits. 6 of them had a
wip:commit with all tasks of the group done (feat(roadmap): Add a test-first manifest kind to the stage plan #3251, feat(roadmap): map all issue requirements to a group #3253, fix(roadmap): the implement job checks the test form that a task names #3451, fix(roadmap): the plan check refuses two tasks that state the same work #3456, fix(roadmap): update pull request metadata when archiving a change #3991, fix(roadmap): runner agent sleeps in polling loop during test #4079), so only the final verification was left. - feat(roadmap): allow-list builder for planner read-only commands #4004 stopped at 8,011,119 input tokens. After the comment
implement: retry, the group finished with 292,903 more input tokens (3.7% of the limit). - In the last 20 tool calls before the stop, all 16 items had at least one successful edit and at most 3 refused commands. In the last 20 calls at 80% of the limit, 6 of 13 stops of another class (
refused_tool,lint,ci_infra,plan_defect) above 6.4 million tokens had 4 or more refused commands, and none of the 16 had.
Proposal
Replace the hard stop at step_token_budget by a check at the limit that uses counts only: extend the budget one time by a share of the limit when the last N tool calls hold a successful edit and fewer than M refused commands. Keep the old limit as the fallback and add an absolute ceiling that only a person can change. The values N, M and the share come from the 14 days of data. No model is needed: a rule with the numbers above makes no false stop on the 16 items.
Alternatives considered
A Jev decision step (ADR 0019) adds nothing measurable on this data: 33 labelled checkpoints from 28 items, 16 positives, and the deterministic rule has no error on them.
Open tool check
No open tool covers a budget that extends on progress. The cost to build is a small function and one setting.
Proposed design
Problem statement
The implement job stops a step at roadmap.implement.step_token_budget with class limit_reached even when the step makes progress. In 14 days, 16 of 20 such items reached a merged pull request only after a person added commits, and 6 of them had only the final verification left. The change adds a one-time extension, with measured defaults and settings, when the last tool calls show a successful edit and few refused commands. The old limit remains the fallback, and a ceiling and the item budget bound the extension.
Acceptance criteria
Requirement: One-time budget extension
The implement step SHALL extend roadmap.implement.step_token_budget one time by roadmap.implement.step_token_extension_percent (default 10) percent of the limit when the last roadmap.implement.step_token_progress_calls (default 20) tool calls hold at least one successful edit and fewer than roadmap.implement.step_token_max_refusals (default 4) refused commands.
Scenario: Progress at the step limit
- WHEN a step reaches its token budget and its last 20 tool calls hold 1 successful edit and 3 refused commands
- THEN the step continues with a budget of 110% of the limit and records the extension
Requirement: No extension without progress
The implement step SHALL stop with class limit_reached when the last roadmap.implement.step_token_progress_calls tool calls hold no successful edit or at least roadmap.implement.step_token_max_refusals refused commands.
Scenario: No progress at the step limit
- WHEN a step reaches its token budget and its last 20 tool calls hold 0 successful edits or 4 refused commands
- THEN the step stops with class
limit_reachedand namesroadmap.implement.step_token_budget
Requirement: Single extension
The implement step SHALL extend the step budget at most one time for each step.
Scenario: Second limit
- WHEN an extended step reaches its extended budget again
- THEN the step stops with class
limit_reachedand makes no second extension
Requirement: Ceiling
The implement step SHALL NOT extend a step budget above roadmap.implement.step_token_ceiling.
Scenario: Ceiling blocks the extension
- WHEN the extension would make the step budget exceed the ceiling
- THEN the step budget is cut to the ceiling, and the step stops at it with class
limit_reachedand names the ceiling
Requirement: Ceiling default
The setting roadmap.implement.step_token_ceiling SHALL default to 2 times roadmap.implement.step_token_budget and SHALL NOT be below the step budget.
Scenario: No ceiling is configured
- WHEN the operator sets no ceiling
- THEN the ceiling is 2 times the step budget
Requirement: Progress setting defaults
The settings roadmap.implement.step_token_progress_calls, step_token_max_refusals and step_token_extension_percent SHALL default to 20, 4 and 10.
Scenario: No progress settings are configured
- WHEN the operator sets none of the three settings
- THEN the window is 20 tool calls, the refusal threshold is 4 and the extension share is 10 percent
Requirement: Progress setting validation
The configuration SHALL refuse a progress window below 1, a refusal threshold below 0, an extension share below 1 or above 100, and a ceiling below roadmap.implement.step_token_budget.
Scenario: An invalid progress setting
- WHEN the configuration sets
step_token_extension_percentto 0 - THEN the configuration refuses it and names the setting
Requirement: Item budget remains binding
The implement step MUST NOT start a request that makes the run exceed roadmap.implement.item_token_budget.
Scenario: Item budget spent
- WHEN a step extension would make the run exceed the item budget
- THEN the item stops with class
limit_reachedand namesroadmap.implement.item_token_budget
Requirement: Time limit remains a hard stop
The implement step SHALL stop with class limit_reached when it reaches roadmap.implement.step_time_limit_seconds, with no extension.
Scenario: Step time limit
- WHEN a step reaches its time limit
- THEN the step stops with class
limit_reachedand namesroadmap.implement.step_time_limit_seconds
Requirement: Extension record
The implement job SHALL record the successful edits, the refused commands and the new budget in the job record when it extends a step budget.
Scenario: Extension is recorded
- WHEN a step extends its budget
- THEN the job record holds the counts and the new budget, and the comment of the job shows them
Existing Tool Considered
pydantic-ai's UsageLimits is the open, maintained library that the project already uses for a run's budget (openspec/changes/archive/2026-10-29-2664-roadmap-implement-step/proposal.md:53). It lacks a progress rule: it stops hard at a limit and raises an error that holds a message and no field, so a stop cannot name its setting (src/devops_cli/roadmap/implement/implement_limits.py:11). No open, maintained tool extends a token budget on progress; the closest project record, the deadline extension, builds its own rule on the Kubernetes patch API (openspec/changes/archive/2026-11-02-3063-long-running-tasks-progress-based-deadlines/proposal.md:57). The change builds a small pure function and four settings on the existing StepBudget and ToolCallLog. Written cost: about 30,000 input tokens and 6,000 output tokens to build, about 3 hours of one engineer, and about 10,000 tokens per month to keep and fix the tests and the defaults.
Key questions
- Where does the implement job compare a step's input tokens with
roadmap.implement.step_token_budget?: InStepBudget.spent(), whichlimit_hookscalls before each model request. A step that has spent the budget stops with classlimit_reached, and the reason namesroadmap.implement.step_token_budgetand its value. [sources: src/devops_cli/roadmap/implement/implement_limits.py:84, src/devops_cli/roadmap/implement/implement_limits.py:106, docs/ENV_VARS.md:127] - What is the item token budget, and does it still bind a step extension?:
roadmap.implement.item_token_budgetis the most input tokens that all steps of one run of an item may use, the fix steps included.StepBudgetchecks the item's spend plus the step's spend before each request, so a step extension cannot make the run pass it; a step that starts after it is spent makes no request and the item stops with classlimit_reached. [sources: docs/ENV_VARS.md:119, src/devops_cli/roadmap/implement/implement_limits.py:63] - What is the action for the failure class
limit_reached?:raise_limit. The reason names the setting and its value. [sources: docs/ROADMAP_WORKFLOW.md:196] - What evidence decides that a step makes progress?: The last
roadmap.implement.step_token_progress_callstool calls in the step's tool-call log: a successful edit is awrite_fileoredit_filecall with outcomeok, and a refused command is ashellcall with outcomerefused. The step extends when the window holds at least one successful edit and fewer thanroadmap.implement.step_token_max_refusalsrefused commands. The rule reads counts that the tool log already records and uses no model. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py:99, src/devops_cli/roadmap/implement/implement_tool_log.py:350, src/devops_cli/roadmap/implement/implement_tool_log.py:432, src/devops_cli/roadmap/implement/implement_trace.py:119, docs/ROADMAP_WORKFLOW.md:266, AGENTS.md:21, src/devops_cli/roadmap/implement/implement_deadline.py:7]- Chosen: Counts of successful edits and refused commands. The 16 measured items had at least one successful edit and at most 3 refused commands; the tool log already records both outcomes for every call.
- Rejected: Model decision step (Jev). ADR 0019 makes a Jev answer evidence and never the only control; the body reports 33 labelled checkpoints and the deterministic rule has no error on them. AGENTS.md rule 13 asks for a deterministic check first.
- Rejected: Changed log line (the deadline rule). The deadline rule counts any changed log line as progress, and a refused command changes the log, so it would extend a step that only refuses calls.
- Rejected: Token burn rate. A token rate does not tell an edit from a refusal.
- Which values of N, M and the extension share does the rule use?: The defaults are N=20 tool calls, M=4 refused commands and a 10% share of the step limit. They are the defaults of
roadmap.implement.step_token_progress_calls,step_token_max_refusalsandstep_token_extension_percent, so an operator can change them without a release. (best practice) [sources: openspec/changes/archive/2026-11-02-3063-long-running-tasks-progress-based-deadlines/proposal.md:9, CONTRIBUTING.md:176]- Chosen: N=20, M=4, share=10%. The 16 items had at most 3 refusals in 20 calls, and the largest observed overrun was 3.7%; 10% gives margin.
- Rejected: N=20, M=3, share=5%. A threshold of 3 refusals would stop an item with 3 refusals, which the data shows as progress.
- Rejected: N=10, M=2, share=5%. A shorter window is noisier and the data is for 20 calls.
- Where does the absolute ceiling live, and what is its default?: A new setting
roadmap.implement.step_token_ceiling, default 2 timesroadmap.implement.step_token_budget, and never below the step budget. Only an operator changes it; no code raises it. (best practice) [sources: openspec/changes/archive/2026-11-02-3063-long-running-tasks-progress-based-deadlines/proposal.md:9, src/devops_cli/config/settings.py:1073, docs/ENV_VARS.md:111]- Chosen: New setting with a default of 2x. It is a separate budget, it follows the project's deadline ceiling, and only a person changes it.
- Rejected: Reuse
roadmap.implement.item_token_budget. The item budget bounds the whole run, not one step, and a step extension must respect it separately. - Rejected: No ceiling. A one-time extension can still exceed a safe cost.
- Does the extension apply to
roadmap.implement.step_time_limit_seconds?: No. The time limit stays a hard stop with classlimit_reached. (best practice) [sources: docs/ENV_VARS.md:126]- Chosen: Token budget only. The measurement and the rule count input tokens; a time limit has no edit or refusal counts.
- Rejected: Both token and time limits. A slow step can make no progress and still extend, which defeats the limit.
- Does the extension add a new failure class or a new stop site?: No. The stop keeps class
limit_reachedand names the setting. The step passes the class itself. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:176, docs/ROADMAP_WORKFLOW.md:196]- Chosen: Keep
limit_reached. The class taxonomy is fixed and the stop site knows its cause. - Rejected: Add a
budget_extendedclass. An extension is no stop, and a new class changes the taxonomy and the metrics.
- Chosen: Keep
- How does the job count successful edits and refused commands?: From the tool-call log and trace of the step.
ToolCallLoggives every call an outcome:write_fileandedit_filewithokare successful edits, andshellwithrefusedis a refused command. The same outcome goes into thetoolevent of the trace, whichdevops roadmap explain <issue> --traceprints. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py:99, src/devops_cli/roadmap/implement/implement_tool_log.py:350, src/devops_cli/roadmap/implement/implement_tool_log.py:432, src/devops_cli/roadmap/implement/implement_trace.py:119, openspec/changes/archive/2026-10-31-2866-tool-log-names-edit-retry-reason/proposal.md:29]- Chosen: Read the step tool log and trace. The log already marks a shell refusal apart from an ok call, and the trace holds the tool name and outcome of each call.
- Rejected: Ask the model to report counts. The model is no check, and the body rejects a model rule.
- Rejected: Parse the pull request diff. The diff does not show refused commands.
- Should the job record the extension in the job record and the stop comment?: Yes. The job record holds the counts and the new budget; the comment of the job shows them. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:176, src/devops_cli/roadmap/implement/implement_trace.py:3]
- Chosen: Record in the job record and comment. The stop comment already names the class and the action left; the record gives the evidence.
- Rejected: Log only. A person reads the stop comment, not the Job log.
- Are N, M and the share settings or constants?: Settings.
roadmap.implement.step_token_progress_calls,step_token_max_refusalsandstep_token_extension_percenthold the defaults 20, 4 and 10. The configuration refuses a window below 1, a refusal count below 0 and a share outside 1 to 100. (best practice) [sources: openspec/changes/archive/2026-11-02-3063-long-running-tasks-progress-based-deadlines/proposal.md:9, src/devops_cli/config/settings.py:1143, CONTRIBUTING.md:176]- Chosen: Settings with measured defaults. The project's progress-based deadline extension uses three settings with defaults and a validator, and CONTRIBUTING.md names a tunable value a DEFAULT_ that a settings field takes. An operator tunes them without a release.
- Rejected: Constants in the pure function. A constant needs a code change and a release to tune, and the closest project record makes the measured values settings.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 10, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It reduces 13% of stops that need a person to finish the last commits, but work still completes without it.It removes the need for a person to add final commits on 16 of 20 limit-reached items in the measured window.The body states the cost is a small function and one setting, with no model call needed.Both work on the step token budget, but #3568 adds the hard limit and the candidate adds a conditional extension rule at that limit.devops-cli-service commentedon Nov 10, 2026
Status set to Ready at 013c1f4 (see proposed design in issue body).
docs(openspec): archive the change of #4394
docs(openspec): archive the change of #4394
docs(openspec): archive the change of #4394
dan-petty commentedon Nov 11, 2026
The delivered criteria are different from the criteria in this issue
PR #4464 closed this issue. It did not deliver some acceptance criteria as this issue states them. The changes are on purpose, and the archived design records them: design.md ("Decisions" and "Rejected alternatives"). The main spec is
openspec/specs/roadmap-implement-step/spec.md. This comment gives the differences, so that the criteria above are not read as the delivered behavior.step_token_extension_percent(default 10) percent, and the scenario gives a budget of 110%CONST_ROADMAP_IMPLEMENT_EXTENSION_PERCENT), so the scenario gives 150%, up to the ceilingstep_token_progress_calls,step_token_max_refusalsandstep_token_extension_percentdefault to 20, 4 and 10src/devops_cli/config/constants.pyhold the rule:CONST_ROADMAP_IMPLEMENT_EXTENSION_CALLS(20),_MIN_EDITS(1),_MAX_REFUSED(3) and_PERCENT(50). "At most 3 refused commands" is the same rule as "fewer than 4".implement.extension. Four settings would make an untested rule easy to change in the ConfigMap.deadline_ceiling_seconds. A review found that this stops the settings load when a person sets only a budget above 16000000. Issue #4505 gives the fix.No follow-up item is filed for the three settings. If a person wants them as settings, file a new item that cites this comment and ADR 0020.
Source: review findings on PR #4464, checked against
mainat c8ed108.devops-cli-service commentedon Nov 11, 2026
Released in v0.111.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.111.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 05:46 UTC