Repository navigation
Description
Problem Description
The runner agent of the implement job polls the harness shell log with tail after a long command. The polls fill the step token budget. #4079 reported this cause and is closed, but the failure still occurs. The #4079 fix (#4162) added a prompt rule that is not true.
The cause (origin/main 0ac2f76):
- pydantic-ai-harness 0.59.0
Coderregisters the persistentshelltool withdefault_timeout=MAX_FOREGROUND_WAIT(pydantic_ai_harness/coder/_capability.py:136-142).MAX_FOREGROUND_WAITis 270 s (pydantic_ai_harness/shell/_persistent.py:25), and a call cannot ask for more:run_persistent_commandrefuses a timeout above 270 s. The tool also has abackgroundmode. Its text says that no notification arrives when the command finishes. _tuneinsrc/devops_cli/roadmap/implement/implement_step.py:492replaces only the allowlist, the operators and the environment of the shell. It keeps the 270 s wait and the background mode.- The prompt rule at
src/devops_cli/ai/tasks/roadmap_implement_step.md:41says "A shell call returns when its command ends. Do not poll". The requirement "The implement prompt forbids polling" inopenspec/specs/roadmap-implement-step/spec.md:1442holds the same rule. This is false for a command that runs longer than 270 s, or for a command in background mode. - A scoped
uv run devops ci test <dir>often runs longer than 270 s. The call then returns a PID and a log path. The agent has no allowed way to wait, so it readsoutput.logorstatus.jsonagain and again. Each read is one more model request that sends the full step context again.
This is not a regression of #4162. Harness 0.59.0 has been pinned since #2684 (2026-10-29), before #4162 (2026-11-08). The design of #4079 states that _tune "sets no command timeout, so a shell call already returns one result when its command exits". That premise was false.
A second, smaller cause: the harness refuses a command that holds a denied operator as text (;, &&, a newline, $(). So uv run python -c with a ; or a newline in the Python code, or a heredoc, is refused. The hint implement_refusal_operator (src/devops_cli/lang/en/messages.py:2748) says "Run one command in each call. Do not chain commands." It does not tell the agent that the ; or the newline inside the Python code is the cause, so the agent sends the same form again.
Reproduction Steps
- Read the timestamped pod logs of a runner Job that runs
uv run devops ci test tests/roadmap/implement, for example Job...-201723-686f(fix(roadmap): the implement plan gate runs the OpenSpec validation too #3429) on 2026-11-10. - Find the
shellcall that returns after 270.1 to 270.3 s with a PID and a log path. - Count the
tail .pydantic-ai-harness/shell/<id>/output.logcalls that follow. - Read
src/devops_cli/ai/tasks/roadmap_implement_step.md:41andpydantic_ai_harness/shell/_persistent.py:25.
Expected vs Actual Behavior
Expected: the prompt states that a foreground shell call returns after at most 270 s with a PID and a log, and it gives one allowed way to wait. Or, better, the step runs its scoped test row in its own exit check, outside the model, and gives the agent only the result. The operator hint names ;, a newline and a heredoc inside python -c code as the cause of the refusal.
Actual, from 2026-11-08T23:45Z to 2026-11-10T23:45Z:
- 8 runner Jobs ran. 6 foreground calls returned at the 270 s cap, in 5 Jobs. In each of the 4 Jobs that polled, the polls started right after a 270 s return.
- 97 reads of harness job files in 4 of 8 Jobs: 686f (fix(roadmap): the implement plan gate runs the OpenSpec validation too #3429) 71 (67
tail), 3b94 (fix(roadmap): refuse a behavior group that omits a test it changes #3414) 16, c187 (fix(roadmap): the implement job checks the test form that a task names #3451) 6, b626 (fix(roadmap): Name the test case that a change invalidates #3443) 4. - In 686f, 71 of 151 tool calls (47%) read the log. About 7.06M of the 12.0M input tokens of the step went into the span of 57 polls and 10 other calls (gateway counter
end_user="devops-cli-job", 20:28:00Z to 20:31:30Z). The step then stopped withLimitReached: step_token_budget=12000000, and fix(roadmap): the implement plan gate runs the OpenSpec validation too #3429 isstatus/blocked. - 24 operator refusals in 8 of 8 Jobs: uv 9, git 7, ls 3, other 3, grep 1, cat 1. Job 3b94 sent
git status ... && git log ...4 times. Job a7fa sent 3 refuseduv run python -ccalls in a row.
Still occurring: Job 686f ran from 20:17Z to 20:36Z on 2026-11-10. After the window, Job 5e9a (#3462, 2026-11-11 02:25Z) started uv run devops ci test tests/roadmap/stage in background mode, then read output.log with tail 2 times, and had 1 refusal (git status --short && git branch).
Environment Diagnostics
- DevOps CLI Version: 0.110.0
- pydantic-ai-harness: 0.59.0
- Python Version: 3.14
- OS & Architecture: Linux x86_64
- Execution Environment: devops-cli-runner Job in the cluster
Logs, Traces, or Terminal Output
# Loki, 2026-11-08T23:45Z to 2026-11-10T23:45Z
sum by (pod) (count_over_time({namespace="devops", service_name="devops-cli-job"} |= "Tool call: shell, started:" |= "pydantic-ai-harness" [48h]))
# 686f 71, 3b94 16, c187 6, b626 4
sum by (pod) (count_over_time({namespace="devops", service_name="devops-cli-job"} |= "Tool call: shell, program" |= "refused" [48h]))
# 24 in 8 of 8 Jobs
# Gateway counter
sum(litellm_input_tokens_metric_total{end_user="devops-cli-job"})
# 3,953,357 at 20:28:00Z, 11,009,815 at 20:31:30Z on 2026-11-10
Tool call: shell, started: uv run devops ci test tests/roadmap/implement # 20:21:38.9Z, returned 20:26:09.1Z
Tool call: shell, started: tail -5 .pydantic-ai-harness/shell/<id>/output.log # 20:27:16Z
Tool call: shell, started: tail -3 .pydantic-ai-harness/shell/<id>/output.log # 20:27:25Z
Tool call: shell, started: tail -4 .pydantic-ai-harness/shell/<id>/output.log # 20:27:33Z
... (67 tail calls on the same log)
LimitReached: The step spent its budget roadmap.implement.step_token_budget=12000000Related: #4079 (closed, the same cause), #4387 (budget unit), #4043 and #4115 (stop on refusals; they do not fix the hint or the wait).
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The implement agent polls the harness shell log after a foreground call reaches the 270 s cap. The polls spend the step token budget and stop the step. The prompt states a false rule. The refusal hint hides the cause of an operator refusal.
Acceptance criteria
Requirement: Implement prompt states the shell cap
The implement prompt SHALL state the 270 s foreground cap, the PID and the log path, and the ban on reading the log.
Scenario: Prompt text names the cap
- WHEN A test reads src/devops_cli/ai/tasks/roadmap_implement_step.md.
- THEN The test finds the 270 s cap, the PID, the log path and the ban on reading the log in the polling rule.
Requirement: Implement prompt sends the long test row to the exit check
The implement prompt MUST send a long scoped test row to the job exit check, not to a shell call.
Scenario: Prompt text names the exit check
- WHEN A test reads the polling rule of the prompt.
- THEN The test finds the rule that the job exit check runs the scoped test row and a shell call must not run it.
Requirement: The tuned shell refuses background mode
The tuned persistent shell tool MUST refuse a call that asks for background mode.
Scenario: Background call is refused
- WHEN A test calls the tuned shell with the background flag set.
- THEN The call returns a refusal and starts no command.
Requirement: The refusal hint names the Python code causes
The operator refusal hint MUST name a semicolon, a newline and a heredoc inside python -c code as causes.
Scenario: Hint names the causes
- WHEN A test asks the refusal message for the operator reason.
- THEN The text names ;, a newline and a heredoc inside python -c code.
Requirement: The spec matches the corrected prompt
The roadmap-implement-step spec SHALL hold the corrected polling rule.
Scenario: Spec holds the corrected rule
- WHEN A test reads the requirement The implement prompt forbids polling.
- THEN The requirement states the 270 s cap, the PID and the log path, and forbids reading the log.
Existing Tool Considered
No alternatives check has run. pydantic-ai-harness 0.59.0 provides the persistent shell tool. It lacks a foreground timeout above 270 s and a completion notification for background commands. The change keeps the harness foreground mode and sends long test rows to the job exit check. It builds no new shell code.
Key questions
- How should the step handle a shell command that runs longer than 270 s?: The step must not let the model wait or poll. The job runs the scoped test row in its exit check and gives the agent the result. The prompt states the 270 s cap. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/ai/tasks/roadmap_implement_step.md, openspec/specs/roadmap-implement-step/spec.md]
- Chosen: Run long test rows in the job exit check. This removes the model wait and keeps the result outside the step context.
- Rejected: Add a wait tool to the harness. This builds and keeps code that the harness does not provide.
- Rejected: Keep background mode and allow polling. This spends the step token budget and is the defect.
- Should the persistent shell offer background mode?: No. The tune step must refuse background mode. The agent must not start a command and poll its log. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/ai/tasks/roadmap_implement_step.md]
- Chosen: Refuse background mode. This removes the poll path from the tool.
- Rejected: Keep background mode. The harness sends no completion notification, so the agent polls the log.
- What should the operator refusal hint say?: The hint must name ;, a newline and a heredoc inside python -c code as causes. It must tell the agent to use a script file or one command. (best practice) [sources: src/devops_cli/lang/en/messages.py, src/devops_cli/roadmap/implement/implement_shell_refusal.py]
- Chosen: Update the existing hint text. The refusal path already returns this text, so no new class is needed.
- Rejected: Add a new refusal class. This adds code and does not change the misleading text.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.Jobs are blocked and millions of tokens are wasted on each occurrence.It blocks implement jobs and exhausts the step token budget.Requires correcting the prompt rule and adding an allowed wait mechanism or moving test execution outside the model.Both address the runner agent polling during long test runs, but #4079 fixed the sleep-loop pattern while this candidate fixes the false prompt rule and adds an allowed wait path.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at c3f62a9 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Released in v0.112.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.112.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 14:13 UTC