Skip to content

Sonny: every agent starts tasks, as deep as task_depth allows - #490

Merged
lydakis merged 7 commits into
mainfrom
claude/project-thread-0ttt4p
Oct 31, 2026
Merged

lydakis merged 7 commits into
mainfrom
claude/project-thread-0ttt4p

Conversation

@lydakis

@lydakis lydakis commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Why

George asked whether the lead/task split was too rigid: workers take roles such as a reviewer, a researcher or a watcher on a PR. The audit (doc) found exactly one capability gate. start_task, remove_task and new_project were declared on leads only, so a task that wanted a helper could only ask its lead or fall back to raw run --new, with no worktree, setup or tab. Everything else, including profiles as roles, peer messaging, subscriptions and lineage-based approvals and sandboxes, was already loose.

George picked a depth bound over a cap on running agents. The risk he wants guarded is infinite downward delegation, not concurrency. He also asked for the bound to be configurable, with an option for no end.

What

  • [sonny] task_depth (in /config) sets how many generations of tasks a lead's line has. The default is 2: a lead's tasks start helpers, and those helpers start none. 1 keeps today's behaviour, and 0 means no end. Depth counts up to the nearest lead, so a lead that another lead made starts fresh.
  • served::Role { lead, starts, passes } replaces the lead: bool.
    • An agent with room below it declares start_task and remove_task.
    • When its own agents would have no room, it declares those tools with inherit: false. A lead's tasks therefore take start_task from their first turn, and their helpers don't take it at all.
    • new_project stays a lead's alone.
  • A task's helper works in its lead's project, in the repository the task works in, starting from the last commit on the task's branch.
    • Paths in the brief that point into the task's worktree are rewritten to the helper's copy.
    • Like a fork, it gets no setup and no build-folder clones on those task-written files.
    • The lead's tasks subscription already covers every bot in its line, so the lead hears helpers too.
  • Guards at call time:
    • A start past the depth is refused with task_depth_reached.
    • A task's side chat starts no tasks. It is told to ask in the task's conversation. A lead's side chat starts tasks as before.
    • A task's remove_task reaches only agents in its own line. The line is followed by ids, so an agent that reuses a name owns nothing.
    • The left-behind folders list stays the lead's.
  • Depth is worked out from created_by. A side chat counts as its agent.
    • The tool host's refresh uses the bot listing it already holds.
    • A window works it out when it opens.
    • sonny tool walks the line with the CLI.
    • new_project, not start_task, now marks a lead in refresh.
  • start_task's description gives the rule: any agent other than a lead starts one only for help inside its own brief, and asks its lead for a task for separate work.
  • README and FEATURES.md rows are updated.

No daemon change.

Known gap

When the depth is 2, a task's declaration is corrected to inherit: false only once its window opens or the tool host refreshes it. A helper it starts during its very first turn can therefore inherit a start_task that refuses at call time. When the helper's window opens, the tool is taken away again. Closing the gap fully needs inheritance bounded by generations in the daemon (inherit: N), which I'd discuss before building.

Tests

  • cargo test -p sonny -p agent-client passes: 660 unit tests and 24 task end-to-end tests.
  • End-to-end tests for a task's helper:
    • It gets a worktree on the task's branch, with its brief's paths rewritten.
    • It gets no setup.
    • It is refused at depth 2.
    • It can't remove its lead's task.
    • With task_depth = 0, it starts a task.
  • Other end-to-end tests:
    • A task's side chat is refused.
    • A task with a reused name can't remove the old task's helper.
    • A task in a nested repository can start a helper and fork itself.
  • New unit tests cover roles and inheritance at depths 1, 2 and no end.
  • cargo fmt --check and clippy are clean.

@lydakis lydakis self-assigned this Oct 31, 2026
@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-31T05:40:09.652771Z deeb648 New commits
🔒 Security Review ✅ Completed 2026-10-31T05:42:58.727018Z deeb648 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: 858b171f01

ℹ️ 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

@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: d1f4844601

ℹ️ 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
Comment thread sonny/src/served.rs Resolved
@lydakis
lydakis force-pushed the claude/project-thread-0ttt4p branch from d1f4844 to 9e94e80 Compare October 31, 2026 04:41
start_task and remove_task are no longer a lead's alone. Any agent with
room below it in its lead's line has them, for help inside its own brief
(a review, research, a watch on something); separate work still goes to
its lead. `[sonny] task_depth` (in /config) bounds how many generations
of tasks a line has: 2 by default, so a lead's tasks start helpers that
start none; 1 is the old behaviour; 0 has no end.

- served::Role (lead, starts, passes) replaces the lead flag; a tool an
  agent keeps to itself is declared with inherit false, so a lead's
  tasks take start_task from their first turn and their helpers do not.
- A task's helper starts from its lead's folder, in its project and
  repository (setup script and build-folder clones stay the lead's), on
  the last commit of the task's branch. A start past the depth is
  refused (task_depth_reached); a task removes only its own line.
- The lookout's refresh and a window's open work out each agent's depth
  from created_by; new_project, not start_task, marks a lead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGE8xLJp2WvDkgJJ9p7
A task started with `folder` works in a repository inside the lead's
folder, so its branch is there, not in the lead's. Its helper now takes
that repository by default and starts on the task's branch in it; the
base branch is looked up in whatever repository the helper is made of.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGE8xLJp2WvDkgJJ9p7
…s without a folder inferred

A path in the brief to the starting task's worktree now names the
helper's worktree, as a fork's brief names its own. A task in a
repository inside its lead's folder that forks itself or another task
no longer gets its repository inferred as a folder, which a fork refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGE8xLJp2WvDkgJJ9p7
@lydakis
lydakis force-pushed the claude/project-thread-0ttt4p branch from e76393d to eeb2b91 Compare October 31, 2026 05:17

@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: eeb2b91a98

ℹ️ 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/task.rs Resolved
… its branch, ownership by id

A helper on its task's branch starts with files a task wrote, so, as a
fork, it gets neither the lead's setup, which runs outside any sandbox,
nor clones of the lead's build folders, which links there could lead
out of its worktree. A side chat of a task starts its helpers on the
task's branch. remove_task follows who made whom by id, so a task that
took a removed one's name owns nothing that one made.

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

@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: c0e9df6ebb

ℹ️ 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
A side chat is gone soon, and a helper it started would hang off it, out
of its task's sight and its lead's. The task starts its own; a lead's
side chat starts tasks as before.

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

@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: a027004944

ℹ️ 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/declared.rs Resolved
Removing a finished task left its helpers a generation shallower, with
room to start more. A walk that cannot reach its maker, or finds another
bot under its name, now counts the line as deep as task_depth lets it
go, so it starts none; with no end to lines nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGE8xLJp2WvDkgJJ9p7
@lydakis
lydakis merged commit 2442201 into main Oct 31, 2026
4 checks passed
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