- Questions never change state (L5, #77): a message ending in "?" to a waiting project item starts a question run (reply and look-only tools, an instruction to change nothing), and the item goes back to the very wait it was in: a restatement up stays up and a go binds to it; the agent's own question stays open. - Explanations: a restatement gives its reasons and the main alternative; a revision says what changed (restate(changed), sent back without it); a milestone's summary says what was done, verified and left open. - Progress in prose (#42): the driver's and a helper's own words for a turn are posted, trimmed, at most once a minute per item; `details` shows the last tool calls; a message arriving mid-run is acknowledged at once ("Noted; ..."). - CI: the e2e job's comments and the plan no longer claim a newer push cancels the run it supersedes (Gitea here doesn't); the concurrency block goes. Tests: conversation unit tests (questions in a go-ahead and an answer wait, an unanswerable question, revisions, progress rate and trimming, details, mid-run notes), the helper's progress, the walk asking questions in every state with a questions_change_nothing property (routing questions the old way fails 32 of 48 seeds), and an e2e question while a restatement is up. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
121 lines
4.4 KiB
Python
121 lines
4.4 KiB
Python
"""Control tools (L13): handled in the harness, acting only on the agent's
|
|
own state, conversation and records. A *waiting* tool ends the driver's run:
|
|
the item then waits on the operator."""
|
|
|
|
from typing import Any
|
|
|
|
|
|
def _tool(tool: str, description: str, /, **params: str) -> dict[str, Any]:
|
|
return {
|
|
"type": "function",
|
|
"function": {
|
|
"name": tool,
|
|
"description": description,
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
p: {"type": "string", "description": d} for p, d in params.items()
|
|
},
|
|
"required": list(params),
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
RESTATE = _tool(
|
|
"restate",
|
|
"Put your understanding of the request to the operator, in their item's "
|
|
"thread: what you take it to mean, how it fits the project, your first "
|
|
"step, and why that way (and the main alternative you considered). Ends "
|
|
"your turn; work starts when they agree.",
|
|
text="Your restatement, in plain language.",
|
|
changed="What changed from your previous restatement, and why; leave it "
|
|
"empty for the first.",
|
|
)
|
|
ASK_HUMAN = _tool(
|
|
"ask_human",
|
|
"Ask the operator a question in the item's thread. Ends your turn; you "
|
|
"continue when they answer.",
|
|
question="The question.",
|
|
)
|
|
CLOSE_ITEM = _tool(
|
|
"close_item",
|
|
"The work is done: close the work item with a summary of what was done, "
|
|
"what was verified, and what is left open.",
|
|
summary="What was done, verified, and left open.",
|
|
)
|
|
|
|
START_MILESTONE = _tool(
|
|
"start_milestone",
|
|
"Start a milestone before changing code: the harness cuts its branch. "
|
|
"Never create or switch branches yourself.",
|
|
name="A short name for the milestone.",
|
|
)
|
|
FINISH_MILESTONE = _tool(
|
|
"finish_milestone",
|
|
"The milestone's work is done and its tests pass: the harness commits "
|
|
"the work, pushes it and opens a PR, or, after review comments, pushes "
|
|
"your fix to the PR. Ends your turn; you continue when the PR is "
|
|
"reviewed or merged.",
|
|
summary="What the milestone did and how it was verified, for the PR.",
|
|
title="A short title for the PR (ignored when pushing a review fix).",
|
|
final="yes if this milestone completes the issue, no if more milestones follow it.",
|
|
)
|
|
WAIT_FOR_REVIEW = _tool(
|
|
"wait_for_review",
|
|
"Nothing more to do until the operator reviews or merges the PR (you "
|
|
"can't merge it yourself): say so and wait. You continue when there's a "
|
|
"new comment, or when it merges or closes.",
|
|
note="What you're waiting on, for the operator.",
|
|
)
|
|
|
|
# A conversation's tools (L1, L5): it talks, and may propose work.
|
|
REPLY = _tool(
|
|
"reply",
|
|
"Answer the operator in the conversation's thread. Ends your turn; you "
|
|
"continue when they say more.",
|
|
text="Your answer, in plain language.",
|
|
)
|
|
PROPOSE_WORK = _tool(
|
|
"propose_work",
|
|
"The conversation has turned into work on one of the projects: propose "
|
|
"an issue for it. The operator agrees to it as to a restatement; then the "
|
|
"issue is opened, and work on it starts as its own item. Ends your turn.",
|
|
project="The project's name, from the list in your instructions.",
|
|
title="A short title for the issue.",
|
|
summary="What was decided, distilled: the request, what it means, and the "
|
|
"first step. Not the conversation; it is the issue's body and the work's "
|
|
"whole brief.",
|
|
)
|
|
|
|
PROPOSE_PROJECT = _tool(
|
|
"propose_project",
|
|
"The conversation has become a new project: propose it. The operator "
|
|
"agrees to it as to a restatement; then you list what it needs set up "
|
|
"(a repository, a build VM, the project's entry), and once it is ready "
|
|
"and checked, the project's architecture is your first piece of work. "
|
|
"Ends your turn.",
|
|
name="The project's name: lowercase letters, digits and -.",
|
|
purpose="What it is for, in a paragraph.",
|
|
decisions="The decisions setting it up depends on: language and toolchain "
|
|
"(which pick the build VM), services, secrets, network access beyond the "
|
|
"default; and anything else agreed so far.",
|
|
)
|
|
|
|
WAITING = frozenset(
|
|
{
|
|
"restate",
|
|
"ask_human",
|
|
"close_item",
|
|
"finish_milestone",
|
|
"wait_for_review",
|
|
"reply",
|
|
"propose_work",
|
|
"propose_project",
|
|
}
|
|
)
|
|
|
|
|
|
def names(tools: list[dict[str, Any]]) -> set[str]:
|
|
return {tool["function"]["name"] for tool in tools}
|