fix(rust-sdk): ag-ui-core — round-trip non-UUID Thread/Run/Message/Agent IDs#2196
fix(rust-sdk): ag-ui-core — round-trip non-UUID Thread/Run/Message/Agent IDs#2196martinsotirov wants to merge 2 commits into
Conversation
…ent IDs The ID newtypes were strict Uuid wrappers whose FromStr/Deserialize rejected any non-UUID string, but the AG-UI protocol treats these IDs as plain strings. This makes them accept and round-trip arbitrary strings (UUID-v5 hash for the Uuid view, original string preserved for Display/serialize), so non-UUID IDs (LangGraph lc_run--…, composite ids) interoperate. Extracted from Mike Schirtzinger's fix on the ag-ui-protocol#972 server-crate branch (90b5205, 5e50a9f), rebased onto main as a focused standalone change: just crates/ag-ui-core/src/types/ids.rs + enabling the uuid `v5` feature. Fixes ag-ui-protocol#2195. Co-authored-by: Mike Schirtzinger <155995654+MikeSchirtzinger@users.noreply.github.com>
Addresses cross-model review of the initial fix. The extraction keyed PartialEq/Hash/Serialize on the UUID-v5 backing value, so distinct strings could collide — and ag-ui-client uses HashSet<&MessageId>. Make the exact protocol string the identity for PartialEq/Eq/Hash/ Serialize/Display; the UUID becomes a derived compatibility view only (as_uuid/From<Uuid>/Into<Uuid>/AsRef<Uuid>/PartialEq<Uuid> unchanged). new() preserves the exact input string for BOTH UUID- and non-UUID- shaped inputs, so different spellings of the same UUID stay distinct — matching the plain-string IDs of the AG-UI protocol and TS SDK. Also updates Cargo.lock for the uuid `v5` feature (sha1_smol), which the prior commit left stale (--locked builds would otherwise fail). Tests: identity independent of the backing UUID; UUID-spelling distinctness; exact-spelling + serde round-trip preservation.
|
Pushed a follow-up commit (
|
Fixes #2195.
What
ThreadId/RunId/MessageId/AgentIdwere strictUuidnewtypes whoseFromStr/Deserializerejected any non-UUID string. The AG-UI protocol (and the TS@ag-ui/core) treat these IDs as plain strings, so any server with non-UUID IDs (LangGraphlc_run--…, composite/namespaced IDs) couldn't round-trip events through the Rust SDK.This makes the newtypes accept and round-trip arbitrary strings — a UUID-v5 hash backs the
as_uuid()view while the original string is preserved forDisplay/serialize — so valid UUIDs behave exactly as before and non-UUID IDs now interoperate.Provenance
The fix itself is @MikeSchirtzinger's work from the server-crate branch (#972), commits
90b5205e+5e50a9f3. It's currently entangled in that large, unmerged PR. This PR extracts just theids.rschange, rebased onto currentmain, so it can land independently of the server crate. Full credit to Mike (co-authored).Changes (minimal + focused)
crates/ag-ui-core/src/types/ids.rs— the round-trip implementation + tests.Cargo.toml— enable the uuidv5feature (needed fornew_v5). Nothing else.Verification
Against current
main(edition 2024):cargo build -p ag-ui-coreandcargo test -p ag-ui-coreboth pass, includingtest_serialize_roundtrip_arbitrary_string,test_run_id_deserialize_non_uuid_string,test_message_id_deserialize_langgraph_format.Happy to adjust scope or squash as maintainers prefer.