Skip to content

Keep Grok Bot transcripts readable across unmapped entry shapes - #510

Merged
kjgbot merged 3 commits into
mainfrom
fix/grok-bot-session-read
Oct 17, 2026
Merged

kjgbot merged 3 commits into
mainfrom
fix/grok-bot-session-read

Conversation

@kjgbot

@kjgbot kjgbot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Opening a Grok Bot session in the Agent Relay sessions view (Grok-Bot · Local transcript) fails with Couldn't read this session. Probe could not finish.

The session appears in the list because discovery's shallow read only checks the replica header and its bounded head/tail. Hydration, though, parses the full replica and stops on the first entry it can't map: a missing id, a duplicate id, a role other than user/assistant, a send-message with no message.type, a toAgent/fromAgent peer that isn't a bc-… cloud agent, or a roster whose schemaVersion isn't 4. Any one of these fails the whole session with an untyped GROK_BOT_* error. The relay-desktop probe's reader (probe/src/probe/transcript.rs → store.hydrate) has no safe message for that error, so it falls back to the generic text at probe/src/probe/main.rs:310.

The plan's shape table comes from a single Grok Bot 0.70.2 install, so entry shapes that vary between installs or app versions break reads without warning.

Fix

  • valid_replica now returns only keyable entries, skipping any entry without a usable kind/id/timestampMs and any repeated id, instead of failing the replica.
  • A message with a role the adapter doesn't map, and a send-message with no type, are each recorded as a session marker.
  • A delegation peer that isn't bc-… keeps its message evidence, but no relationship edge is created.
  • The roster only supplies titles. If it's unreadable, too large or in a newer schema, the transcript still hydrates; only the title is lost. Rows are still read when present.

Regression fixture

tests/fixtures/grok-bot/replicas/drift-{replica,roster}.json holds invented data only. They are not in the corpus manifest, so existing snapshots don't change. grok_bot_unmapped_entry_shapes_and_newer_roster_still_hydrate stages them over the complete fixture. On main it fails with HydrationFailed("GROK_BOT_INVALID_RECORD: missing/invalid id"); with this change it passes, along with the existing Grok Bot tests.

Not verified

Grok Bot isn't installed on the machine this was built on, so the live session be32c8af-… wasn't replayed. The fix covers every strict check that can fail hydration while discovery still succeeds.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Changes ingest semantics for Grok Bot (skipped entries, markers, roster leniency) which could alter stored transcripts versus strict failure, but scope is limited to that provider.

Overview
Grok Bot hydration no longer aborts the whole session when the local transcript replica or roster drifts from the shapes this adapter was written for.

Replica parsing skips entries missing a valid kind/id/timestampMs or with duplicate ids instead of returning GROK_BOT_INVALID_RECORD. Unknown message roles and send-message entries without a type are stored as markers rather than errors. Delegation edges are only created for bc-… cloud-agent peers; other toAgent/fromAgent peers still contribute message text. Roster files are treated as optional title metadata—unreadable, oversized, or newer-schema rosters no longer block acquire/hydrate, and title updates ignore rows that omit name/title. Truncated-window detection uses the native first replica entry so a skipped malformed tbs0 is not misread as a trimmed tail.

Regression coverage adds drift fixtures and tests for partial entry shapes, bad rosters, and skipped opening entries.

Reviewed by Cursor Bugbot for commit 774ec09. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 400cfb07 · opened via gh pr create · last active 2026-10-17

Hydration rejected the whole replica when one entry lacked an id, carried
a role other than user/assistant, had an untyped send-message, named a
non-bc delegation peer, or when the roster used a schema other than v4.
Discovery reads only the bounded head/tail, so the session listed but
every open failed with an untyped GROK_BOT_* error that the desktop probe
reports as "Probe could not finish".

Unkeyable or duplicate entries are now skipped, unmapped shapes become
markers, non-bc peers keep their message without a relationship edge, and
an unreadable or newer roster only drops the title.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Session-Id: 400cfb07-41a9-4175-9ae3-935c13b8aa7c
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: afb03d5f-a935-46df-987a-75bb63a87462
📥 Commits

Reviewing files that changed from the base of the PR and between 010e2b4 and 774ec09.

📒 Files selected for processing: 4
  • CHANGELOG.md
  • crates/ai-hist/src/providers/grok_bot/mod.rs
  • crates/ai-hist/src/providers/grok_bot/normalize.rs
  • crates/ai-hist/tests/provider_grok_bot.rs
📝 Walkthrough

Grok Bot transcript reads now filter invalid or duplicate replica entries, continue without an unavailable or unparseable roster, and retain markers for unsupported message shapes. A new test covers hydration with drifted replica and roster fixtures.

Changes: Grok Bot transcript handling

Layer / File(s) Summary
Replica and roster acquisition
crates/ai-hist/src/providers/grok_bot/format.rs, crates/ai-hist/src/providers/grok_bot/mod.rs
Replica validation filters entries with invalid fields or repeated IDs. Roster read, parse, or size-limit failures no longer prevent acquisition.
Transcript normalization
crates/ai-hist/src/providers/grok_bot/normalize.rs
Unsupported roles and message types receive marker or fallback values. Invalid peer IDs are ignored; valid IDs continue through relationship handling.
Drift fixture and hydration coverage
crates/ai-hist/tests/fixtures/grok-bot/replicas/*, crates/ai-hist/tests/provider_grok_bot.rs, CHANGELOG.md
New fixtures and a provider test cover hydration with a drifted replica and schema-version-5 roster. The changelog records the transcript-read handling.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: khaliqgant

Merge Risk: 🔵 Low · up to 010e2

Sessions may lose an existing title when a newer roster schema omits the recognized title fields. This is a narrow, low-impact issue that is worth fixing before or soon after merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: keeping Grok Bot transcripts readable when entries use unmapped shapes.
Description check Passed The description directly explains the hydration failures, the resilience changes, the regression fixture, and the verification status. It is fully related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads the records with care,
It skips odd entries here and there.
A marker stands where roles don’t fit,
A missing roster won’t stop it.
The drifted transcript now comes through,
And carrots wait for testing too.

Comment @coderabbitai help to get the list of available commands.

@capy-ai capy-ai 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.

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

devin-ai-integration[bot]

This comment was marked as resolved.

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the latest change preserves the title check.

Summary

Grok Bot transcripts stay readable when some entries cannot be mapped or the roster cannot be read.

  • Grok Bot keeps usable entries when other replica rows drift.
  • Unmapped Grok Bot messages stay visible without false child links.
  • Grok Bot sessions stay readable when roster titles are unavailable.

Reviews (3) · Last reviewed commit: "Format Grok Bot title guard for both rus..." · Reviewed by Greptile

greptile-apps[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

kjgbot added 2 commits October 16, 2026 21:09
A roster row that omits both name and title no longer clears the saved
title, an unreadable roster path no longer aborts enumeration, and
truncation is judged from the native first entry so a skipped malformed
tbs0 is not reported as a trimmed window.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Session-Id: 400cfb07-41a9-4175-9ae3-935c13b8aa7c
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Session-Id: 400cfb07-41a9-4175-9ae3-935c13b8aa7c

@capy-ai capy-ai 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.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@kjgbot
kjgbot merged commit 8b3acd9 into main Oct 17, 2026
14 checks passed
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