Skip to content

An attached note waits at most a day, then goes as a steer - #609

Merged
lydakis merged 8 commits into
mainfrom
claude/project-thread-bgpakl
Nov 1, 2026
Merged

lydakis merged 8 commits into
mainfrom
claude/project-thread-bgpakl

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

What

An attach never started a turn and never expired. An idle agent could hold one forever, and an agent told that would stop using attach. Now an attach waits at most attach_wait (a day by default). If no call has taken it in by then, it goes as a steer: it joins the running turn at its next boundary, or starts a turn of its own on an idle bot.

George's pick (11-01): a daemon cap with a Sonny/CLI default of 1 day, 0 meaning never, and a per-message override. The default lives in config.toml as a top-level attach_wait, not [daemon], because docs/CLI.md says the daemon keeps no delivery default and clients send what they resolved.

Changes

Daemon (protocol 45, schema 76)

  • submit takes wait_ms with attach only (invalid_delivery otherwise). It must be 1 ms to 365 days, otherwise invalid_wait.
  • turns.wait_ms and turns.due_ms are new columns, with a partial index turns_due on due attached rows. A migration adds the columns. Notes already waiting keep no limit.
  • Database::next_due and Database::lapse. Each due row becomes delivery='steer'. It goes queued if the bot has a turn running or ready, ready if the bot is idle. It commits with a queued event carrying lapsed: true, and counts as pending from then on. A retry of the original request is still read as the attach it was, and wait_ms is compared like any other field.
  • The run loop has a lapses timer, planned at start and lowered on submit. The next due time is read on the writer after each look, so no submission is missed. While draining, the timer is skipped.
  • Lapsed messages get the same handling as an admitted steer: the running turn's steer flag is armed inside the job, and lift, wake_for_steer and ready_hint are applied.

Clients

  • client/src/config.rs: top-level attach_wait ("1d" default, "0" for never, at most 365d). Also Config::attach_wait(), plus duration_ms, which src/cli.rs now reuses.
  • agent run --attach-wait DURATION. It falls back to config.toml, then 1d. Using it without --delivery attach is a usage error.
  • Sonny's trigger notes (missed and failed fires) send the configured wait. Sonny's own reactions and margin closes send none. Those are the person's gestures about the conversation they're in, and they wait for the person's next word.
  • Sonny shows no "queued" notice when a lapsed note arrives.
  • Coordination skill, line 16: "--delivery attach, for a note needing no answer, joins its next call without starting a turn, or after a day goes as a steer." To stay inside the 16 KiB lead budget, "a change of plan" became "a plan change".

Docs: docs/CLI.md, docs/RUST_PROTOTYPE.md, README.md, sonny/README.md and sonny/FEATURES.md are updated.

Why steer and not queue

When a note lapses, its sender has waited long enough, so it is delivered the way a message sent now would be. A steer is what the latency thread made the agent-to-agent default. A queued turn would sit behind the bot's own work and could wait again.

Testing

  • cargo test --workspace passes. cargo clippy --workspace --all-targets and cargo fmt --check are clean.
  • Store contract tests:
    • an idle bot lapses to ready, and a second lapsed note waits behind it for the first boundary;
    • a busy bot's lapsed note joins even a final reply's boundary, as a steer;
    • the retry and conflict check on wait_ms;
    • the schema 75 → 76 migration.
  • Runtime tests (AGENT_TEST_RUNTIME=1):
    • test_delivery covers refusals, a lapse on an idle bot starting a turn, and a lapse joining a running turn;
    • test_cli covers --attach-wait usage errors and a 200 ms wait running end to end.

The footer's 📎 said a note would come with the agent's next call: an
open loop the person could not close without typing, for words that ask
nothing of them (George, 11-01). Attached notes are now passive, as a
muted iOS notification or a muted Slack channel: no clip, no count, and
the folded 📎 row under what a call carried, once the agent reads them,
stays as #535 drew it. The App's attached and reaction_turn bookkeeping
went with the clip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGG5PKzf3A9NDuvu9Xu
An attach never started a turn and never expired, so an idle agent could
hold one forever and senders could not count on it being read. Submit now
takes `wait_ms` with `attach` (protocol 45): once no call has taken the
note in by then, the daemon delivers it as a steer sent then would, joining
the running turn or starting a turn of its own, and its `queued` event says
`lapsed`. Rows keep their wait and due time (schema 76, a partial index on
the due attached rows); the run loop looks when the first is due.

The daemon keeps no default. The agent CLI and Sonny's trigger notes send
`attach_wait` from config.toml, a day unless it says otherwise, "0" for no
limit; `agent run --attach-wait` sets one note's. Sonny says nothing when a
note lapses, and the coordination skill tells leads attach notes arrive
within a day.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGG5PKzf3A9NDuvu9Xu
# Conflicts:
#	sonny/FEATURES.md
#	sonny/README.md
#	sonny/src/main.rs
@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-01T10:21:54.862673Z 2d391cd New commits
🔒 Security Review ✅ Completed 2026-11-01T09:08:07.552712Z dc3554d 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.

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

ℹ️ 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 src/store/db.rs Resolved
Comment thread src/server/mod.rs Resolved
A look cloned every active turn's steer flag to arm the few it delivers;
it now reads the due bots first and takes only theirs, arming any that came
due in between once the job is back. A deleting bot's due note kept
`next_due` in the past while `lapse` passed it over, so the timer fired
empty at once, over and over; the deadline now uses the sweep's own test.

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

@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: 03b9da59ac

ℹ️ 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 src/server/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: 708c64e84a

ℹ️ 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 src/server/mod.rs Resolved
…tried

A lapse job that hit a storage error stopped the daemon through the run
loop's ?, ending every running turn for one due note. A look now writes
its batch in one savepoint, so a refused write leaves every note attached
and due, and the loop looks again after the storage backoff that ready
turns use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGG5PKzf3A9NDuvu9Xu
@lydakis
lydakis merged commit 791ce90 into main Nov 1, 2026
10 checks passed
lydakis pushed a commit that referenced this pull request Nov 1, 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