Skip to content

Sonny: answer tools from their own companion, not the lookout - #481

Merged
lydakis merged 11 commits into
mainfrom
claude/project-thread-p6odw4
Oct 31, 2026
Merged

lydakis merged 11 commits into
mainfrom
claude/project-thread-p6odw4

Conversation

@lydakis

@lydakis lydakis commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Opened by Claude for @lydakis, following George's call on 10-31 ("Split into its own companion"): the lookout is a watch-and-tell interface, not a tool host.

What

  • New companion sonny tool-host (sonny-tool-host), in sonny/src/tool_host.rs. It answers every answered_by: "sonny" call: start_task, memory, goal, triggers, subscriptions, commons, and exec with its MCP servers. Sonny and sonny acp keep it beside the lookout, with the same SONNY_BUILD env, so an upgrade replaces both.
  • The lookout only watches and tells. served::Server is gone from it. The lookout follows subscriptions and goal calls by their tool_started, and rereads its files on their tool_completed. The stream orders that event before every later event, so news that arrives right after a subscribe is still read with the new subscriptions. This replaced a signal, which raced (Codex P2).
  • How the host runs:
    • It holds STORE.tool-host.lock. A second host prints already_serving, and a host from another build gives way to the new one, using the lookout's replace, now generalized.
    • It follows only tool_started and turn_finished, starting from STORE.tool-host.cursor. On its first run it starts from the lookout's cursor, so it never reads the whole log.
    • It exits 30 s after the daemon goes away.
    • Refreshing agents' declared tools after an upgrade moved here from the lookout.
  • /status shows "tools not answered" when no tool host is running.
  • Docs:
    • SONNY.md has a new "Tool host" section, and its MCP, memory and triggers text now name the host.
    • LOOKOUT.md says the lookout only watches and tells.
    • README and ROLE_EVAL are updated, and comments that said "the lookout answers" now say "the tool host".
    • FEATURES.md rows for the lookout and MCP exec are updated.

Precedent: Codex keeps its code-mode host as a separate, recyclable process, apart from the session loop.

Tests

  • cargo clippy -p sonny --all-targets -D warnings is clean.
  • cargo test -p sonny passes, including new tests for the cursor and for the reread on a call's end.
  • test_served starts the host rather than the lookout. The goal tests start both. The give-way test mid-setup now replaces the host. A new test checks one host per store, already_serving, and that the cursor is saved and reused.
  • test_lookout: the subscriptions-tool test starts the host too. It checks end to end that the reread happens when the call ends.
  • test_acp: the thread now keeps two companions.
  • Local runs: test_served and test_lookout pass, except for two tests that start tasks and need bubblewrap, which this box lacks. The same three test_acp tests fail on main here for that reason too, so CI is the check.

Sonny only. The daemon is unchanged.

🤖 Generated with Claude Code

…ntity

The lookout's MCP host held what scripts and servers sent outside QuickJS's
cap without bound, and a resumed T3 Code thread bound by bot name alone.

- exec: a script's output is kept within 1 MB as it runs, its first half
  and its latest, as Codex keeps a command's; eight calls in flight per
  script; a result over 16 MB (rmcp's per-message cap) is refused; results
  reach the script as one JSON string, not a Value tree.
- exec: one deadline from the call, which waiting for a place and listing
  servers' tools spend; servers list concurrently, and a start given up
  stops its process group.
- exec: tools whose identifiers collide are refused, not replaced.
- mcp: the listing cache is keyed by a SHA-256 of the config, not the
  config's debug string with its env and headers, and written 0600 in a
  0700 folder; stderr is read in chunks, each line cut at 1 KB.
- acp: a thread remembers its bot's id and store lineage; resume refuses a
  bot made again under the name, or another store's, and submit carries
  bot_id. A thread kept by name only binds by name once and is pinned then.

Closes #347, closes #332; #335 keeps its macOS allocator item.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF1uDHaNjs42Bgs9Uu
Codex review on #474: a first text() over 1 MB kept only its end. The
head now fills from the text that overflows it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF1uDHaNjs42Bgs9Uu
The lookout only watches and tells now. Sonny's tools (start_task, memory,
goal, commons, exec and its MCP servers) are answered by `sonny tool-host`,
the daemon's companion `sonny-tool-host`, kept beside the lookout by Sonny
and `sonny acp`, so a slow, crashing or memory-heavy tool never holds up a
lead's news. The host signals the lookout (SIGUSR1) when a call changes the
subscription or goal files it reads, follows only tool_started and
turn_finished from its own cursor, refreshes agents' declared tools on
start, and gives way to another build as the lookout does. /status says
"tools not answered" when no host runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF1uDHaNjs42Bgs9Uu
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 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-31T03:56:41.820229Z a306bed New commits
🔒 Security Review ✅ Completed 2026-10-31T03:58:35.574744Z a306bed New commits
ℹ️ 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: 0dfe0754d1

ℹ️ 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/main.rs Resolved
Comment thread sonny/src/lookout/mod.rs Resolved
…not a signal

A SIGUSR1 from the tool host could be handled after the events that
follow the call's tool_result, so news right after a subscribe could be
read with the old subscriptions and lost. The lookout now follows those
calls by their tool_started and rereads on their tool_completed, which
the stream orders before every later event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF1uDHaNjs42Bgs9Uu
@lydakis
lydakis merged commit 6c2ed1a into main Oct 31, 2026
4 checks passed
lydakis added a commit that referenced this pull request Oct 31, 2026
…text (#494)

* Sonny: bound the shared MCP host and pin a T3 thread to its bot's identity

The lookout's MCP host held what scripts and servers sent outside QuickJS's
cap without bound, and a resumed T3 Code thread bound by bot name alone.

- exec: a script's output is kept within 1 MB as it runs, its first half
  and its latest, as Codex keeps a command's; eight calls in flight per
  script; a result over 16 MB (rmcp's per-message cap) is refused; results
  reach the script as one JSON string, not a Value tree.
- exec: one deadline from the call, which waiting for a place and listing
  servers' tools spend; servers list concurrently, and a start given up
  stops its process group.
- exec: tools whose identifiers collide are refused, not replaced.
- mcp: the listing cache is keyed by a SHA-256 of the config, not the
  config's debug string with its env and headers, and written 0600 in a
  0700 folder; stderr is read in chunks, each line cut at 1 KB.
- acp: a thread remembers its bot's id and store lineage; resume refuses a
  bot made again under the name, or another store's, and submit carries
  bot_id. A thread kept by name only binds by name once and is pinned then.

Closes #347, closes #332; #335 keeps its macOS allocator item.

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

* FEATURES: MCP bounds and T3 identity pinning (#474)

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

* exec: one text past the output cap keeps its own start

Codex review on #474: a first text() over 1 MB kept only its end. The
head now fills from the text that overflows it.

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

* tests: a T3 thread's record holds its bot's identity and store

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

* Split Sonny's tool answering out of the lookout into its own companion

The lookout only watches and tells now. Sonny's tools (start_task, memory,
goal, commons, exec and its MCP servers) are answered by `sonny tool-host`,
the daemon's companion `sonny-tool-host`, kept beside the lookout by Sonny
and `sonny acp`, so a slow, crashing or memory-heavy tool never holds up a
lead's news. The host signals the lookout (SIGUSR1) when a call changes the
subscription or goal files it reads, follows only tool_started and
turn_finished from its own cursor, refreshes agents' declared tools on
start, and gives way to another build as the lookout does. /status says
"tools not answered" when no host runs.

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

* FEATURES: tool host rows for #481

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

* Lookout: reread on a subscriptions or goal call's end in the stream, not a signal

A SIGUSR1 from the tool host could be handled after the events that
follow the call's tool_result, so news right after a subscribe could be
read with the old subscriptions and lost. The lookout now follows those
calls by their tool_started and rereads on their tool_completed, which
the stream orders before every later event.

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

* cargo fmt

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

* Sonny: exec's image() shows the model the picture, in order with the text

With the daemon's tool_result parts (#482), an exec script's text() and
image() come back as ordered text and image parts, as Codex's code mode
returns them, rather than a saved file's path. A picture is a PNG, JPEG,
GIF or WebP by its own bytes, scaled to 1568 on its longest side as the
daemon's read scales one; a result holds up to 20, 5 MB together, and
image() throws past that. Pictures are marked in the output by a private
use character that text() strips, so the budget's cut drops a picture
with its place; the tool host holds the parts' text to its 60 KiB.

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

* FEATURES: #494

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

* exec: a picture's mark opens and closes with its own characters

A mark the output budget cut in half shifted the split's alternation, so
later whole marks named no picture. A mark now opens with U+E000 and
closes with U+E001: a half one is dropped and every whole one after it
still shows its picture.

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

---------

Co-authored-by: Claude <[email protected]>
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