Skip to content

fix(reflection): count canonical assistant steps - #3795

Draft
just-cameron wants to merge 2 commits into
mainfrom
cameron/fix-reflection-step-count
Draft

fix(reflection): count canonical assistant steps#3795
just-cameron wants to merge 2 commits into
mainfrom
cameron/fix-reflection-step-count

Conversation

@just-cameron

Copy link
Copy Markdown
Contributor

Overlord (agent-c2adbf5c-8419-4211-8cd8-3740db164974)

Problem

A single backend assistant message can become several transcript rows when the CLI splits long output for display. Reflection cadence counted each row as a completed step. One long response could therefore reach the configured step threshold early.

Change

  • Count each non-empty backend assistant message ID once per completed turn.
  • Keep one-row-per-step behavior when a transcript row has no backend message ID.
  • Migrate older reflection state from transcript history.
  • Clear legacy cursors that no longer exist, so migration cannot skip unreflected content.
  • Advance reflected cursors past all rows that share the same canonical message ID.
  • Preserve every transcript fragment in reflection payloads.

Normal completed-turn accounting remains O(delta). Full transcript scans occur only for migration, external-source filtering, and payload/finalization paths that already need transcript history.

Validation

  • Regression test uses the accumulator streaming path to create two display rows with one backend message ID.
  • The regression suite fails against the parent implementation and passes with this change.
  • Focused reflection suites: 43 passed, 0 failed.
  • bun run check: 12/12 checks passed.
  • Independent adversarial review found one missing-cursor migration case; the branch includes the repair and a regression test.

Risk

This changes local reflection state schema from v3 to v4. Existing v2 and v3 state rebuilds counters from transcript history. Missing canonical IDs retain the prior row-count behavior.

👾 Generated with Letta Code

just-cameron and others added 2 commits August 11, 2026 12:39
Letta Code (agent-c2adbf5c-8419-4211-8cd8-3740db164974)

Count backend assistant message IDs once so rendering splits do not advance reflection cadence. Migrate older transcript state conservatively and advance reflected cursors past all fragments of a canonical message.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
Letta Code (agent-c2adbf5c-8419-4211-8cd8-3740db164974)

Discard legacy reflection cursors that no longer exist in the transcript so later ID reuse cannot skip older unreflected content.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
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.

1 participant