Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(claude-code): assert the bytes, not that an event arrived

Nguyen Thanh Dat05d73c61e35d
diff --git a/src/openhuman/inference/provider/claude_code/stream_parser_tests.rs b/src/openhuman/inference/provider/claude_code/stream_parser_tests.rs
index 92012799e1..36b6cdc4ae 100644
--- a/src/openhuman/inference/provider/claude_code/stream_parser_tests.rs
+++ b/src/openhuman/inference/provider/claude_code/stream_parser_tests.rs
@@ -189,6 +189,18 @@ fn feed_bytes_preserves_a_character_split_across_chunks() {
events.extend(p.feed_bytes(&bytes[split..]));
assert_eq!(events.len(), 1);
+
+ // `ParseError` carries the original line, so its Debug rendering contains
+ // the emoji too — matching the variant is what separates "decoded across
+ // the boundary" from "failed to parse and echoed the bytes back".
+ let ClaudeCodeEvent::Assistant { message } = &events[0] else {
+ panic!("expected an Assistant event, got {:?}", events[0]);
+ };
+ assert_eq!(
+ message["text"], "héllo 世界 🌍 tail",
+ "the character split across the two chunks must survive intact"
+ );
+
let rendered = format!("{:?}", events[0]);
assert!(
rendered.contains("héllo 世界 🌍 tail"),
@@ -214,4 +226,16 @@ fn feed_bytes_still_replaces_genuinely_invalid_bytes() {
1,
"the line must still be emitted, not withheld"
);
+
+ // Not just "an event arrived": the invalid byte has to have been REPLACED.
+ // Dropping it would also emit one event and would also parse, so the count
+ // alone cannot tell the two apart.
+ let ClaudeCodeEvent::System { session_id, .. } = &events[0] else {
+ panic!("expected a System event, got {:?}", events[0]);
+ };
+ assert_eq!(
+ session_id.as_deref(),
+ Some("\u{FFFD}"),
+ "0xFF must decode to the replacement character, not vanish"
+ );
}