Repository navigation
Description
Problem or Motivation
The implement agent keeps asking its shell for programs outside the allowlist, and each refusal counts against the tool retry limit of 5. The run then ends and the job discards the work. Evidence from the first Jobs on 0.22.x, 2026-10-30:
- fix(config): config files and their copies keep the mode of the file, never 0644 #2745, Job
devops-cli-runner-20261030-132149-34ad: the stop reason is "UnexpectedModelBehavior: Tool 'shell' exceeded max retries count of 5 ... Refused commands: 6. Other retries: 1." The log shows sixshell, program other, refusedlines in a row. The agent had already written a correct test file for_write_content. - fix(config): devops config unset stops with a TypeError for a key that a YAML merge key gives #2656, Job
devops-cli-runner-20261030-130645-dc17: fourshell, program other, refusedlines among about 30 tool calls.
The shell allows git, uv, ruff and mypy. The step prompt says so and says to run project commands with uv run, for example uv run devops ci test <file>. The model does not follow it. The log writes any other first word as "other" (#2758 did this on purpose so that no model-written string reaches the log), so nobody can see which program the model wants. The likely ones are python, pytest, cd, cat, ls and pip, but nothing proves it.
Proposed Solution & Architectural Design
- The prompt (
roadmap_implement_step.md) gets a short table of what to use in place of each habit:pythonandpytestbecomeuv run pythonanduv run pytest;cat,ls,grep,findandheadbecome the toolsread_file,list_filesandgrep;cdis not needed because every command runs in the checkout;pipandpython -m pipare not allowed, and the dependencies come from the lockfile. The table sits next to the allowlist line, and a test pins the table toIMPLEMENT_SHELL_PROGRAMS, so the two cannot drift. - The refusal that the model reads tells it the replacement. Find, in the installed
pydantic-ai-harnessShellorCoder, whether the refusal text can be set; if it can, it names the allowed programs and theuv runform. If it cannot, a thin wrapper of the shell tool in the project turns a refusal into that text without changing what is allowed. - The Job log names the program of a refused command when it is a bare word: it matches
[A-Za-z][A-Za-z0-9_.-]{0,23}. Anything else stays "other". The shell has no credential in its environment (the job keeps the token in its own process), so a bare word cannot be a secret that the model knows. The stop reason counts the refused commands by program, for example "Refused commands: python 4, cd 2".
Target Subsystem
src/devops_cli/ai/tasks/roadmap_implement_step.md, src/devops_cli/roadmap/implement_step.py, src/devops_cli/roadmap/implement_tool_log.py, src/devops_cli/lang/en/messages.py.
Existing Tool Considered
pydantic-ai-harness Shell (the allowlist and its refusal text) and the project's tool-call log of #2758. Nothing new is built unless the refusal text cannot be set.
Acceptance criteria
- With the model faked as a
FunctionModelthat callspythonandcd, the refusal text that the model receives names the replacement, and the stop reason counts the refused commands by program. - The log line for a refused bare word shows the word; a refused string with a space, a path, a quote or more than 24 characters shows "other".
- A test fails when the prompt table and
IMPLEMENT_SHELL_PROGRAMSdisagree. uv run devops cipasses, anddevops docs generate --sync-readmeis run.
Evidence: the stop comments on #2745 (13:24 UTC) and #2656 (13:14 UTC), and the two Job logs.
Proposed design
Problem statement
The implement agent's shell allows only git, uv, ruff and mypy. The model keeps calling other programs, and each refusal counts against the tool retry limit of 5. The run ends and the job discards the work. The log writes 'other' for every non-allowlisted first word, so a person cannot see which program the model wants. The refusal text the model reads does not name the replacement.
Acceptance criteria
Requirement: Prompt table of replacements
The prompt roadmap_implement_step.md SHALL contain a table of replacements for common shell habits, placed next to the allowlist line, and a test SHALL fail when the table and IMPLEMENT_SHELL_PROGRAMS disagree.
Scenario: Table and allowlist drift
- WHEN A test modifies IMPLEMENT_SHELL_PROGRAMS without updating the table in the prompt
- THEN The test fails with a message that names the disagreement
Requirement: Refusal text names the replacement
The refusal text that the model receives for a refused shell command SHALL name the allowed programs and the uv run form of the replacement.
Scenario: Model calls a refused program
- WHEN A FunctionModel calls shell with 'python -c print(1)'
- THEN The refusal text the model receives names 'uv run python' as the replacement
Requirement: Log names bare words
The log line for a refused shell command SHALL show the first word when it matches [A-Za-z][A-Za-z0-9_.-]{0,23}, and SHALL show 'other' when it does not.
Scenario: Refused bare word versus refused path
- WHEN A FunctionModel calls shell with 'python -c print(1)' and then with '/usr/bin/python -c print(1)'
- THEN The first log line shows 'python' and the second shows 'other'
Requirement: Stop reason counts by program
The stop reason of a step that ends on tool retries SHALL count the refused commands by program name, for example 'Refused commands: python 4, cd 2'.
Scenario: Multiple refusals of different programs
- WHEN A FunctionModel calls shell with 'python' four times and 'cd' two times, exceeding the retry limit
- THEN The stop reason contains 'Refused commands: python 4, cd 2'
Requirement: CI and docs pass
uv run devops ci SHALL pass, and devops docs generate --sync-readme SHALL produce no diff.
Scenario: Full CI gate
- WHEN The change is committed and uv run devops ci is run
- THEN All checks pass and devops docs generate --sync-readme writes no change
Existing Tool Considered
No check has run. The existing tool is pydantic-ai-harness Shell, which provides the allowlist and the refusal mechanism. It lacks a settable refusal text that names the replacement for each refused program, and it does not log the specific program name of a refused command. The project's ToolCallLog writes 'other' for any non-allowlisted first word. The change adds a thin wrapper for the refusal text when Shell cannot set it, and changes the project's log to name bare words and count refusals by program.
Key questions
- What replacements does the prompt table list?: python and pytest become uv run python and uv run pytest; cat, ls, grep, find and head become the tools read_file, list_files and grep; cd is not needed because every command runs in the checkout; pip and python -m pip are not allowed, and the dependencies come from the lockfile. (best practice) [sources: src/devops_cli/config/commands.py:59, src/devops_cli/ai/tasks/roadmap_implement_step.md]
- Chosen: Table in the prompt next to the allowlist line. The model reads the prompt before it acts. A table there prevents the first refusal. A test pins it to IMPLEMENT_SHELL_PROGRAMS so the two cannot drift.
- Rejected: Only in the refusal text. The refusal text is seen only after a refusal, so the model has already spent a retry. It does not prevent the first refusal.
- How does the log identify a bare word it may show?: The first word of the command is shown when it matches [A-Za-z][A-Za-z0-9_.-]{0,23}. Anything else, such as a path, a quote, an assignment, or a word longer than 24 characters, is shown as 'other'. The shell has no credential in its environment, so a bare word cannot be a secret. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:470, src/devops_cli/roadmap/implement_tool_log.py, CONTEXT.md]
- Chosen: Show the bare word when it matches a safe pattern. The shell environment has no token or secret. shell_environment sets only HOME, XDG_CONFIG_HOME, GIT_CONFIG_NOSYSTEM, GIT_TERMINAL_PROMPT, UV_CACHE_DIR and UV_PYTHON. A bare word of at most 24 characters from [A-Za-z0-9_.-] cannot be a path, an assignment, or a secret.
- Rejected: Always show 'other' for non-allowlisted words. This is the current behavior. It hides the program name, so a person cannot see which program the model keeps asking for.
- How does the stop reason count refused commands?: The stop reason counts the refused commands by program name, for example 'Refused commands: python 4, cd 2'. The ToolCallLog keeps a Counter of program names for refusals instead of a single integer. (best practice) [sources: src/devops_cli/roadmap/implement_tool_log.py, src/devops_cli/lang/en/messages.py]
- Chosen: Count by program name in a Counter. A person sees at once which program the model kept asking for, and how often. The current single integer hides this.
- Rejected: Keep a single integer count. This is the current behavior. It does not show which program was refused, so a person cannot fix the cause.
Open questions
- Can the refusal text of pydantic-ai-harness Shell be set to name the allowed programs and the uv run form? (missing verified source)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 30, 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.The agent loses work on multiple jobs, but a re-run recovers it and no data is corrupted.It stops recurring job failures and saves the work the agent already produced.It spans a prompt file, a log module, a messages file, and a possible shell wrapper, with tests for each.Both touch the implement step shell log and stop reason, but #2758 fixed the stop reason to show the exception message while the candidate fixes the prompt, refusal text, and bare-word logging.devops-cli-service commentedon Oct 30, 2026
Refine cannot set this item to Ready at d264e6e until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
chore(main): release 0.22.4 (#2785)