fix(agent): make AgentEvent::Warning a struct variant so it serializes#126
Merged
Conversation
AgentEvent is internally tagged (#[serde(tag = "type")]), and serde
cannot inject the tag into a newtype variant wrapping a bare string, so
every Warning event failed to persist with 'cannot serialize tagged
newtype variant AgentEvent::Warning containing a string'. The live
timeline still rendered warnings, but they were silently dropped from
the JSONL log and lost on session resume.
Warning(String) becomes Warning { message: String }, matching the
sibling Error { message, fatal } shape. No on-disk compatibility
concern: the old shape never serialized successfully. Adds a serde
round-trip test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
AgentEventis internally tagged (#[serde(tag = "type")],crates/agent/src/lib.rs), andWarning(String)was the only variant wrapping a bare primitive. Serde cannot inject the"type"tag into a plain string, soStore::append_eventfailed at runtime with:The live timeline still rendered warnings (folding happens regardless of persistence), which is why the app appeared unaffected — but every Warning event was silently dropped from the JSONL log and lost on session resume.
Fix
Warning(String)→Warning { message: String }, matching the siblingError { message, fatal }shape; serializes as{"type":"warning","message":"…"}. All construction/match sites updated (compiler-enforced). Adds a serde round-trip test.No on-disk compatibility concern: the old shape never serialized successfully, so no legacy data exists.
Other newtype variants (
TokenUsage(TokenUsage),ItemStarted(ThreadItem), …) wrap structs, which serialize as maps and accept the tag — they are unaffected, as are the other#[serde(tag = "kind")]enums in the file.Verification
cargo fmt --all --check✅cargo clippy --workspace --all-targets --locked -- -D warnings✅cargo test --workspace --locked✅ (one pre-existing, environment-only failure intermPTY test locally; fails identically on unchangedmain)🤖 Generated with Claude Code