Skip to content

Lookout: filter, digest and urgent on every subscription, agent activity as typed events - #599

Merged
lydakis merged 10 commits into
mainfrom
claude/project-thread-qf811y
Nov 1, 2026
Merged

lydakis merged 10 commits into
mainfrom
claude/project-thread-qf811y

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

What

Lookout's three rules (filter, digest, urgent) used to apply only to sources, and only partly. Now every subscription can set all three, and they read the bots a subscription watches the same way they read its sources. Nothing that happens today changes. This only adds the option.

  • Agent activity as typed events. What a watched bot does becomes an event shaped like a source's event: message.written, turn.ended, approval.waiting, ask.posted, turn.silent and note.changed. Their fields are bot, maker, by, turn, status, resolved, goal, theirs, text, question, options and id. Each event is matched when it arrives, before it folds into its task's news. The subscriptions tool lists these fields for the agent, and a filter on a field no event has gets the same warning a source filter gets.
  • filter narrows which events a subscription hears, for bots as well as sources. A filter no longer needs sources.
  • digest (30s, 15m, 1h) tells a subscription's news at most once per window. The first event after a quiet spell goes at once. The person's own words, a question for them, or an approval only they can give never wait. On a source, the subscription's digest replaces the source's. A source with no subscription digest keeps its own per-source timer, so commons per-thread subscriptions behave as before.
  • urgent is a pattern that cuts into a busy subscriber's turn. The steer note names the subscription that marked it ("urgent by your migration"). Sources also get urgent = {…} in [sonny.sources.NAME]. It marks events urgent the same way the command's own mark does, and the runner refuses a bad pattern with source_refused.

Cost when unused

A subscription with none of the three builds no event. Which bots any rule-bearing subscription watches is worked out when subscriptions change, and stored per bot as Arc<[Rule]>. Every other bot has no entry, takes the fast path, and its news goes out exactly as before. Notes stay byte-identical: subscriptions_that_say_nothing_more_cost_nothing_more checks that no rules exist and that the note text matches.

Also fixed: a first replay that lags starts over from the beginning

Found while benchmarking, and present on main too. A lookout with no cursor yet replays the whole log. If it fell behind partway through, it followed again from event 0. On a long history it could lag, back off two seconds and start over indefinitely. In the bench it never went live during the 10 s idle phase (five restarts, main and branch alike). Whenever it was still replaying when the load began, the first round of turns went untold. It now goes on from the last event it replayed, as a consumer resumes from its offset (follow_after, with a test).

No daemon or protocol change

All of this is Sonny-only. No protocol or schema numbers are taken.

Tests

  • cargo test -p sonny -p agent-client: all pass.
  • cargo clippy is clean.
  • New tests cover: filtered task events, a digest that holds task news but never the person's words, urgent cutting in and naming its subscription, digest and urgent on a subscription's sources, a source's configured urgent, config parsing, the subscription parse and describe changes, and the replay resume point.

Performance

bench/lookout_scale.py gains --rules. With it, every lead's tasks subscription gets a filter that matches everything and an urgent pattern that never matches. Every event is then built and matched, but none is held or dropped, so the run measures only the cost of the rules. The numbers are in the comment below. With the replay fix, the branch tells every turn, and its CPU and note delays are in main's range. RSS is a few MB higher.

Docs

  • docs/LOOKOUT.md: subscriptions, sources and filters are updated, and task updates gains "As events", "Digests" and "Urgent".
  • sonny/FEATURES.md: new row.

🤖 Generated with Claude Code

… watches read as typed events

A subscription's filter, digest and urgent now read the bots it watches as
well as its sources. Agent activity becomes typed events (message.written,
turn.ended, approval.waiting, ask.posted, turn.silent, note.changed) in the
shape a source's have, matched as each comes, before it folds into its
task's news. A subscription's digest takes its sources' place (the person's
words, a question or an approval for them never wait); urgent cuts into a
busy subscriber's turn and the note names the subscription. A source's
urgent pattern in the settings marks what is urgent, as the command's own
mark does.

A subscription with none of the three builds no event: which bots any of
them watches is worked out when subscriptions change, and every other bot's
news goes as it always went, so every note reads as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
…turn awaiting its reply, let overlapping digests each allow, digest 0 overrides a source's

A turn the lookout did not see start is held apart until who asked for
it is read, so a filter on `by` hears it as it is. A turn waiting for
its reply keeps the urgency it was heard with. News several digests hold
goes when any of them allows. A subscription's `digest = "0"` waits for
no digest of its sources either.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
…again, however soon it went

Hold keeps which subscriptions with a digest heard a task's news apart
from whether something in it goes now, so news the person's words, an
urgent match or a subscription with no digest take along still starts
each digest's time again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
…t for the next note keeps its urgency

A task note and a sources note told through one subscription with a
digest both check when it last told: each now marks it as the note goes,
and puts it back if the note is not sent, so the two never slip through
one window together. News a note leaves for the next, for room as for a
reply, may go as it might have, and keeps the urgency it was heard with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
…ilters hear words as written

Each message, turn, margin note and question keeps the urgency it was
heard with, and a task's urgency is whatever of it is still to be told:
a turn the subscriber read with wait takes its urgency with it, as does
a turn whose asker was still to be read. A filter on a message's text
hears the person's words as they wrote them, not as a note cuts them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
…unts from the notes that land

What a piece of a task's news may wait for, and which digests heard it,
now goes with that piece, as its urgency does: a note counts only for
the digests of what it tells, and what it leaves for later keeps its own.
A note on its way marks the digests it tells as flying, so no other note
tells more of them meanwhile; one that lands starts their time, one that
fails leaves what any other note told.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEQqpYZ4K234ddyPtV
@lydakis lydakis self-assigned this Nov 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T11:27:07.685147Z 43ce224 New commits
🔒 Security Review ✅ Completed 2026-11-01T08:05:34.648645Z 45430b3 PR opened
ℹ️ 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.

The Perf screen's sonny_screen, fair_queuing and ingress_credits build
their own arguments for Bench; a missing rules reads as none.

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

@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: 45430b333e

ℹ️ 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/updates.rs Resolved
Comment thread sonny/src/lookout/activity.rs Resolved
Comment thread sonny/src/lookout/mod.rs Resolved
Comment thread sonny/src/lookout/updates.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: 96f721c58b

ℹ️ 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/activity.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: 1bc78b1f87

ℹ️ 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/updates.rs Resolved
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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b8ba9b53d

ℹ️ 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/updates.rs Resolved
Comment thread sonny/src/lookout/updates.rs Resolved
Comment thread sonny/src/lookout/updates.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: 812fbfa8bc

ℹ️ 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/updates.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: f42fb6e450

ℹ️ 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/updates.rs Resolved
Comment thread sonny/src/lookout/updates.rs Resolved
A lookout with no cursor yet replays the whole log. When it fell behind
partway through, it followed again from the first event, so on a long
history it could lag, back off and start over indefinitely: in the
1,100-bot bench it never went live during the idle phase, on main too,
and the first round of the load went untold whenever it was still
replaying then. It now goes on from the last event it replayed, as a
consumer resumes from its offset.

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

lydakis commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Performance, 1,100 bots (bench/lookout_scale.py --projects 100 --tasks 10, 6,000 task turns under load, 4-core cloud box, nothing else running)

runs lookout CPU under load lookout peak RSS turns told note delay p50 p95 lags
main (660fda3) 8 2.3–3.2 s 41–43 MiB 6,000 in 8 of 8 2.6–3.2 s 3.0–3.8 s 1–5
branch before the replay fix 10 2.5–4.8 s 45–49 MiB 6,000 in 5 of 10 2.6–3.5 s 3.0–4.7 s 1–13
branch with --rules before the fix 10 3.0–7.2 s 48–52 MiB 6,000 in 1 of 10 2.6–3.8 s 3.0–4.5 s 3–23
branch now (43ce224) 2 2.49, 2.68 s 45, 47 MiB 6,000 in 2 of 2 2.9, 3.2 s 3.5, 3.7 s 1, 1
branch now with --rules 2 2.55, 2.63 s 49, 50 MiB 6,000 in 2 of 2 2.9, 3.1 s 3.4, 3.6 s 2, 1

What the earlier rows were: every short run lost exactly the first round of the load (1,000 turns), sometimes more. The cause is a bug main has too. A lookout's first replay, with no cursor yet, restarts from event 0 each time it lags. A controlled start-and-idle run showed main and the branch identical here: five restarts in 10 s, never live. Main got through in time more often by luck of timing. The extra lags were where the extra CPU in those rows came from. 43ce224 resumes the replay from where it got to.

The rules alone, in-process with no I/O: 60,000 task events through Lookout::event + flush. With the lead idle: 95 ms without rules, 109 ms with. With the lead busy: 79 ms and 103 ms. That is about 0.4 µs more per event when every event is built and matched. A bot no rule-bearing subscription watches costs nothing more.

Memory: about 3–5 MiB more than main with no rules, and about 7 MiB more with rules on every lead, at 100 leads and 1,000 tasks. That covers the per-item holds, the per-bot rule tables, and the digest bookkeeping.

Start and restart are unchanged: seated in 0.2 s, and a restart from the saved cursor is busy for 0.22 s.


Generated by Claude Code

@lydakis
lydakis merged commit 6227aab into main Nov 1, 2026
10 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