Repository navigation
Lookout: stays light with thousands of bots - #398
Conversation
A streaming synthetic model in its own process, P projects of T tasks whose leads are subscribed as Sonny subscribes them, and the companions in a bot's path: the lookout's start, rest and load (CPU, memory, how late and whether each lead hears a task's turn ended), its restart over the whole log, and a burst of gated calls against a slow judge. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEHSaQA9KQfmqTB4MM
Each event reaches only the subscribers that watch its bot (a bot made or deleted, all of them), and each checks that one bot alone instead of every bot listed. Each subscriber keeps only the bots it watches. A lookout follows from its cursor rather than replaying the whole log, reading who asked for its subscribers' running turns once when it starts. Notes and status checks go to the daemon beside the stream, so no call holds the events up; a dropped connection makes what a note carried news again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEHSaQA9KQfmqTB4MM
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cc2e6ec51
ℹ️ 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".
…ers, read who asked for turns begun before it heard - A note the daemon has not answered counts as untold, so a saved cursor never passes news a crash would lose. - A status answer is let go when the subscriber's own events came after the question: it is older than what they said. - A task's turn that ends without having begun in what the lookout heard (before its cursor, or before its bot was watched) is held while its prompt is read for who asked, instead of being told as the person's. This replaces the start-up read of running turns. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEHSaQA9KQfmqTB4MM
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f441150e8
ℹ️ 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".
Each piece of a turn's state the lookout learns from its events (who asked, what the subscriber waits on, a task's resolving) began before the cursor for a turn that spans it. Recovering each from listings one by one missed some, so the cursor file now keeps two marks, as a consumer commits its offset only up to its oldest record still in work: where the news ended, and just before the oldest turn still under way among the bots a lookout hears. The stream starts at the second; what comes before the first is history, as before. This replaces the prompt reads for turns begun before the cursor and the start-up read of what each subscriber waits on, and covers a dropped connection too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEHSaQA9KQfmqTB4MM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGETkBwAL5VmcD7kf5q
* Sonny: a register of every feature it has had, and why (sonny/FEATURES.md) Each Sonny feature added, changed or removed, with its pull requests, status (experimental, shipped, removed), the reason, and a Used? column for the person to fill in. AGENTS.md asks every pull request that touches a Sonny feature to update its row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGETkBwAL5VmcD7kf5q * FEATURES.md: the commons (#392) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGETkBwAL5VmcD7kf5q * FEATURES.md: /goal (#397) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGETkBwAL5VmcD7kf5q * FEATURES.md: #398 and #399 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGETkBwAL5VmcD7kf5q --------- Co-authored-by: Claude <[email protected]>
The lookout collapsed near 1,000 bots. Four costs multiplied each other:
Lookout::sync), which is leads × bots per new bot.This follows how Kubernetes controllers stay light on large clusters (list then watch from a version, a shared cache, handlers by key, a work queue):
check). The full check runs only when a subscriber's subscriptions change, and only for that subscriber (resubscribe(all)).watchersindexes which lookouts hear each bot (its own, and those that watch it). An event reaches only those, and a bot made or deleted reaches all. Each subscriber seats only the bots it watches plus its own.prompts) and what each subscriber's own turn waits on (turns), which the replay used to tell it. Only a lookout with no cursor reads the whole log, once.refresh_toolsnow runs once per lookout, not on every reconnect.wake,wake_sourcesand the "does it rest?" check run as spawned tasks whose answers come back on a channel (answered). One note is in flight per subscriber. A dropped connection makes what a note carried news again (reconnected).disconnectedandlagged, so a dropped session shows up.No behavior change in what a subscriber hears or when.
Numbers
From
bench/lookout_scale.py(added here): 4-core Linux container, every task streams 10 deltas a second, 4 s turns in rounds, each sent from its lead.* Past about 1,000 busy bots, the daemon still drops the lookout's session. Each socket session queues at most 64 messages (
src/output.rs:48) on top of its 2 MiB byte budget, and hundreds of streaming turns overflow it before the writer runs. With that limit raised locally to 4,096, 1,100 bots / 100 subscribers told all 3,000 of 3,000 endings (p95 2.9 s). That daemon change is waiting on George and isn't in this PR.Tests
cargo test -p sonny lookout: 67 pass, including three new tests (an event reaches only the lookouts that hear its bot; a note goes beside the stream and one lost with the connection is news again; a turn running before the lookout started is told as whoever asked).tests.test_lookout(live): all 7 pass, including both restart tests.tests.test_served: 2 of 17 fail in this container because bubblewrap isn't installed (sandbox_unavailablewhen a task starts). They don't touch the lookout.