From cfd367ce2f918089a4354351061449aa214fd030 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Thu, 29 Oct 2026 14:43:58 -0500 Subject: [PATCH 1/2] The wire capture records whole messages, so a native tool result is no longer read as a lost body Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/cognition/llm_deliberation_faculty.rs | 9 ++++--- .../llm_deliberation_faculty/tests/mod.rs | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs b/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs index 2b6552b0d1..475bfcda83 100644 --- a/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs +++ b/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs @@ -718,11 +718,10 @@ fn append_wire_capture(dir: &std::path::Path, persona_id: Uuid, persona_name: &s let row = serde_json::json!({ "ts_ms": continuum_base::time::EpochMs::now().millis(), "persona": persona_name, - "messages": request - .messages - .iter() - .map(|m| serde_json::json!({"role": m.role, "text": m.content_text()})) - .collect::>(), + // Whole messages, every part: a text-only projection dropped native tool calls and + // results, so her newest result read as a bare label in the one input of record + // (Aiko, the M5, 2026-10-29: a result counted as lost was on the wire). + "messages": request.messages, }); let _ = std::fs::create_dir_all(dir); use std::io::Write as _; diff --git a/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs b/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs index 9eda760308..ba26c630ff 100644 --- a/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs +++ b/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs @@ -17,6 +17,30 @@ fn a_turn_in_her_mind_room_writes_zero_wire_capture_bytes() { assert!(std::fs::metadata(&file).expect("row written").len() > 0, "an ordinary room still captures"); } +// what this catches (the M5, 2026-10-29): the wire capture keeping only Text parts, so a +// native tool result (her newest result rides as one) was recorded as its label alone and +// read as a lost body. The capture must carry every part of every message. +#[test] +fn the_wire_capture_records_native_tool_results_whole() { + let dir = tempfile::tempdir().expect("wire capture dir"); + let persona = uuid::Uuid::new_v4(); + let request = crate::ai::types::TextGenerationRequest { + messages: vec![crate::ai::types::ChatMessage { + role: "tool".into(), + content: crate::ai::types::MessageContent::Parts(vec![crate::ai::types::ContentPart::ToolResult { + tool_use_id: "call-1".into(), + content: "nothing to commit, working tree clean".into(), + is_error: None, + }]), + name: None, + }], + ..Default::default() + }; + super::append_wire_capture(dir.path(), persona, "Aiko", uuid::Uuid::new_v4(), &request); + let row = std::fs::read_to_string(dir.path().join("Aiko.wire.jsonl")).expect("row written"); + assert!(row.contains("nothing to commit, working tree clean"), "{row}"); +} + // what this catches (Kimi, 2026-09-25): a cut act must leave her a record of what // she was composing and that it did not land; a long payload is trimmed to its two // edges so the record cannot crowd the retry the way the payload did. From 2413319d656b385d796e0a175ff909621183cdb5 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Thu, 29 Oct 2026 15:11:54 -0500 Subject: [PATCH 2/2] Wire capture: the test round-trips every message whole (ordered typed parts, ids, error flag); the doc names the boundary as the adapter's input (Codex on #5592) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/cognition/llm_deliberation_faculty.rs | 6 ++-- .../llm_deliberation_faculty/tests/mod.rs | 35 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs b/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs index 475bfcda83..a187f50c8c 100644 --- a/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs +++ b/core/continuum-cognition/src/cognition/llm_deliberation_faculty.rs @@ -708,8 +708,10 @@ fn occupancy_of(shape: TurnShape, prefill_tps: f64, decode_tps: f64) -> Option/.wire.jsonl` (the wire capture, -/// sink 4 of PRIVACY-OF-THOUGHT.md). A turn in her mind room writes nothing. +/// Append one request's message list, whole, to `/.wire.jsonl` (the wire capture, +/// sink 4 of PRIVACY-OF-THOUGHT.md). A turn in her mind room writes nothing. The boundary is the +/// ADAPTER'S INPUT (`TextGenerationRequest::messages`), not the HTTP body an adapter serializes +/// from it; a write failure is silent here, so a missing row is never evidence no request ran. fn append_wire_capture(dir: &std::path::Path, persona_id: Uuid, persona_name: &str, room_id: Uuid, request: &TextGenerationRequest) { if crate::cognition::mind_room::is_private_room(persona_id, room_id) { crate::cognition::mind_room::note_withheld(persona_id, "wire_capture"); diff --git a/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs b/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs index ba26c630ff..b886c709cf 100644 --- a/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs +++ b/core/continuum-cognition/src/cognition/llm_deliberation_faculty/tests/mod.rs @@ -18,27 +18,38 @@ fn a_turn_in_her_mind_room_writes_zero_wire_capture_bytes() { } // what this catches (the M5, 2026-10-29): the wire capture keeping only Text parts, so a -// native tool result (her newest result rides as one) was recorded as its label alone and -// read as a lost body. The capture must carry every part of every message. +// native tool call or result (her newest result rides as one) was recorded as its label alone +// and read as a lost body. Every message must round-trip whole: role, name, and its typed parts +// in order with their ids and error flag. #[test] -fn the_wire_capture_records_native_tool_results_whole() { +fn the_wire_capture_records_every_message_whole() { + use crate::ai::types::{ChatMessage, ContentPart, MessageContent}; let dir = tempfile::tempdir().expect("wire capture dir"); let persona = uuid::Uuid::new_v4(); - let request = crate::ai::types::TextGenerationRequest { - messages: vec![crate::ai::types::ChatMessage { + let messages = vec![ + ChatMessage { + role: "assistant".into(), + content: MessageContent::Parts(vec![ + ContentPart::Text { text: "checking the tree".into() }, + ContentPart::ToolUse { id: "call-1".into(), name: "code/shell".into(), input: serde_json::json!({"cmd": "git status"}) }, + ]), + name: Some("Aiko".into()), + }, + ChatMessage { role: "tool".into(), - content: crate::ai::types::MessageContent::Parts(vec![crate::ai::types::ContentPart::ToolResult { + content: MessageContent::Parts(vec![ContentPart::ToolResult { tool_use_id: "call-1".into(), content: "nothing to commit, working tree clean".into(), - is_error: None, + is_error: Some(false), }]), name: None, - }], - ..Default::default() - }; + }, + ]; + let request = crate::ai::types::TextGenerationRequest { messages: messages.clone(), ..Default::default() }; super::append_wire_capture(dir.path(), persona, "Aiko", uuid::Uuid::new_v4(), &request); - let row = std::fs::read_to_string(dir.path().join("Aiko.wire.jsonl")).expect("row written"); - assert!(row.contains("nothing to commit, working tree clean"), "{row}"); + let row: serde_json::Value = serde_json::from_str(std::fs::read_to_string(dir.path().join("Aiko.wire.jsonl")).expect("row written").trim()).expect("row is json"); + let recorded: Vec = serde_json::from_value(row["messages"].clone()).expect("messages deserialize"); + assert_eq!(serde_json::to_value(&recorded).expect("recorded"), serde_json::to_value(&messages).expect("sent")); } // what this catches (Kimi, 2026-09-25): a cut act must leave her a record of what