Skip to content

feat(comms): carry the agent turn sequence to the stored message and the settle sink (RIG-4323) - #1617

Open
rigel-mintaka wants to merge 6 commits into
compass-managed/rig-4325-turn-bounded-settlefrom
compass-agent/rig-4324-turn-sequence-agent
Open

rigel-mintaka wants to merge 6 commits into
compass-managed/rig-4325-turn-bounded-settlefrom
compass-agent/rig-4324-turn-sequence-agent

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Agent half of T1 in the settle turn-order record (DL-382). Stacks on #1603, the current top of the #1602 line, so the stack stays linear. This change needs only #1602's proto fields.

  • TurnSequence (packages/compass-agent/src/turn-sequence.ts) is a per-session-identity counter. agent_start increments it, and each new value is written as an SDK custom session entry (compass_turn_sequence). The entry travels in the transcript, so a resume of the same session id continues from the highest stored value. A new session id starts at 1. The counter refuses to pass int64 max.
  • EventMapper stamps the value on the internal SessionFrame.turn_sequence of the agent_end frame. The server copies it to the public frame. Other frames stay 0.
  • All three comms post builders stamp PostMessageRequest.turn_sequence.

Tests: successive turns stamp 1, 2, 3 on agent_end; a post carries the current turn; a stored value is restored; a new identity starts at 1; the int64 ceiling. A real SessionManager round trip (write, close, open) continues at 3. That test fails if the custom entry is not written.

Merge order: land #1704 (RIG-4418) before this. Without it, a Reload restarts the SDK session and the counter goes back to 1 while the server still holds the old settle value. This PR stays draft until #1704 merges; then it is rebased onto main, re-reviewed, and promoted.

Refs RIG-4324

Co-authored-by: Matt Wilkinson matt@rigel.build

@trunk-io

trunk-io Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

❌ This stack could not start testing because there was a merge conflict. See more details here.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@linear-code

linear-code Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RIG-4323

RIG-4324

@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 4, 2026 12:54
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-agent-rig-4324-turn.compass-eng-docs.pages.dev

Deployed from compass-agent/rig-4324-turn-sequence-agent at 895aaea.

@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 4, 2026 16:04
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 4, 2026 16:05
@rigel-mintaka
rigel-mintaka force-pushed the compass-agent/rig-4324-turn-sequence-agent branch from 9da05bc to 6df6ebf Compare October 5, 2026 18:13
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 18:13
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 18:13
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 18:52
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 18:52
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 19:00
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 19:00
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 19:13
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 19:13
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 19:42
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 19:42
@rigel-mintaka
rigel-mintaka force-pushed the compass-agent/rig-4324-turn-sequence-agent branch from 2f02d6d to 2c810c3 Compare October 5, 2026 20:09
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 5, 2026 20:10
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 5, 2026 20:10
@rigel-mintaka
rigel-mintaka marked this pull request as ready for review October 5, 2026 22:07
@rigel-mintaka
rigel-mintaka force-pushed the compass-agent/rig-4324-turn-sequence-agent branch from 2c810c3 to 15e495f Compare October 6, 2026 05:50
@rigel-mintaka
rigel-mintaka changed the base branch from compass-managed/rig-4325-turn-bounded-settle to main October 6, 2026 05:50
@rigel-mintaka
rigel-mintaka changed the base branch from main to compass-managed/rig-4325-turn-bounded-settle October 6, 2026 05:50
@mattwilkinsonn
mattwilkinsonn added this pull request to stack #1823 October 7, 2026 00:21
@mattwilkinsonn

Copy link
Copy Markdown
Contributor

/trunk merge

@rigel-mintaka
rigel-mintaka force-pushed the compass-agent/rig-4324-turn-sequence-agent branch from 15e495f to 813d73e Compare October 7, 2026 01:53
rigel-mintaka and others added 6 commits October 7, 2026 00:03
…G-4324)

compass-agent keeps a per-session-identity turn counter. agent_start
increments it, comms posts carry it on PostMessageRequest.turn_sequence, and
the agent_end SessionFrame carries it on turn_sequence. Each new value is
written as an SDK custom session entry, so a resume of the same session id
continues from the transcript. A new session id starts at 1.

Refs RIG-4324

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…t (RIG-4324)

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…he turn sequence (RIG-4324)

The SDK can supersede or drop an agent_end, which desynced the FIFO
start/end pairing and stamped every later settle one turn behind. A
terminal end now settles the current sequence and clears the queues.
An in-place SDK identity change no longer restores a lower sequence,
since the server's settle mark outlives it.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…tled (RIG-4324)

A control prompt can start the next run in the gap between the core
agent_end and the session's terminal end. Settling current() there fired
that run's holds while it streamed. Settle below the first core start
whose session agent_start has not been seen.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…G-4324)

The core loop goes idle before the session emits its terminal agent_end, so
a raw control prompt in that window started a run the pending end settled.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…rops stale starts (RIG-4324)

Waiting on waitForIdle covers the trailing session end, scheduled continues, and a
missing end. With no early core start possible, a terminal end clears captured starts.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-agent/rig-4324-turn-sequence-agent branch from 813d73e to 895aaea Compare October 7, 2026 04:06

This branch has not been deployed

No deployments
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