Skip to content

fix(roadmap): the implement shell waits for its command - #4536

Merged
dan-petty merged 4 commits into
mainfrom
fix/4493-blocking-run-command
Nov 11, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/4493-blocking-run-command

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The implement step gave its agent the persistent shell tool of the harness. A call of that tool returns after 270 s with a PID and a log, and its background mode sends no notice when the command ends. After a test run of more than 270 s, the agent read the log again and again until the step token budget ran out. The prompt said that a shell call returns when its command ends.

The step now gives the agent the blocking tool run_command of the same harness capability. A call waits until its command ends, up to roadmap.implement.command_timeout_seconds, and the harness kills a command that runs longer. The step sets that wait for each call. The allowlist and the refusals apply as before.

The prompt states the wait and the count of extra turns (roadmap.implement.repair_rounds). The operator hint names a ;, a new line and a heredoc in python -c code.

Closes #4493

Change: openspec/changes/archive/2026-11-11-4493-runner-agent-polls-output-log-after/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Evidence

Real run of the harness tool (pydantic_ai_harness 0.59.0, Shell(tools=["run_command"], default_timeout=2) on a LocalWorkspace, scripted model):

Call Result Returned after
sleep 1, timeout_seconds=600 (no output) 1.1 s
sleep 5 [Command timed out after 2s] 2.1 s
git rev-parse --verify no-such-ref [stderr] ... [exit code: 128] 0.1 s
cd /, then pwd the workspace directory: no state from one call to the next 0.1 s
git status; git log refused: Shell operator ';' is not allowed. 0.1 s
git --version, timeout_seconds=0 the run ends with ValueError: timeout must be a positive finite number or None

The last row is why the step replaces the wait of the model with roadmap.implement.command_timeout_seconds.

Tests (local, 4 workers): the changed tests fail on the base (25 failed, 48 passed: the tool run_command is unknown, the status is not read, the prompt holds the old rules) and pass on the change. ruff check and mypy --strict pass on the changed files. uv run devops ci docs --fix changed only docs/ENV_VARS.md.

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main, exit 0): 72 failed on base, 451 passed, 0 errored, in the 10 changed test files of tests/roadmap/implement/. A sample of the base failures: test_roadmap_implement_timeouts::test_a_shell_call_of_a_step_waits_for_its_command_up_to_the_command_limit_of_the_setting (the tool run_command is unknown), test_roadmap_implement_step_trace::test_a_shell_call_has_the_exit_status_that_the_shell_reports[failed] (None == 128), test_roadmap_implement_shell_refusal::test_the_refusal_of_python_code_names_the_operator_in_the_code_and_a_script_file.

Local run on the change: the 10 changed test files and tests/roadmap/test_roadmap_tools.py, tests/roadmap/test_roadmap_mcp.py, tests/roadmap/test_roadmap_explain.py: 581 passed (73 + 508). The run of the whole tests/roadmap/implement/ directory stopped at 30 % on the load of the host (no failure until then); the CI runs the full suite.

Live steps

None. No setting is added, removed or renamed, so the live ConfigMap needs no change. The Job log lines read Tool call: run_command, ... after the release, in place of Tool call: shell, ....

Polls for each run after the release

Polls: the shell calls that read a job file of the harness or sleep. The persistent shell wrote its job files under .pydantic-ai-harness/shell/, and run_command writes none, so the count must be 0 after the release.

# Polls by runner Job (pod), last 7 days
sum by (pod) (count_over_time({namespace="devops", service_name="devops-cli-job"} |~ "Tool call: (shell|run_command), started: " |~ "pydantic-ai-harness|sleep" [7d]))

# Polls for each run: the polls divided by the runner Jobs that made a tool call
sum(count_over_time({namespace="devops", service_name="devops-cli-job"} |~ "Tool call: (shell|run_command), started: " |~ "pydantic-ai-harness|sleep" [7d]))
/
count(sum by (pod) (count_over_time({namespace="devops", service_name="devops-cli-job"} |= "Tool call: " [7d])))

# Operator refusals for each run (the python -c hint)
sum(count_over_time({namespace="devops", service_name="devops-cli-job"} |~ "Tool call: (shell|run_command), program " |= "refused" [7d]))
/
count(sum by (pod) (count_over_time({namespace="devops", service_name="devops-cli-job"} |= "Tool call: " [7d])))

Base line from the issue (2026-11-08T23:45Z to 2026-11-10T23:45Z): 97 polls in 4 of 8 runner Jobs (12.1 for each run), and 24 refusals in 8 of 8 Jobs (3 for each run).

@dan-petty
dan-petty force-pushed the fix/4493-blocking-run-command branch from c1b49a8 to 29dd7d5 Compare November 11, 2026 07:20
@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 07:48
@dan-petty

Copy link
Copy Markdown
Owner Author

The first CI run failed one test in two shards: tests/roadmap/implement/test_roadmap_implement_step_repair.py::test_the_instructions_say_that_a_failed_static_check_gets_one_turn. It asserted the old prompt text "you get one more turn with the text of the error", which this change corrects. The second commit edits the assertion to the corrected text ("you get an extra turn with the text of the error"); the test keeps its name and its purpose. After a rebase onto origin/main, all 29 checks pass and 3 skip.

@dan-petty
dan-petty force-pushed the fix/4493-blocking-run-command branch from 29dd7d5 to f78dee8 Compare November 11, 2026 08:08
@dan-petty

Copy link
Copy Markdown
Owner Author

Review findings

1. Major: three scenarios of the main spec named the old tool shell. Fixed.

Verification: the finding is correct. Before this push, openspec/specs/roadmap-implement-step/spec.md:236 named shell in the tools of the agent, and lines 408 and 412 expected Tool call: shell, .... The step offers run_command, and test_roadmap_implement_tool_log.py:79-80 expects Tool call: run_command, .... Line 236 also disagreed with the new requirement "The shell of a step waits for its command up to the command limit".

What I did (commit c7e2545, then the archive again in the last commit f78dee8):

  • The delta spec now has MODIFIED entries for "A run that reaches a limit ends stopped" (the tools are edit_file, grep, list_files, read_file, run_command and write_file, and no delegate_task) and for "A call with a command writes the command to the Job log before it runs" (the lines Tool call: run_command, started: ... and Tool call: run_command, program pytest, refused.). The archive applied both to the main spec.
  • test_the_line_of_a_command_is_written_before_the_call_runs now names its tool run_command, so that the test agrees with its scenario "The line comes before the call". Task 1.3 records this.
  • The proposal lists the two modified requirements.

Checks:

  • uv run devops ci test tests/roadmap/implement/test_roadmap_implement_tool_log.py tests/roadmap/implement/test_roadmap_implement_step.py: 240 passed.
  • openspec validate 4493-runner-agent-polls-output-log-after --strict: valid. devops openspec archive: every spec and change validates.
  • The main spec has no Tool call: shell line and no tool list with shell after the archive.

Other open pull requests that change this main spec (#4553, #4556) change other requirements, not these lines.

@dan-petty
dan-petty marked this pull request as draft November 11, 2026 10:47
The step gives its agent the blocking tool run_command of the harness, with the wait of roadmap.implement.command_timeout_seconds, in place of the persistent shell tool that returned after 270 s with a PID and a log. The prompt states the wait and the count of extra turns, and the operator hint names the code of python -c.
…ent step

The scenario of the agent tools and the two scenarios of the Job log line
named the old tool shell. The step offers run_command, so the delta spec
now modifies these two requirements, and the test of the line before a
call names the tool of the step.
@dan-petty
dan-petty force-pushed the fix/4493-blocking-run-command branch from f78dee8 to d868a14 Compare November 11, 2026 11:26
@dan-petty

Copy link
Copy Markdown
Owner Author

Review findings of this pull request: check and fix

I checked each finding against the code of the branch. All four are CONFIRMED. The fixes are in the commit "fix(roadmap): the implement shell waits for its command" and in the archive commit, which stays the last commit.

  1. Major: stale shell names in openspec/specs/roadmap-implement-step/spec.md. CONFIRMED. An earlier fix (commit "docs(openspec): name run_command in the stale scenarios of the implement step") corrected it. I checked it again: the main spec names run_command at lines 236 and 407-412, and it holds no tool name shell and no line "Tool call: shell". It stays fixed.

  2. Minor: the knowledge base page of the harness names the shell tool. CONFIRMED. pydantic_ai_harness.md line 34 said that the agent gets shell, and item 3 named only allowed_commands and denied_operators. _tune sets tools=[IMPLEMENT_SHELL_TOOL] (run_command) and default_timeout=command_timeout (implement_step.py:557-558).
    Change: line 34 says that the step registers run_command in place of shell, that a call waits until its command ends up to the command limit, and that it has no background mode. Item 3 names tools=["run_command"] and default_timeout with roadmap.implement.command_timeout_seconds. A new item 9 says that the base instructions of Coder name a heredoc and a poll, and that the step prompt forbids both. The reviewed date is 2026-11-11.

  3. Minor: the step prompt does not name the refusal of a heredoc before the first call. CONFIRMED. pydantic_ai_harness 0.59.0 coder/_instructions.py says "Check behavior with inline shell scripts (e.g. a heredoc)" and "poll status and output until complete". Coder(instructions=...) adds the step prompt after that text (coder/_capability.py:126-128). CONST_ROADMAP_IMPLEMENT_DENIED_OPERATORS holds ; and a new line, so the shell refuses a heredoc and python -c code on more than one line. The prompt already forbade a poll (the run_command rule), but it named only ;, && and ||.
    Change: the shell rules of roadmap_implement_step.md now say that the shell reads the whole text of a command, also the text in quotes, and refuses a new line. So it refuses a heredoc, and python -c code that holds a ; or a new line. The agent writes that code to a file under .data/agent/scratch/ and runs uv run python <file>. The rule wins over any text that tells the agent to use a heredoc.
    Test first: test_the_prompt_says_before_the_first_call_that_the_shell_refuses_a_heredoc failed on the head of the branch (1 failed, 22 passed) and passes with the change. The test also asserts that the denied operators hold ; and a new line, so the prompt cannot state a false rule. The archived change has the new requirement "The implement prompt names the refusal of a heredoc" (also in the main spec), task 2.3 and a line in the proposal. I measured nothing live.

  4. Minor: SHELL_TIMEOUT_ARGUMENT is public, but one module reads it. CONFIRMED. A search of src and tests finds it only where it is defined (implement_shell_policy.py) and in implement_shell_refusal.py. CONTRIBUTING.md says that a constant that one module reads is _<NAME> in that module.
    Change: the constant is now _SHELL_TIMEOUT_ARGUMENT in implement_shell_refusal.py. IMPLEMENT_SHELL_TOOL stays in implement_shell_policy.py, because three modules read it.

Checks:

  • uv run devops ci test tests/review/test_kb_manuals_metadata.py tests/docs/test_docs.py tests/roadmap/implement: 1708 passed.
  • uv run devops ci test of the prompt, shell refusal, shell policy and step rules tests: 157 passed.
  • uv run devops openspec check: passed.
  • uv run devops ci fail-to-pass --base origin/main: 74 tests failed on the base and pass on the head, 0 errored. The base prompt holds no "heredoc", so the new prompt test is one of them.
  • CI on head d868a141: 29 checks passed, 3 skipped, none failed.

Live steps: none. The change adds, removes and renames no setting, so the live ConfigMap needs no change.

@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 11:57
@dan-petty
dan-petty merged commit 571e044 into main Nov 11, 2026
32 checks passed
@dan-petty
dan-petty deleted the fix/4493-blocking-run-command branch November 11, 2026 11:58
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.112.0](v0.111.0...v0.112.0)
(2026-11-11)


### Features

* **k8s:** export gateway spans without key metadata
([#4520](#4520))
([7234d71](7234d71))
* **k8s:** set the homelab domain in container env values
([#4608](#4608))
([a3bcf7c](a3bcf7c))
* **telemetry:** send pydantic-ai spans through the exporter seam
([#4538](#4538))
([fcf2a7a](fcf2a7a))


### Bug Fixes

* **ai:** price cached prompt tokens of chat calls
([#4584](#4584))
([f84bbe6](f84bbe6))
* **devcontainer:** stop uv noise lines in agent shells
([#4592](#4592))
([9ba375c](9ba375c))
* **k8s:** delete gateway management bodies from spans
([#4551](#4551))
([b835d3c](b835d3c))
* **k8s:** set the kube context and namespace on devops pods
([#4514](#4514))
([9087b39](9087b39))
* **roadmap:** a refused spec after the archive is a plan defect
([#4549](#4549))
([1db29f7](1db29f7))
* **roadmap:** count and log the reason of a left-out stage item
([#4541](#4541))
([5600179](5600179))
* **roadmap:** default the step ceiling to twice the budget
([#4556](#4556))
([1dfb6c8](1dfb6c8))
* **roadmap:** explain --trace shows the argument digest
([#4526](#4526))
([c92195f](c92195f))
* **roadmap:** explain totals count dropped model events
([#4543](#4543))
([fe0e979](fe0e979))
* **roadmap:** give each eval verify run its own report file
([#4534](#4534))
([ad27f2d](ad27f2d))
* **roadmap:** one event loop and a time limit for decide_all
([#4585](#4585))
([ec51e01](ec51e01))
* **roadmap:** scoped updates send requests with no row scope
([#4531](#4531))
([5f75d25](5f75d25))
* **roadmap:** the caller gate reads an added parameter span
([#4548](#4548))
([1ba07c1](1ba07c1))
* **roadmap:** the implement shell waits for its command
([#4536](#4536))
([571e044](571e044))
* **roadmap:** the module-test and caller gates read imports and calls
([#4490](#4490))
([8a22e82](8a22e82))
* **service:** put trace ids on Service JSON log lines
([#4511](#4511))
([0d7a0d2](0d7a0d2))


### Performance Improvements

* **ai:** keep intake embeddings between CLI runs
([#4546](#4546))
([812871e](812871e))
* **roadmap:** intake reads only the issues that changed
([#4552](#4552))
([7dfd155](7dfd155))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): runner agent polls output.log after 270 s

1 participant