Skip to content

feat(roadmap): extend a step budget when the run makes progress #4394

Closed

Description

@dan-petty

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.

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_reached and names roadmap.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_reached and 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_reached and 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_percent to 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_reached and names roadmap.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_reached and names roadmap.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?: In StepBudget.spent(), which limit_hooks calls before each model request. A step that has spent the budget stops with class limit_reached, and the reason names roadmap.implement.step_token_budget and 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_budget is the most input tokens that all steps of one run of an item may use, the fix steps included. StepBudget checks 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 class limit_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_calls tool calls in the step's tool-call log: a successful edit is a write_file or edit_file call with outcome ok, and a refused command is a shell call with outcome refused. The step extends when the window holds at least one successful edit and fewer than roadmap.implement.step_token_max_refusals refused 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_refusals and step_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 times roadmap.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 class limit_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_reached and 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_extended class. An extension is no stop, and a new class changes the taxonomy and the metrics.
  • How does the job count successful edits and refused commands?: From the tool-call log and trace of the step. ToolCallLog gives every call an outcome: write_file and edit_file with ok are successful edits, and shell with refused is a refused command. The same outcome goes into the tool event of the trace, which devops roadmap explain <issue> --trace prints. (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_refusals and step_token_extension_percent hold 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

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces 13% of stops that need a person to finish the last commits, but work still completes without it.
    • Value: Medium. It removes the need for a person to add final commits on 16 of 20 limit-reached items in the measured window.
    • Effort: Low. The body states the cost is a small function and one setting, with no model call needed.
    • Related: feat(roadmap): a step stops at its budgets and records attempts #3568, which asks for a different change. Both work on the step token budget, but #3568 adds the hard limit and the candidate adds a conditional extension rule at that limit.
  3. added
    priority/p2-medium
    owner/agent
    on Nov 10, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 10, 2026
  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 013c1f4 (see proposed design in issue body).

  6. added
    status/in-progress
    and removed
    status/ready
    on Nov 11, 2026
  7. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  8. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    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.

    Criterion in this issue Delivered behavior Reason (design.md)
    One-time budget extension: the extension is step_token_extension_percent (default 10) percent, and the scenario gives a budget of 110% The extension is 50% of the budget (CONST_ROADMAP_IMPLEMENT_EXTENSION_PERCENT), so the scenario gives 150%, up to the ceiling One stop needed 3.7% more tokens. The other stops have no measured need, so half of the budget gives room for a step that is further from its end. The ceiling and the item budget bound the cost.
    Progress setting defaults: the settings step_token_progress_calls, step_token_max_refusals and step_token_extension_percent default to 20, 4 and 10 There are no such settings. Four constants in src/devops_cli/config/constants.py hold 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". ADR 0020 keeps the parameters of a rule as data of its decision point. The registry of decision points (#4453) takes them over when a later item registers implement.extension. Four settings would make an untested rule easy to change in the ConfigMap.
    Progress setting validation: the configuration refuses a window below 1, a refusal threshold below 0 and a share outside 1 to 100 No validation, because the three settings do not exist. The refusal of a ceiling below the step budget is delivered. Same as above.
    Ceiling default: when the operator sets no ceiling, the ceiling is 2 times the step budget The default ceiling is a fixed 16000000 (2 times the default budget), not 2 times the configured budget The design follows the fixed 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 main at c8ed108.

  9. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 05:46 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions