Repository navigation
Description
Problem
One agent run of the fix-plan step (a plan run or a review run) has no time limit of its own. The time budget of #5363 (PR #5380) is checked only before each run, and it keeps a margin of 1200 s below the Job deadline for one more run. On 2026-11-13 the longest run of the #5350 attempt took 1013 s, close to that margin. A longer run would pass the Job deadline, and the attempt would end with no result line again.
The first text of this item said that the attempt stalled for 39 minutes. That was false: the full Tempo trace (12.6 MB) shows continuous work until the Job deadline. A read through the Grafana MCP proxy stops at its 10 MiB limit, so the summary showed an early end. The evidence is in the comment above.
Proposed fix
Give each agent run of fix-plan an upper limit from a setting, below the margin that the step budget keeps (nested timeouts: run limit < margin < Job deadline). When a run reaches its limit, stop it, keep the plan branch as it is, and end the attempt with the timeout result line of #5363.
Acceptance criteria
- A test with a run that does not end finds the
timeoutresult line before the margin ends. It fails onmain(devops ci fail-to-pass). - A test holds the order: run limit < step margin < Job deadline of the templates.
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
Depends on #5380 (the step budget).
Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai), MIT, last activity 2026-11-28, maintained.
Reason: Searches found no other maintained tool; pydantic-ai, already the project's agent framework, gives the before_model_request hook and per-request timeout that bound each fix-plan run, so only the setting, validation, docs and template check remain to build.
Covers:
- before_model_request hook runs before every model request
- Per-request timeout bounds one request by remaining run time
- run_sync returns control between requests so the hook can stop a run
Lacks:
- No built-in wall-clock limit for one whole agent run
- No run-limit setting, validation or generated config reference
- No timeout result line or nested template deadline check
Proposed design
Problem statement
Hold this item until a person closes #6521 after the re-architecture experiments of #6519 decide. One fix-plan run has no wall-clock limit of its own: the step checks its time budget only before each run, and it keeps a 1200 s margin below the Job deadline. The longest run of the #5350 attempt took 1013 s, so a longer run passes the deadline and the attempt ends with no result line. The fix adds roadmap.fix_plan.run_time_limit_seconds with a default of 1080 s and stops a run that reaches it with the timeout result line.
Acceptance criteria
Requirement: Per-run limit ends a fix-plan run
The fix-plan step SHALL stop one agent run when it reaches roadmap.fix_plan.run_time_limit_seconds and SHALL end the attempt with the timeout result line.
Scenario: A run past its limit writes the timeout line
- WHEN A test runs the fix-plan step with
roadmap.fix_plan.run_time_limit_secondsof 1 s androadmap.fix_plan.time_budget_secondsof 60 s, and its fake model reply advances the clock past the run limit and asks for another request. - THEN The run raises
RoadmapTimeBudgetErrorbefore the next request, the plan branch keeps its last commit, the result line holdsresult=timeoutandclass=timeout, anduv run devops ci fail-to-pass --base origin/mainshows the test fails onmain.
Requirement: A model request cannot pass the run limit
The fix-plan step MUST give each model request no more time than remains before the run limit.
Scenario: The last request gets only the remaining time
- WHEN A test sets
roadmap.fix_plan.run_time_limit_secondsto 100 s, advances the fake clock to 90 s of the run, and starts one model request. - THEN The step gives the request a timeout of 10 s, and a run whose remaining time is zero raises
RoadmapTimeBudgetErrorbefore the request starts.
Requirement: The settings refuse a run limit at or above the budget
The settings load MUST refuse a fix-plan run limit at or above roadmap.fix_plan.time_budget_seconds.
Scenario: A run limit at the budget is refused
- WHEN A test loads the settings with
roadmap.fix_plan.run_time_limit_secondsequal toroadmap.fix_plan.time_budget_seconds. - THEN The load raises a validation error that names both settings, and the same test loads with a run limit 1 s below the budget.
Requirement: The generated reference lists the setting
The generated configuration reference MUST list roadmap.fix_plan.run_time_limit_seconds with its default.
Scenario: The generated docs are current
- WHEN
uv run devops docs checkruns afteruv run devops docs generate. - THEN The command exits 0 with no stale generated document, and
docs/CONFIGURATION.mdlistsrun_time_limit_secondswith the default1080.
Requirement: The default run limit stays below the budget margin
The default fix-plan run limit MUST stay below the margin that the fix-plan budget keeps below the Job deadline.
Scenario: The default fits the margin
- WHEN A test compares
DEFAULT_ROADMAP_FIX_PLAN_RUN_TIME_LIMIT_SECONDSwith the fix-plan budget margin constant. - THEN The run limit is below the margin, and the test fails when the default equals the margin.
Requirement: The templates hold the nested order
The k8s gate check MUST refuse a rendered roadmap CronJob whose activeDeadlineSeconds is below the fix-plan budget plus its margin.
Scenario: The rendered templates hold the nested order
- WHEN
uv run devops ci --check --only k8srenders the roadmap CronJob templates. - THEN The command exits 0, and it exits 1 naming the template when
activeDeadlineSecondsis belowroadmap.fix_plan.time_budget_secondsplus the margin.
Existing Tool Considered
The alternatives check in the issue body gives the verdict in-use for pydantic/pydantic-ai (MIT, maintained). The check lists what the library covers and what it lacks. This change uses the before_model_request hook to stop a run at its limit. It sets the timeout of each request to the remaining run time. It adds the setting, its validation, the result line and the nested-order check that the library lacks. The cost is about 30k tokens to build this code. Each later fix costs about 5k tokens. The elapsed time is 1 to 2 days.
Key questions
- Does one fix-plan run have a wall-clock limit of its own today?: No. The step checks
roadmap.fix_plan.time_budget_seconds(3600 s) before each run, andai.request_timeout_seconds(1200 s) limits one model request. No limit covers the whole run. [sources: docs/CONFIGURATION.md, src/devops_cli/config/defaults.py:1225, src/devops_cli/config/defaults.py:151, src/devops_cli/roadmap/time_budget.py] - What margin does the fix-plan budget keep below the Job deadline?: 1200 s, as the issue states. The step starts a run only when that much time remains. The longest run of docs(openspec): plan #5118 Restore the Status on a claim release #5350 took 1013 s, near that margin. [sources: src/devops_cli/roadmap/time_budget.py, docs/CONFIGURATION.md]
- Which item must be delivered before this one?: chore(roadmap): hold incremental stage and implement work #6521. A person closes chore(roadmap): hold incremental stage and implement work #6521 after the re-architecture experiments of refactor(roadmap): re-architect stage and implement on Coder #6519 decide. The step budget of fix(roadmap): fix-plan ends at the Job deadline with no result line #5363 is delivered:
roadmap.fix_plan.time_budget_secondsis in the generated reference. [sources: docs/CONFIGURATION.md, src/devops_cli/config/settings.py:2063] - How does the step stop one agent run at its limit?: A
before_model_requesthook raisesRoadmapTimeBudgetErrorwhen the run limit is spent. It also sets the timeout of each request to the remaining run time, so one request cannot pass the limit. (best practice) [sources: src/devops_cli/roadmap/implement/implement_limits.py, src/devops_cli/roadmap/time_budget.py, src/devops_cli/exceptions/roadmap.py:280]- Chosen:
before_model_requesthook with the remaining-time timeout. It runs before each request, it bounds the request, and the step maps the error to the timeout line. - Rejected:
asyncio.timeoutaround each run. The planner callsagent.run_sync, so no event loop exists to cancel. - Rejected: HTTP client read timeout. It applies to each read, so a reply that keeps streaming is never stopped.
- Rejected: The 1200 s request timeout as the only inner limit. It ends one request, not the run, so a run of several requests passes the margin.
- Rejected: Keep the step budget only. A run that starts near the budget end passes the Job deadline, as the 1013 s run shows.
- Chosen:
- What default does the per-run limit take?: 1080 s. It is below the 1200 s margin, with 120 s for the push and the result line, and above the 1013 s longest run of docs(openspec): plan #5118 Restore the Status on a claim release #5350. (best practice) [sources: docs/CONFIGURATION.md, src/devops_cli/config/defaults.py:1225, src/devops_cli/config/defaults.py:151]
- Chosen: 1080 s. It stays below the margin, keeps 120 s for the push and the result line, and stays above the 1013 s run.
- Rejected: 1500 s. It is above the 1200 s margin, so a run at the limit passes the Job deadline.
- Rejected: 1200 s. It equals the margin, so no time stays for the push and the result line.
- Rejected: 900 s. It is below the 1013 s longest run of docs(openspec): plan #5118 Restore the Status on a claim release #5350, so a normal long run is cut.
- Rejected: 3600 s. It equals the step budget, so it adds no limit below the budget.
- Which setting holds the per-run limit?:
roadmap.fix_plan.run_time_limit_seconds, inRoadmapFixPlanConfig, with the precedence of the other fix-plan settings. (best practice) [sources: src/devops_cli/config/settings.py:2063, docs/CONFIGURATION.md]- Chosen:
roadmap.fix_plan.run_time_limit_seconds. It follows the_secondssuffix and sits in the fix-plan group with the other limits. - Rejected:
roadmap.fix_plan.run_limit_s. The settings use_secondsfor a time limit, not_s. - Rejected: A constant in the step code. It gives no way to tune the limit for a slow model tier.
- Chosen:
- Which result line ends an attempt that the per-run limit stops?: The
timeoutline of fix(roadmap): fix-plan ends at the Job deadline with no result line #5363, withresult=timeoutandclass=timeout. The step mapsRoadmapTimeBudgetErrorto the timeout class, as the stage step does. (best practice) [sources: src/devops_cli/exceptions/roadmap.py:280, src/devops_cli/roadmap/stage/stage.py, tests/roadmap/test_roadmap_limit_classes.py]- Chosen: The
timeoutline. One cause has one class, and the existing retry and label rules handletimeout. - Rejected: A new
run-timeoutclass. Two classes for one cause split the job grade count and the dashboards. - Rejected:
failed. A run limit is a time stop, not a model or check failure.
- Chosen: The
Fit
Fits in one pull request.
Suspected block
The re-architecture experiments of #6519 must decide, and a person must then close #6521 or close this item as not planned.
Activity
dan-petty commentedon Nov 13, 2026
Both concern the fix-plan step and the same 2026-11-13 incident, but #5363 adds a step-level time budget while the candidate diagnoses the stall and bounds each model request, tool call, and wait.dan-petty commentedon Nov 13, 2026
A lead for the cause: the worker node hawk hung at about the same time. Its last journal line in Loki is at 04:38:28Z, 10 s after the last span of this attempt (04:38:18Z). The kubelet stopped reporting at 04:40:08Z, and the node did not come back. hawk was cordoned and ran only DaemonSet pods. Check whether a request of the attempt went through hawk (a DaemonSet on that node in the path, a model tier, DNS or the pod network) and whether the call had a client timeout that should have fired.
dan-petty commentedon Nov 13, 2026
The premise of this item is false: the fix-plan attempt did not stall. No call hung, so no client timeout had to fire. I return the item to New with this evidence.
Evidence (read on 2026-11-13 by trace ID from the Tempo API
/api/v2/traces/fbef6e37a8678ee158d313142a3f044e, and from Prometheus):fix-plan-5350,process.pid1) continue to 05:15:34Z. The LLM gateway spans continue to 05:15:38Z.tool_call. The gateway sent HTTP 200 after about 2 s and then streamed the reply. All 217 model requests of the trace ended.kube_pod_start_time). 5400 s after that is 05:15:08Z. The last span of the step ends 26 s later, in the termination grace period. Thus the Job deadline stopped a process that still did work.kube_pod_info). The spans of the step continue after 04:38:28Z. Thus the node failure did not stop the attempt.Client timeouts on
origin/main:drain_eventsinsrc/devops_cli/roadmap/agent_run.pystreams each model request (#2379). The read timeout of an HTTP client applies to each read, so it does not stop a reply that continues to send chunks. That is correct for these requests: each one sent chunks until it ended.What is left: the attempt needed more than 5400 s of work. #5363 (pull request #5380) covers this failure. With its default budget of 3600 s, the budget ends at about 04:45Z, the run in progress ends at 04:50:19Z, the step starts no new run, and it writes the result line with class
timeout. One agent run has no upper limit of its own, and the longest run of this attempt (1013 s) is near the margin of 1200 s that #5380 keeps for one more run. If a limit on each agent run is necessary, write that as the new body of this item. Else close this item as covered by #5363.[-]fix(roadmap): find the 39-minute stall of a fix-plan attempt[/-][+]fix(roadmap): limit each agent run of fix-plan below the budget margin[/+]devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: Searches for a library that bounds a single agent run (per-run timeouts, nested deadline budgets, streaming LLM run limits) returned only unrelated material — web-platform timer APIs (
setTimeout,XMLHttpRequest.timeout), an HTTP 408 page and container images — and nothing that imposes an upper limit on one agent run of a job. The need is a change inside the project's own fix-plan runner (a per-run limit from a setting, the nested order run limit < step margin < Job deadline, stopping the run and writing thetimeoutresult line of #5363, plus the two tests), which no external tool provides.Tool: none found
Lacks:
timeoutresult line of fix(roadmap): fix-plan ends at the Job deadline with no result line #5363Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at 2620fae (see proposed design in issue body).
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 22, 2026
The result in the alternatives block of the issue body changed. Before this check:
none, no tool. A person decides what the new result means for the item.Searches (10)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 27, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.