Skip to content

fix: preserve chronological position of deduplicated token events#64

Merged
ColeMurray merged 1 commit into
mainfrom
fix/token-dedup-ordering
Feb 5, 2026
Merged

fix: preserve chronological position of deduplicated token events#64
ColeMurray merged 1 commit into
mainfrom
fix/token-dedup-ordering

Conversation

@ColeMurray
Copy link
Copy Markdown
Owner

Summary

Fixes a regression from #63 where the assistant's complete response text rendered above tool calls instead of below them.

The previous token dedup replaced content at the first token's array slot. Since the first token for a message appears before tool calls but the final cumulative token appears after them, this placed the complete response text before all tool call cards in the UI.

Fix: Instead of replacing at the first occurrence's position, null out the old slot and push the latest token at its actual chronological position. Nulls are filtered out before grouping.

Before/After

Before: Summary response appears above tool calls
After: Summary response appears at its correct position after tool calls

Test plan

  • npm run typecheck -w @open-inspect/web
  • npm run test -w @open-inspect/web
  • npm run build -w @open-inspect/web
  • Verify in browser: load a session with tool calls and confirm the assistant response appears after them

The previous token dedup replaced content at the first token's array
position. Since the first token appears before tool calls but the final
cumulative token appears after, this caused the complete response text
to render above tool calls instead of below them.

Instead, null out the old slot and push the latest token at its actual
chronological position, then filter nulls before grouping.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 5, 2026

Greptile Overview

Greptile Summary

Fixed token deduplication to preserve chronological position of assistant responses. The previous implementation replaced tokens at the first occurrence's array index, causing complete responses to render before tool calls instead of after them. The fix nulls out old positions and pushes the latest token at its actual chronological position, then filters nulls before grouping.

@ColeMurray ColeMurray merged commit 5613b6a into main Feb 5, 2026
7 checks passed
@ColeMurray ColeMurray deleted the fix/token-dedup-ordering branch February 5, 2026 00:27
bleleve added a commit to bleleve/background-agents that referenced this pull request May 22, 2026
…feedback on ColeMurray#64)

fountain-reef reviewer flagged that `slack.channel_info.missing` was
overloaded: it fired both for Slack-returned `ok: false` (operator-
actionable — missing scope, channel_not_found) and for the anomalous
`ok: true` / no `channel` field case. Mixed events make alerting harder.

Split into three distinct event names so each failure mode can be filtered
or alerted on independently:

- `slack.channel_info.api_error` — Slack API returned `ok: false` with a
  structured error (typically a permission or configuration issue).
- `slack.channel_info.missing` — `ok: true` but no `channel` field
  (Slack-side anomaly; should not happen per the API contract).
- `slack.channel_info.fetch_failed` — transport-level exception before
  any envelope was parsed (renamed from `slack.channel_info.error` to
  avoid name overlap with the API-error case).

No behaviour change; only log-event naming.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bleleve added a commit to bleleve/background-agents that referenced this pull request May 22, 2026
…feedback on ColeMurray#64)

fountain-reef reviewer flagged that `slack.channel_info.missing` was
overloaded: it fired both for Slack-returned `ok: false` (operator-
actionable — missing scope, channel_not_found) and for the anomalous
`ok: true` / no `channel` field case. Mixed events make alerting harder.

Split into three distinct event names so each failure mode can be filtered
or alerted on independently:

- `slack.channel_info.api_error` — Slack API returned `ok: false` with a
  structured error (typically a permission or configuration issue).
- `slack.channel_info.missing` — `ok: true` but no `channel` field
  (Slack-side anomaly; should not happen per the API contract).
- `slack.channel_info.fetch_failed` — transport-level exception before
  any envelope was parsed (renamed from `slack.channel_info.error` to
  avoid name overlap with the API-error case).

No behaviour change; only log-event naming.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bleleve added a commit to bleleve/background-agents that referenced this pull request May 22, 2026
…feedback on ColeMurray#64)

fountain-reef reviewer flagged that `slack.channel_info.missing` was
overloaded: it fired both for Slack-returned `ok: false` (operator-
actionable — missing scope, channel_not_found) and for the anomalous
`ok: true` / no `channel` field case. Mixed events make alerting harder.

Split into three distinct event names so each failure mode can be filtered
or alerted on independently:

- `slack.channel_info.api_error` — Slack API returned `ok: false` with a
  structured error (typically a permission or configuration issue).
- `slack.channel_info.missing` — `ok: true` but no `channel` field
  (Slack-side anomaly; should not happen per the API contract).
- `slack.channel_info.fetch_failed` — transport-level exception before
  any envelope was parsed (renamed from `slack.channel_info.error` to
  avoid name overlap with the API-error case).

No behaviour change; only log-event naming.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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