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-22: in-use.
The repository already uses this tool.
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai), MIT, last activity 2026-11-22, maintained.
Reason: Searches found no dedicated tool for a per-run wall-clock limit; the project's pydantic-ai supplies the before_model_request hook seam and per-request timeouts, but no run limit or nested run/budget/deadline order.
Covers:
- Hooks seam before each model request
- Per-request timeout as the inner limit
- UsageLimits for request and tool-call counts
Lacks:
- Wall-clock limit for one whole agent run
- Nested run limit, step margin and Job deadline order
- Setting, validation and timeout result line
Proposed design
Problem statement
One agent run of the fix-plan step has no time limit of its own. The step budget of #5363 is checked only before each run and keeps a margin 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 can pass the Job deadline, and the attempt then ends with no result line.
Acceptance criteria
Requirement: Per-run limit ends a run
The fix-plan step SHALL stop one agent run when it reaches roadmap.fix_plan.run_time_limit_seconds and end the attempt with the timeout result line.
Scenario: A run past its limit writes the timeout line
- WHEN A test runs fix-plan with
roadmap.fix_plan.run_time_limit_secondsof 1 s androadmap.fix_plan.time_budget_secondsof 5 s, and the first model reply advances the clock past the run limit and asks for another request. - THEN The run stops before the next request, the plan branch keeps its last commit, the result line holds
result=timeout,class=timeoutandrun_limit=1, anduv run devops ci fail-to-pass --base origin/mainshows the test fails onmain.
Requirement: Defaults nest under the Job deadline
The default per-run limit MUST stay above the default model request timeout, below the default fix-plan time budget, and below the margin that budget leaves to the deadline of each Job template.
Scenario: The k8s gate check holds the nested order
- WHEN
uv run devops ci --check --only k8sruns the gate check of the rendereddevops-clianddevops-cli-runnerCronJobs and the default constants. - THEN The command exits 0, and it fails when the run limit is at or below
DEFAULT_AI_REQUEST_TIMEOUT_SECONDS, at or aboveDEFAULT_ROADMAP_FIX_PLAN_TIME_BUDGET_SECONDS, or at or aboveactiveDeadlineSeconds - DEFAULT_ROADMAP_FIX_PLAN_TIME_BUDGET_SECONDSof a template.
Requirement: Settings refuse a limit at or above the budget
The settings load MUST refuse a fix-plan run limit at or above the step time budget.
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 passes when the run limit is below the budget.
Requirement: 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.mdlistsroadmap.fix_plan.run_time_limit_seconds=1500.
Existing Tool Considered
pydantic-ai 2.59.0 (pyproject.toml:40) is the open, maintained agent library. It gives the Hooks(before_model_request=...) seam (src/devops_cli/roadmap/implement/implement_limits.py:298-318) and UsageLimits for request and tool-call counts (src/devops_cli/roadmap/stage/stage_toolbox.py:24 and :83-88), but it has no wall-clock limit for one agent run and no nested run/budget/deadline ordering. The alternatives check of 2026-11-17 found no dedicated tool. The change builds the limit in the project's fix-plan runner: about 30k tokens to build, about 5k tokens for each later fix, and 1 to 2 days elapsed.
Key questions
- Did the fix-plan attempt stall, and does the item still have work?: No call hung:
drain_eventsstreams each model request, and each request of the full trace ended. The trace shows continuous work until the Job deadline; a read through the Grafana proxy stops at 10 MiB and hid the end. The item still has work: one run has no limit of its own, and the longest run took 1013 s near the margin of fix(roadmap): fix-plan ends at the Job deadline with no result line #5363. (best practice) [sources: src/devops_cli/roadmap/agent_run.py:50-54, src/devops_cli/roadmap/steps/fix_plan.py:89-93, docs/roadmap/stage.md:116, openspec/changes/archive/2026-11-13-5363-fix-plan-time-budget/design.md:17]- Rejected: Close the item as covered by fix(roadmap): fix-plan ends at the Job deadline with no result line #5363. fix(roadmap): fix-plan ends at the Job deadline with no result line #5363 checks the budget only before each run and keeps a margin for one more run, so a run that starts near the end passes the Job deadline.
- Chosen: Limit each agent run. The longest run took 1013 s, near the margin, so a longer run passes the Job deadline; a per-run limit stops it before the margin.
- How does the step stop one agent run at its limit?: Add a pydantic-ai
Hooks(before_model_request=...)capability to the agent run, asimplement_limits.limit_hooksdoes, and raiseRoadmapTimeBudgetErrorbefore the next model request once the run limit is spent. The request timeout (default 1200 s) is the inner limit that ends a request already in flight.revise_planalready catchesRoadmapTimeBudgetErrorand maps it toFailureClass.TIMEOUT, so the attempt ends with thetimeoutresult line. (best practice) [sources: src/devops_cli/roadmap/refine/refine_investigation.py:630, src/devops_cli/roadmap/implement/implement_limits.py:298-318, src/devops_cli/roadmap/stage/stage.py:3593-3607, openspec/changes/archive/2026-11-13-5363-fix-plan-time-budget/design.md:17]- Chosen: pydantic-ai
Hooks(before_model_request=...). It runs on every model request of the run and raises before the next request once the run limit is spent;revise_planalready maps the error to thetimeoutclass. - Rejected:
asyncio.timeoutaround each run. The planner callsagent.run_sync, so there is no event loop to cancel; the archived fix(roadmap): fix-plan ends at the Job deadline with no result line #5363 design rejected it for this reason. - Rejected: HTTP client read timeout. It applies to each read, so a reply that keeps streaming is never stopped.
- Rejected: No run limit, keep the step budget only. A run that starts near the budget end passes the Job deadline, as the 1013 s run shows.
- Chosen: pydantic-ai
- What default does the per-run limit take?: 1500 s: above the 1200 s model request timeout and the 1013 s longest run of docs(openspec): plan #5118 Restore the Status on a claim release #5350, and below the 1800 s that the 3600 s step budget leaves to the 5400 s hand-made Job deadline (and the 3600 s it leaves to the 7200 s template deadline), with 300 s for the push and the result line. (best practice) [sources: src/devops_cli/config/defaults.py:141, src/devops_cli/config/defaults.py:1127, docs/SERVICE_PATTERNS.md:96, ARCHITECTURE.md:153, k8s/devops/cronjob.yaml:30]
- Rejected: 1080 s. It is below the 1200 s model request timeout, so a single request can overrun the run limit and the limit is not an upper bound.
- Rejected: 1200 s. It equals the request timeout, so a request can use the whole run limit and leave no margin for the next request.
- Chosen: 1500 s. It is above the request timeout and the 1013 s run, and below the 1800 s margin of the 3600 s budget, leaving 300 s for the push and the result line.
- Rejected: 1800 s. It equals the margin that the 3600 s budget leaves to the 5400 s Job deadline, so a run that starts at the budget end leaves no time for the push and the result line.
- 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 same precedence (config file, environment, default). The settings load refuses a value at or aboveroadmap.fix_plan.time_budget_seconds, as the stage job's validator does for its nested timeouts. (best practice) [sources: src/devops_cli/config/settings.py:1942-1960, src/devops_cli/config/settings.py:1534-1538, src/devops_cli/config/settings.py:2140-2148, docs/CONFIGURATION.md:315]- Chosen:
roadmap.fix_plan.run_time_limit_seconds. It follows the_secondssuffix oftime_budget_secondsandstep_time_limit_secondsand sits in the fix-plan group with the other limits. - Rejected:
roadmap.fix_plan.run_limit_s. The project's settings use_seconds, not_s, for a time limit. - Rejected: Constant in the step code. A constant 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
timeoutresult line of fix(roadmap): fix-plan ends at the Job deadline with no result line #5363, withresult=timeoutandclass=timeout; the line addsrun_limit=<seconds>to its counts, so the cause is visible.revise_planalready mapsRoadmapTimeBudgetErrortoFailureClass.TIMEOUT. (best practice) [sources: src/devops_cli/roadmap/steps/fix_plan.py:253-262, src/devops_cli/roadmap/steps/fix_plan.py:840-841, src/devops_cli/roadmap/steps/fix_plan.py:1297-1307, src/devops_cli/roadmap/job_result.py:269-306]- Chosen: Reuse the
timeoutline. One cause, one class: the job grade counts the attempts by class, and the existing comment and label rules already handletimeout. - Rejected: New class
run-timeout. Two classes for one cause split the grade count and the dashboards. - Rejected:
failed. A run limit is a time stop, not a model or check failure, and the retry rule oftimeoutalready applies.
- Chosen: Reuse the
Fit
Fits in one pull request.
Suspected block
None.
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: