Skip to content

Sonny: a margin holds 6 notes of 12 lines, and says so past either (G6) - #761

Merged
lydakis merged 7 commits into
mainfrom
claude/wave2-margin-limits
Nov 7, 2026
Merged

lydakis merged 7 commits into
mainfrom
claude/wave2-margin-limits

Conversation

@lydakis

@lydakis lydakis commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Wave 2, G6. Part of #670. Builds on #742.

What changes

A margin held 20 notes, and a new one past that silently pushed out the oldest. A note's length was bounded only by bytes. Now:

  • [sonny] margin_notes defaults to 6, and a new [sonny] margin_note_lines defaults to 12. Both are configurable, at least 1, and listed in /config.
  • A margin call past either limit is refused, and the agent is told why in the tool's answer. A refusal changes nothing in the margin.
  • Lines are counted in the note's Markdown source, not in drawn rows, so the window's width changes nothing. A note that shows a file or a task's note (from) isn't limited by length. Removing a note is never refused.
  • Notes kept from before a lower limit stay. Only a new note waits for room, and those notes can still be changed in place.

How the agent is told

margin used to be declared with a fixed result ("In the margin."), so nothing could refuse it. It's now answered by Sonny's tool host (answered_by), like memory or show_agent. The host reads the margin as it stands from the bot's history, counting each call as it was answered (a call taken under higher limits stays taken). It reads on from its own checkpoint, kept apart from the window's file and never past a call still waiting on its answer, so each call reads only what came since. A side chat's margin starts at its fork, so its source's notes don't count against it. Calls made together (several in one response) are answered in the order they were made, so together they never take more than the margin holds. Then it answers "In the margin." or refuses with a typed code:

Code Detail the agent reads
margin_full the margin holds 6 notes and takes at most 6: n1, n2, n3, n4, n5, n6. Post one of those ids again to change that note, or remove one that no longer holds
margin_note_too_long the note is 13 lines and a margin note holds at most 12: keep it to what the person looks at more than once, or write the longer text to a file and show that file in the note

The tool description doesn't mention the limits: an agent learns them when a call meets one, from the refusal, which gives the limit, the notes there, and suggests a file. (A sentence about them in the description put a lead's declared Sonny tools 221 bytes over their budget of half the daemon's 64 KiB cap.)

Only the host refuses (margin::refusal). The window applies a margin call once it is answered and didn't fail, and a lead's view of a task's note does the same with the task's history, so what's drawn matches what the agent was told. (Before, the window drew a note as its call started; now it shows when Sonny answers, a moment later.)

Checked end to end

I ran a real daemon with a scripted model that posts seven notes, then a 13-line note, then removes one and posts the seventh again. The answers:

n1..n6  -> In the margin.
n7      -> margin_full (lists n1..n6)
n1 (13 lines) -> margin_note_too_long
n1 remove -> In the margin.
n7      -> In the margin.

The window shows notes 2 to 7, and note 1 kept its two lines.

Tests

  • a_note_past_the_most_is_refused_and_says_what_it_can_change: the first three of five stay, with the exact refusal text; a note already there still changes; removing one makes room; a lower limit keeps what's there, and replaying calls taken earlier keeps them too.
  • a_note_is_as_long_as_its_text_says_not_as_it_is_drawn: long lines that wrap count once; the exact refusal text; a long note taken before the limit was lowered stays; file, from and removal calls pass.
  • a_margin_call_is_answered_from_where_it_was_last_read_and_a_side_chat_s_from_its_copy: the host reads on from its checkpoint (reads start at 13, 13, 15), pairs a call with its later answer, and a side chat's first note is taken though its source held six.
  • margin_calls_made_together_take_no_more_than_the_margin_holds: five held and two new ones in one response: the first made is taken and the second refused, whichever is answered first.
  • a_note_shows_in_the_margin_once_taken_and_a_marker_pins_where: no note until the call is answered; a failed call changes nothing.
  • a_task_s_note_taken_away_by_the_person_starts_again_empty: a task's call refused there, or not answered yet, changes nothing in the lead's view until its answer says it was taken.
  • the_margin_is_answered_by_sonny_and_says_its_limits_are_told.
  • A task's note in its lead's margin is no longer pushed out by newer ones, and a too-long change leaves it as it was.
  • Config: defaults, a set value, and 0 refused for margin_note_lines.
  • cargo test -p sonny -p agent-client, clippy and fmt pass.

Performance

  • A margin call now waits on Sonny's tool host instead of a fixed result: one connection, one bots read, and the history since the host's checkpoint. A bot's first host-answered call reads its history once from the start (a side chat's from its fork); each later call reads only the nodes since, so the cost per call is the new history, with a few agents or with thousands.
  • Calls made together are checked in order on a scratch copy: work proportional to the calls still waiting, usually one or two.
  • A lead's view of a task's note keeps waiting only that note's own calls, so its memory doesn't grow with how many calls the task makes at once.
  • Drawing is unchanged: the window applies a call once it's answered, as before for history.

Upgrade notes

  • A margin with more than 6 notes keeps them all. The agent's next new note is refused until it removes some, and the refusal lists them. Set margin_notes higher to keep more.
  • margin calls now wait for Sonny's tool host to answer, as memory and the other Sonny tools do.


Generated by Claude Code

A margin call past either limit is refused, answered by Sonny with the
limit and the notes there or the note's length, where the oldest note
went silently. Notes kept from before a lower limit stay.

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

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T03:17:23.373299Z 0cb08ab New commits
🔒 Security Review ✅ Completed 2026-11-06T05:03:25.764663Z 0fc88bc 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: 0fc88bc8b8

ℹ️ 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/margin.rs Resolved
Comment thread sonny/src/margin.rs Resolved
Comment thread sonny/src/margin.rs Resolved
Comment thread sonny/src/margin.rs Resolved
…eckpoint

A margin call is refused only by the tool host's answer; the window, a
lead's view of a task's note, and the host's own replay go by each call's
recorded answer, so notes taken under higher limits stay. The window
applies a call once it is answered, not as it starts. The host keeps a
checkpoint beside the window's file and reads on from it, up to the first
call still waiting on its answer. A side chat's margin starts at its fork.

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

@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: 59a31ccc9b

ℹ️ 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/margin.rs Resolved
Comment thread sonny/src/margin.rs Resolved
A margin call made before this one and not answered yet counts as it
would be answered, so calls in one response never take more than the
margin holds. A lead's view of a task's note keeps only that note's own
calls waiting for their answers, however many the task made at once.

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

@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: 219b5e9e17

ℹ️ 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/margin.rs Resolved
A window's margin can be read past a call still waiting on its answer, so
the host no longer adopts it; it keeps its own, and a side chat's start
is seeded there.

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

@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: 6b450e549c

ℹ️ 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/margin.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: 9600462131

ℹ️ 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/margin.rs Resolved
@lydakis
lydakis merged commit dbea88d into main Nov 7, 2026
5 checks passed
@lydakis
lydakis deleted the claude/wave2-margin-limits branch November 7, 2026 03:38
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