Repository navigation
Description
Problem Description
The implement step answers a refused shell command with a hint that does not fit the refused form, and the hint names a directory that does not exist. The model then sends the same form again, or it stops after 3 refusals in a row.
Evidence (Loki, implement runner, 17 runs, 2026-11-10 to 2026-11-13):
- 71 refusals in 1,231 shell calls (5.8%) in 14 runs.
python -ccode with;or a new line: 27 in 10 runs.gitwith&&: 15, and with|to a program that is not allowed: 2, in 9 runs.lswith;: 2. gititself is allowed: 322 of 339gitcalls passed.- After a
python -crefusal, the model sent the same form again in 17 of 27 cases (7 of them were refused again). After agit ... &&refusal, it sentread_file9 times and onegitcommand only 2 times. - An earlier review counted 175 refusals in 4,823 shell calls in 37 of 37 runs, and 13 stops after 3 refusals in a row. Each stop loses a full paid run.
- 14
uv run python -c '...mkdir...'calls in 9 runs, 13 of them followed by a passingwrite_file. 3write_fileretries with "Parent directory ... does not exist" in 3 runs.
Causes in the code on main (0.129.1):
refusal_hint(src/devops_cli/roadmap/implement/implement_shell_refusal.py, lines 52-62) selects the text from the first word only. Souv run python -cwith;andgit status && git logget the same text,implement_refusal_operator(src/devops_cli/lang/en/messages.py, lines 3223-3229). That text starts with "Run one command in each call. Do not chain commands", and the instruction about the file comes last.- That text, and the prompt, send the model to
.data/agent/scratch/. A fresh checkout does not have this directory. - The step offers
read_file,write_file,edit_file,list_files,grepandrun_command(IMPLEMENT_LOCAL_TOOL_NAMES,src/devops_cli/roadmap/implement/implement_step.py, line 641). It leaves out thecreate_directorytool of pydantic-ai-harness 0.59.0, which the lock file already holds. src/devops_cli/ai/tasks/roadmap_implement_step.md, lines 40 and 59, tell the model to make a directory withuv run python -c '...mkdir...'. So the 14 mkdir calls follow the prompt.- The pipe refusal names
head,tail,grepandwc, notread_filewithoffsetandlimit.
Expected vs Actual Behavior
Expected: the hint names the exact next call for the refused form, and every path that it names exists. Actual: one generic text for all operator refusals, and a missing directory.
Proposed Solution
- The job makes
.data/agent/scratch/(git-ignored) in the checkout before step 1. - The step offers the harness tool
create_directory. Change lines 40 and 59 ofroadmap_implement_step.mdto namecreate_directory, and remove thepython -cmkdir text. refusal_hintselects the text from the refused form, not only from the first word:python -cwith;, a new line or a heredoc: "Write the code withwrite_fileto.data/agent/scratch/<name>.py, then runuv run python .data/agent/scratch/<name>.py." This text comes first.- A chain with
&∨of allowed programs: "Send each command as its own call, for examplegit status --short, thengit log --oneline -5." - A pipe to a program that is not allowed, such as
sed: "Useread_filewithoffsetandlimit."
- Add
SHELL_REFUSALSrows foropenspecand a baredevops, which nameuv run devops openspec checkanduv run devops.
This item changes only the hint text, the scratch directory and the tool list. It changes no allowlist and no operator rule. The parser and the split of chained commands stay in #5201.
Acceptance Criteria
- A test (written first, fails on the base) gives
refusal_hinta refuseduv run python -c "a=1; print(a)"and proves that the text starts with thewrite_fileinstruction. - A test gives a refused
git status && git logand proves that the text names two separate calls. - A test proves that the step offers
create_directoryand that the job makes.data/agent/scratch/before step 1. - A test proves that the prompt holds no
python -cmkdir text. -
uv run devops ci fail-to-pass --base origin/mainshows that the new tests fail on the base. - Measure in telemetry, 7 days after the release (runner log lines in Loki): refusals per implement run go down from about 4, a repeat of the same refused form after its hint goes to 0, stops after 3 refusals in a row go to 0, and
python -cmkdir calls go to 0.
Existing Tool Considered
pydantic-ai-harness create_directory (0.59.0, already locked) for the directory. The hint is project text in the existing _RefusingToolset wrapper, which already removes a cd <checkout> && prefix by itself. No new tool. Cost to build (estimate): 0.2 M model input and output, and 2 to 3 hours. Cost to keep: one hint per refused form.
Related
#5201 (shell parser, parent), #5180 (refusal ranking), #5179 (tool error classes).
Source: #5201
Proposed design
Problem statement
The implement step answers a refused shell command with a hint selected from the first word only, so uv run python -c code with a separator and git status && git log get the same text, and the instruction about the file comes last. That text, and the prompt, send the model to .data/agent/scratch/, which a fresh checkout does not have, and the prompt tells the model to make a directory with uv run python -c. The model then sends the same form again, or it stops after three refusals in a row. The change selects the hint from the whole refused form, creates the scratch directory in the job, registers a create_directory tool (the locked harness 0.59.0 has none), and removes the python -c mkdir text from the prompt.
Acceptance criteria
Requirement: Python code refusal names write_file first
The refusal hint for a python -c command that holds ;, a new line or a heredoc SHALL start with the write_file instruction for a file under .data/agent/scratch/ and then give the uv run python command.
Scenario: Refused python -c with a separator
- WHEN
refusal_hintreceives the whole commanduv run python -c "a=1; print(a)", a form with a new line, and a heredoc form. - THEN Each returned text starts with the
write_fileinstruction and names.data/agent/scratch/anduv run python.
Requirement: Allowed command chain names separate calls
The refusal hint for a chain of allowed programs with && or ; SHALL name each command as its own call and SHALL give an example of two calls.
Scenario: Refused git chain
- WHEN
refusal_hintreceivesgit status && git log. - THEN The returned text names
git status --shortandgit log --oneline -5as separate calls.
Requirement: Pipe refusal names read_file
The refusal text for a pipe to a program that the shell does not allow SHALL name read_file with offset and limit.
Scenario: Refused pipe to sed
- WHEN
pipe_refusalreceivesgit status | sed -n 1,20p. - THEN The returned text names
read_filewithoffsetandlimitand still names the program after the pipe.
Requirement: Implement step offers create_directory
The implement step SHALL register a create_directory tool that creates a directory inside the checkout.
Scenario: Tool list includes create_directory
- WHEN The implement tool names are read and the local tool set of the agent is built.
- THEN
create_directoryis inIMPLEMENT_LOCAL_TOOL_NAMES, the agent offers it, and a call with a path outside the checkout is refused.
Requirement: Job creates scratch directory
The implement job SHALL create .data/agent/scratch/ in the checkout before it builds the inputs of the first step.
Scenario: Fresh checkout has the scratch directory
- WHEN The implement job starts a run in a clean checkout with no
.data/agent/scratch/. - THEN The directory exists before the first model request, and
git check-ignore .data/agent/scratch/reports it ignored.
Requirement: Prompt names create_directory
The implement prompt SHALL name create_directory for a new directory and SHALL hold no python -c mkdir text.
Scenario: Prompt text has no mkdir shell command
- WHEN The prompt
roadmap_implement_step.mdis rendered for a step. - THEN The text names
create_directoryand holds nopython -ccommand that callsmkdir.
Requirement: Refusal table names openspec and devops
SHELL_REFUSALS SHALL hold a row for openspec that names uv run devops openspec check and a row for a bare devops that names uv run devops, and docs/ROADMAP_WORKFLOW.md SHALL show the same rows.
Scenario: Refusal table rows for project commands
- WHEN
SHELL_REFUSALSand the refusal table ofdocs/ROADMAP_WORKFLOW.mdare read. - THEN Both hold an
openspecrow withuv run devops openspec checkand adevopsrow withuv run devops.
Requirement: New tests fail on base
Each new test for the refusal hints, the tool list, the scratch directory and the prompt MUST fail on the base commit.
Scenario: Fail-to-pass replay
- WHEN
uv run devops ci fail-to-pass --base origin/mainruns. - THEN The command reports that each new test failed on the base commit and passes on the change.
Existing Tool Considered
No alternatives list was given. The locked pydantic-ai-harness 0.59.0 (pyproject.toml:41) covers the file tools and the shell, but it has no create_directory: Coder gives six tools, and its write_file creates no directory (src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai_harness.md:34, :59), and mkdir is not on the shell allowlist either (openspec/changes/archive/2026-10-29-2664-roadmap-implement-step/design.md:14). It also has no setting for the refusal text. The project therefore builds a small create_directory tool (a pydantic-ai function tool that refuses a path outside the checkout) and the hint text in _RefusingToolset: about 60 lines of code and 150 lines of tests, about 0.15 M model input and output tokens and 3 hours of elapsed time. Cost to keep: one tool and one hint per refused form.
Key questions
- How should the hint choose the replacement text for a refused command?: Pass the whole refused command to
refusal_hintand match it in a fixed order. Apython -ccommand with;, a new line or a heredoc gets thewrite_filetext first, before the text of the shell. A chain of allowed programs gets the separate-call text. The pipe text stays inpipe_refusal, which already reads the stages, and namesread_filewithoffsetandlimitwhen a stage is not allowed. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_refusal.py:52, src/devops_cli/lang/en/messages.py:3235, src/devops_cli/roadmap/implement/implement_shell_policy.py:327, docs/ROADMAP_WORKFLOW.md:286]- Rejected: First word only. It gives the same operator text to
python -candgit status && git log, and it puts the file instruction last. - Chosen: Whole-form match with ordered rules. It selects the exact next call for each refused form, puts the file instruction first for
python -c, and leaves the pipe text in the function that reads the stages. - Rejected: Model-generated hint. It is not deterministic for an offline test and adds a model request to each refusal.
- Rejected: First word only. It gives the same operator text to
- How should the step create a directory?: The locked pydantic-ai-harness 0.59.0 has no
create_directory:Codergives six tools,write_filecreates no directory, andmkdiris not on the shell allowlist. So the job creates.data/agent/scratch/before step 1, the step registers a small projectcreate_directorytool for any other new directory, and the prompt names that tool and drops thepython -cmkdir text. (best practice) [sources: src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai_harness.md:34, src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai_harness.md:59, openspec/changes/archive/2026-10-29-2664-roadmap-implement-step/design.md:14, src/devops_cli/roadmap/implement/implement_step.py:648, src/devops_cli/ai/tasks/roadmap_implement_step.md:40, src/devops_cli/ai/tasks/roadmap_implement_step.md:59]- Rejected: Harness
create_directory. It does not exist in 0.59.0:Codergives six tools and the knowledge page states thatwrite_filecreates no directory. - Chosen: Project
create_directorytool. The step can register a small pydantic-ai function tool, and the tool refuses a path outside the checkout. - Rejected:
python -cmkdir in the prompt. The model adds a;or a new line, and the shell refuses it; the evidence shows the repeated refusals and the failedwrite_fileretries. - Rejected: Shell
mkdir.mkdiris not on the allowlist, and this change keeps the allowlist as it is.
- Rejected: Harness
- Should the scratch directory stay at
.data/agent/scratch/?: Yes. The job creates.data/agent/scratch/, and the prompt keeps scratch files there, because the repository ignores that path. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_implement_step.md:40, AGENTS.md:18]- Chosen:
.data/agent/scratch/. The prompt already names it as the git-ignored scratch path,.gitignoreignores.data/*, and the job can create it before step 1. - Rejected: The checkout root. The step commits every file in the checkout root, so a scratch file there reaches a commit.
- Rejected: A system temporary directory. It is outside the checkout, so
write_fileanduv run python <file>cannot use it as the prompt describes.
- Chosen:
- Should
SHELL_REFUSALSgain rows foropenspecand a baredevops?: Yes. Addopenspec->uv run devops openspec checkanddevops->uv run devops, so each refusal names the exact project command, and render the same rows indocs/ROADMAP_WORKFLOW.md. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py:199, docs/ROADMAP_WORKFLOW.md:286]- Chosen: Add both rows. The table then gives the exact replacement for each refused project command, and a test keeps the document equal to the table.
- Rejected: Keep only the generic allowed-program list. The generic list does not name the command that replaces
openspecor a baredevops. - Rejected: Add only
openspec. A baredevopsstill gets no exact replacement.
- Should the post-release telemetry measurement stay in this item?: Yes. It stays in the item as a check that only a person can run: the change's
tasks.mdcarries it as a plain bullet startingPending a person:with the Loki query, the date window and the release version, and the stage job maps that criterion topending-personwith a reason. It is not a code requirement and not a new issue. (best practice) [sources: docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md:113, docs/ROADMAP_WORKFLOW.md:348]- Chosen: A
Pending a person:bullet in the change's tasks.md. The project records this form for a check only a person can run, and the stage job maps the criterion topending-personwith a reason. - Rejected: A separate issue. A follow-up issue is for work the item will not do; this measurement is the item's own post-release check.
- Rejected: An offline acceptance criterion. No offline test can read Loki 7 days after a release, and the stage gate has no group for it.
- Chosen: A
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
The bug causes 71 refusals in 17 runs, model loops on the same form, and 13 stops that each lose a full paid run.Both address refused command patterns (python -c with ;, git with &&) and propose safe alternatives, but the candidate fixes the hint text selection and tool list while #5180 ranks refusals and proposes tool changes as a broader feature.devops-cli-service commentedon Nov 14, 2026
Status set to Ready at 1eb3ea4 (see proposed design in issue body).
3 remaining items
docs(openspec): plan #5452 Fit each refusal hint to the refused command
docs(openspec): plan #5452 Fit each refusal hint to the refused command
docs(openspec): plan #5452 Fit each refusal hint to the refused comma…
devops-cli-service commentedon Nov 14, 2026
Released in v0.142.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.142.1
devops-cli-service commentedon Nov 14, 2026
Live since 2026-11-14 21:08 UTC