Skip to content

Sonny: the six agent-only commands become tools the lookout answers - #268

Merged
lydakis merged 17 commits into
mainfrom
claude/project-thread-qzgtqy
Oct 28, 2026
Merged

lydakis merged 17 commits into
mainfrom
claude/project-thread-qzgtqy

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

George asked what a CLI buys us when only an agent calls it. The rule he picked: when an agent talks to Sonny, it uses a tool; a command exists only for callers that aren't Sonny agents. #248 added answered declared tools to the daemon, and #256 let tasks read their siblings' history. This PR is the last step: it moves Sonny's six agent-only commands to tools and deletes the command forms.

What changes

Was Now (tool) Who has it Gated
sonny task start start_task {name, brief, profile?, setup?, model?, effort?} lead yes
sonny task rm remove_task {task, discard?} lead yes
~/.agent/project add new_project {folder, model?, effort?, threads_model?, threads_effort?, threads_in?} lead yes
sonny lookout ls/add/rm subscriptions {add?, remove?} (empty lists them) lead yes
sonny show show_agent {agent, split?, beside?} every agent no
sonny run run_in_pane {name, command, cwd?, split?} every agent yes
  • Answered by the lookout.
    • All six are declared with answered_by: "sonny". The lead-only tools carry inherit: false.
    • Each call runs as sonny tool NAME with the calling turn's own context: its folder, model and effort. It runs in a process group of its own. That group is killed if the call runs out of time, if its turn ends (the person interrupting a slow setup, say), or if the lookout gives way to another build.
    • The call returns its result or a typed error, such as task_not_started, not_shown or subscription_refused. If nobody answers in time, it ends as tool_unserved.
    • These tools work with every Sonny window closed. Every Sonny window now starts the lookout, lead or not.
  • Gates.
    • Every tool except show_agent waits for a verdict wherever the agent's other calls do (/approvals):
      • a start runs the folder's setup script;
      • a new project makes a lead;
      • a removal can drop work;
      • a subscription sends other bots' words to a judge;
      • a pane runs a command outside the sandbox.
    • Sonny recomputes the gate whenever it changes an agent's declared tools.
    • If Sonny didn't set a bot's gate (another client's tag, or several gates), the bot gets no gated tools until the person picks a mode.
  • Setup scripts.
    • .agents/setup runs without any provider keys: the well-known ones, AWS/Bedrock credentials, the key any AGENT_PROVIDER spec names, and everything ~/.agent/env sets.
    • Its stdout is dropped. A failure reports only the last 20 lines of stderr.
  • Effort defaults (Effort defaults for leads, tasks and judges in ~/.agent/config.toml #251). start_task takes the project's threads_model/threads_effort, then [sonny] task_effort, then the lead's own. new_project takes [sonny] lead_effort.
  • Upgrades. The lookout writes its build to STORE.lookout.sonny. A Sonny that finds another build's lookout stops it and takes over.
  • Subscriptions apply at once. The lookout re-reads them on its next tick, about 1 s, after a subscriptions call. /background (Sonny: /background lists triggers and lookout subscriptions, with a ↻ count per agent #267) removes subscriptions through the same code.
  • Clean view. Each call says what it did ("Started fix", "Subscribed to deploys", "Discarded fix", "Opened a split"). A failed call shows its reason in red underneath.
  • Removed:
    • the commands sonny task start and rm, sonny show, sonny run, sonny lookout ls/add/rm and sonny project;
    • the ~/.agent/project runner;
    • the SONNY_BIN substitution in the pane skills.
  • Docs and prompts. lead.md, the skills, sonny/README.md and docs/LOOKOUT.md now name the tools.

A lead starting a task, subscribing, a show_agent call refused with its reason, and a discard the person allowed

The screenshot is from a live run: a real daemon, a scripted Responses model, and the lead's Sonny in tmux in ask mode.

Testing

🤖 Generated with Claude Code

A tool declared with `answered_by: TAG` takes no fixed result. A call that
fits its parameters waits for the answer of whichever client serves that
tag. The client finds it by following the bot (`tool_started` carries
`answered_by` and `expires_ms`) or with `tool_calls {tag}`, and answers with
`tool_result {output | error{code,detail}}`. The turn holds live for up to
250 ms, then parks like `wait` and survives restart. A call nobody answers by
`expire_ms` (default 60 s) ends as a typed `tool_unserved` result, and the
turn goes on.

Gates may now name declared tools, so a client's tool can need approval
before it is asked. Protocol 20, schema 55 (`answers` table).

The approval_overhead bench gains declared, answered and answered_parked
arms. Measurements are in DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
# Conflicts:
#	docs/RUST_PROTOTYPE.md
#	src/tools.rs
#	tests/store_contract.rs
…eads one

The history tool takes an optional `bot`. With a bot and no turn, it lists that agent's newest 20 turns, newest first: each one's number along its lineage, its handle, its status and the start of its prompt. With a turn, it reads that turn as it stands, a running one included, paged as before. A bot's own turns are still read by number only. Agents no longer have to read the store to see what a sibling is doing.

Sonny's task rule names the tool and says to message another agent only when work depends on it. The lead's rule says tasks can read each other.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
`sonny task start`, `sonny task rm`, `sonny show`, `sonny run`,
`sonny lookout ls/add/rm` and `sonny project add` were only ever called by
agents, so they become answered declared tools (tag `sonny`): start_task,
remove_task, show_agent, run_in_pane, subscriptions and new_project. The
lookout answers them, each in a `sonny tool NAME` child run in the
caller's folder with its environment, and their CLI forms are gone.

- Leads get start_task, remove_task, new_project and subscriptions
  (`inherit: false`); every agent gets show_agent and run_in_pane.
- remove_task and run_in_pane are gated like the shell calls they replace.
- Errors are typed codes (task_not_started, not_shown, ...).
- A lookout another Sonny build started gives way, so upgraded tools are
  answered; a subscriptions call is read at once.
- The clean view says what each call did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
…-qzgtqy

# Conflicts:
#	docs/LOOKOUT.md
#	sonny/README.md
#	sonny/agents/lead.md
#	sonny/src/lookout/mod.rs
@lydakis lydakis self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T04:45:24.142261Z 2867552 New commits
🔒 Security Review ✅ Completed 2026-10-28T04:48:22.647410Z 2867552 New commits

Security findings

Advisory findings (3)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1c7bef65c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/served.rs Resolved
Comment thread sonny/src/served.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/task.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: b1c7bef65c

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sonny/src/served.rs Resolved
…un in the turn's folder

- A window that adds Sonny's tools to a bot gated auto or ask gates the
  new ones too, so remove_task and run_in_pane never run unjudged there.
- A call's process runs in a group of its own; when its turn ends (the
  person interrupting a slow setup) or its time runs out, the group is
  killed, so no task starts after all.
- A call runs with its turn's workspace, model and effort, not the bot's
  current ones.
- A setup script's output is no longer kept: only the last 20 lines of
  its errors, read as it runs.
- Every Sonny window starts the lookout, a lead or not, since every agent
  has show_agent and run_in_pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
… keys

start_task runs the folder's .agents/setup outside any sandbox, and
new_project makes a lead, so both now wait for a verdict wherever the
agent's other calls do, as the shell calls they replace did. The setup
script also runs without the provider keys the lookout holds (the
well-known ones and what ~/.agent/env sets), as a bot's shell runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr

lydakis commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e7a3374fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/task.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 8e7a3374fb

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sonny/src/served.rs Resolved

lydakis commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 946b2c2731

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 946b2c2731

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

start_task now takes its defaults from #251's with_defaults (the project's
threads_model/threads_effort, then [sonny] task_effort, then the lead's),
new_project takes [sonny] lead_effort, and threads_effort may come without
threads_model. /background removes subscriptions with subs::remove, which
the subscriptions tool shares.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5bbc26806

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/lookout/mod.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: e5bbc26806

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sonny/src/main.rs Resolved
Another build's lookout takes over with SIGTERM and serves the pending
calls again, so a setup the old one left running would share the task's
folder with the new one's. The lookout now kills its served process groups
on SIGTERM before it exits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
configure sets one gate, so Sonny cannot add its gated tools to another
client's tag or to several gates. Such a bot is declared show_agent and
Sonny's own tools only, and gets the rest, gated, with the mode the person
picks in /approvals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGErsjQZRay4MEvYNpr
@lydakis
lydakis merged commit a182590 into main Oct 28, 2026
3 checks passed
lydakis pushed a commit that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants