Repository navigation
Description
Problem or Motivation
In src/devops_cli/roadmap/implement/implement_step.py, an agent runs turns until it stops or until limits stop it.
When an agent completes all tasks of its task group, it ticks each task in tasks.md. WipKeeper verifies each ticked task.
In issue #3253 (pull request #4035), the agent completed task 1.1 and task 1.2 in 18 seconds. Both tasks passed verification. tasks.md held no unticked task for group 1.
The agent did not stop. It executed more tool calls across many turns. Each turn sent the full prompt context of 140,000 tokens. The step spent its full budget of 8,000,000 tokens (roadmap.implement.step_token_budget=8000000) and stopped with limit_reached.
The job marked issue #3253 blocked, although all tasks of the group were complete and verified.
Proposed Solution & Architectural Design
- Add a check in
implement_step.pythat inspectskeeper.tasks_fileor the group task list after each turn. - When every task of the assigned group is ticked and verified:
- Provide an instruction in the next turn message: "All tasks of group {number} are ticked and verified. Provide your summary now and call no further tools."
- If the agent calls more tools without unticking or changing code, stop the agent loop cleanly and start the step exit checks.
- Update
src/devops_cli/ai/tasks/roadmap_implement_step.mdto state clearly:
"When all tasks of your group are ticked and their verification commands pass, stop tool calls and write your final summary."
Target Subsystem
AI & Agentic Review Pipeline
Existing Tool Considered
PydanticAI agent run loop controls. Building this check in implement_step.py requires approximately 10,000 tokens to implement and test.
Standards Compliance
- I confirm this proposal aligns with AGENTS.md engineering principles (cyclomatic complexity <= 10, nesting <= 5, zero bare exceptions, tests that cover the changed lines).
- I am willing to submit a pull request implementing this feature with accompanying tests.
Source: #3253
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)
Alternatives check of 2026-11-25: in-use.
The repository already uses this tool.
Tool: pydantic-ai (https://pypi.org/project/pydantic-ai), MIT, last activity 2026-11-25, maintained.
Reason: Searches found no library that detects a complete OpenSpec task group; PydanticAI, already used, supplies only run-loop hooks and limits, so the completion policy, the final instruction and the prompt rule must be written.
Covers:
- Agent run loop with request and token limits
- Hooks that run before each model request
- Ends a run through an exception from a hook
Lacks:
- No notion of a ticked and verified task group
- No check that a task group is complete
- No instruction that asks the agent for its summary
Proposed design
Problem statement
The implement step continues to send model requests after the agent ticks every task of its group. Each request resends a prompt of about 140,000 tokens. A completed group can spend the full step token budget and stop with limit_reached, which marks a complete item blocked. The change detects a ticked and verified group before a request, adds one final instruction, and ends the loop before the next request so the exit checks and the commit still run.
Acceptance criteria
Requirement: Completion check before a request
The implement step SHALL treat the assigned group as complete before a model request when every task of the group is ticked and each verification command of the group passes.
Scenario: Every task of the group is ticked and verified
- WHEN A step runs with a scripted model that ticks every task of group 1 and whose group verification command exits 0, and the before-request check runs.
- THEN The check reports group 1 as complete before the next model request is sent.
Requirement: One final instruction
The step SHALL add exactly one final instruction to the next model request after it marks the group complete.
Scenario: Final instruction in the next request
- WHEN The check marks group 1 complete and the step has sent no final instruction for that group.
- THEN The next request carries one part with the text
All tasks of group 1 are ticked and verified. Provide your summary now and call no further tools., and a second before-request check adds no second part.
Requirement: Stop after the final instruction
The step SHALL end the agent loop before the next model request when every task of the group stays ticked after the final instruction.
Scenario: The agent calls a tool after the final instruction
- WHEN The scripted model answers the final instruction with a tool call and leaves every task of group 1 ticked.
- THEN The run ends with an empty failure reason, and
run_stepruns the exit checks and commits the group when they pass.
Requirement: Untick keeps the loop running
The step MUST NOT end the agent loop when the agent unticks a task of the group after the final instruction.
Scenario: The agent unticks a task
- WHEN The scripted model unticks one task of group 1 after the final instruction and sends another request.
- THEN The check reports group 1 as incomplete, the request is sent, and the run records no stop.
Requirement: Prompt states the stop rule
The implement prompt SHALL tell the agent to stop tool calls and write its final summary when every task of its group is ticked and its verification commands pass.
Scenario: Prompt text
- WHEN A test calls
load_task_promptforroadmap_implement_step.mdwith the tools table of the step. - THEN The returned prompt text holds the sentence
When all tasks of your group are ticked and their verification commands pass, stop tool calls and write your final summary.
Existing Tool Considered
pydantic-ai (https://pypi.org/project/pydantic-ai), MIT, maintained, verdict in-use: the repository already uses it. The alternatives check in the issue body holds what the tool covers and what it lacks. The change writes the completion policy on the existing before_model_request hook and the RequireVerification and WrapUpAtLimits capabilities. The repository builds and keeps that policy: about 10,000 tokens to write and test it, plus upkeep, and about one working day.
Key questions
- Where does the step check for a complete group?: Before each model request, in a
before_model_requesthook added besidelimit_hooksandToolCallLog.hooks. The hook runs before the full prompt goes out. (best practice) [sources: src/devops_cli/roadmap/implement/implement_limits.py, src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/roadmap/implement/implement_tool_log.py]- Chosen: Before each model request. The hook runs at the only point before a full prompt goes out, and the step already stops a run there with
LimitReached. - Rejected: After each
run_syncturn. A turn holds many model requests, so the step would still send extra full prompts. - Rejected: Only in the prompt. The model ignored the prompt in issue feat(roadmap): map all issue requirements to a group #3253.
- Chosen: Before each model request. The hook runs at the only point before a full prompt goes out, and the step already stops a run there with
- How does the step know that every task of the group is ticked and verified?: The new completion state re-parses the group from
tasks.mdwithparse_task_groups, readsGroupTask.ticked, and runs the group verification commands once withcommands_failureafter every task is ticked. It records the run inlog.verified, the same record that the exit check reads. (best practice) [sources: src/devops_cli/roadmap/step_files.py, src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/roadmap/implement/implement_tool_log.py]- Chosen: Re-parse the tasks file and run verification once. The step already owns the file and the verification commands, and the exit check uses the same two sources.
- Rejected: Read
StepInputs.groupalone. It is the group text from before the run, so it never shows the ticks the agent writes. - Rejected: Trust the ticks alone. A tick does not show that the verification command passed.
- Rejected: Re-run every verification before each request. It repeats expensive commands at every request and duplicates the exit check.
- What does the step do when the group becomes complete?: The hook adds one final instruction to the pending request and stops on the next request. It returns the request context with one extra
UserPromptPart, records that it sent it, and raises a completion exception before the next request when the group is still complete. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/ai/tasks/roadmap_implement_step.md]- Chosen: One final instruction in the pending request, then stop. It gives the agent one chance to write the summary, bounds the extra cost to one request, and uses one hook for both the instruction and the stop.
- Rejected: Stop at once. The step loses the summary that the prompt asks for.
- Rejected: A second
_run_turnwith the message. It ends the run first and starts a second one, so the instruction and the stop need two paths. - Rejected: Run until a limit. It spends the token budget and marks a complete item blocked, as issue feat(roadmap): map all issue requirements to a group #3253 shows.
- How does the step end the agent loop with no failure reason?: The hook raises a private completion exception.
_run_turncatches it beside its handlers and returns a_Runwith an emptyreasonand nofailure_class, so_attemptruns the exit checks and the done path. (best practice) [sources: src/devops_cli/roadmap/implement/implement_limits.py, src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/roadmap/failure.py]- Chosen: Private completion exception. It ends the loop before the next request and keeps the exit checks and the done path.
- Rejected: Raise
LimitReached. It classifies the stop aslimit_reachedand blocks the item. - Rejected: Let the agent end on its own. The agent can continue for many turns and spend the full budget, as issue feat(roadmap): map all issue requirements to a group #3253 shows.
- What does the implement prompt say?: Add one sentence to
src/devops_cli/ai/tasks/roadmap_implement_step.md: when every task of the group is ticked and its verification commands pass, stop tool calls and write the final summary. The code guard enforces it. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_implement_step.md, src/devops_cli/ai/task_loader.py]- Chosen: Add the stop sentence to the prompt. The prompt is the instruction of the agent, and the code guard enforces it.
- Rejected: Change the prompt only. The prompt alone did not stop the agent in issue feat(roadmap): map all issue requirements to a group #3253.
- Rejected: Change the code only. The agent would not know why the step stops before its summary.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.The step wastes 8 million tokens and marks a complete job as blocked, but the work is not lost and a person can re-run the step.It stops token burn and prevents a false blocked status when all tasks are already verified.The body estimates roughly 10,000 tokens of code and tests across implement_step.py and the prompt file.Both concern the implement step created by #2664, but #2664 builds the step while the candidate adds a halt condition when all group tasks are verified.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at c8990be (see proposed design in issue body).
devops-cli-service commentedon Nov 10, 2026
Alternatives check: partly
Reason: PydanticAI is an open, maintained agent framework that provides the run loop and the before-request hook this change would build on. The one search for a ready-made "halt when all tasks verified" tool returned nothing relevant. No tool covers the OpenSpec task-group completion policy, so the project has to write that part itself. No ADR rejects PydanticAI. The issue does not name it as in use, only as the "Existing Tool Considered".
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.
6 remaining items
devops-cli-service commentedon Nov 20, 2026
Owner question: The inputs of the step of the task group "End the loop with one final instruction when the group is complete" hold 64313 tokens, over the budget of 64000 tokens, also after the model split the groups once. Split the group or raise the budget of the step?
Options
Recommendation: Split the group: the plan check keeps the budget of the step.
Evidence
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.
dan-petty commentedon Nov 24, 2026
Split the group.
devops-cli-service commentedon Nov 25, 2026
The result in the alternatives block of the issue body changed. Before this check:
in-use, tool https://github.com/pydantic/pydantic-ai. A person decides what the new result means for the item.Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 26, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.
devops-cli-service commentedon Nov 28, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.