Repository navigation
bt-daemon: let translators save and restore their state - #289
Merged
Merged
Conversation
Every translator is now serializable, and AgentTranslator requires a new TranslatorState trait with a blanket implementation for serde types. A translator's saved state is everything it still needs from events it has consumed to translate later ones, so a later pipeline can persist it instead of replaying those events. Sink-only row fields that wire JSON omits are preserved through a shared SinkFields codec, which the stored SpanOp codec now also uses. serde_json round-trips floats exactly so restored state matches what was saved. OpenCode v2 message parts the translator does not model are kept as raw JSON rather than rejected. A test resumes every agent's native stream from saved state after each event and requires output identical to an uninterrupted run; the shared native streams now include an OpenCode v2 session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Stephen Belanger (Qard)
added a commit
that referenced
this pull request
Nov 16, 2026
This branch already contained its own translator-state and import changes, so conflicts take this branch's side. Keeps #289's save-and-restore test for every agent alongside this branch's recovery tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
Match the crate's convention: derives name Serialize and Deserialize through a use serde import rather than serde:: paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stephen Belanger (Qard)
requested review from
Abhijeet Prasad (AbhiPrasad) and
Andrew Kent (realark)
November 16, 2026 12:36
Abhijeet Prasad (AbhiPrasad)
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of a stack that splits #276. This PR only covers translators and doesn't change storage or delivery.
Changes
TranslatorState.AgentTranslatornow requires aTranslatorStatetrait withsave_state/restore_state. A blanket impl covers anySerialize + DeserializeOwnedtype, so each translator derives serde on its state instead of writing a codec by hand. Wrappers (ConfiguredTranslator, turn lineage, OpenCode's v1/v2 dispatch) forward to the translator they wrap.SinkFields. Row fields the wire JSON leaves out (late_merge_key,late_merge_version,turn_span_id,is_turn) survive a save and restore through a sharedSinkFieldscodec. The existing stored-SpanOp codec uses it too, and its JSON shape is unchanged.serde_jsonhasfloat_roundtripon, so restored state is exactly what was saved.Tests
every_agent_resumes_from_saved_state_at_every_native_boundarysaves state after each event, restores it into a fresh translator, and requires the output to match an uninterrupted run exactly.cargo fmt --checkpasses. The suite ran with one known failure, and after the fix the three affected tests passed: the recovery test's coverage list needed a dedupe for OpenCode's second stream.🤖 Generated with Claude Code