Skip to content

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

test(session_host): register typed transcript compat test module

Steven Enamakela9f1bd5ea274
diff --git a/crates/openhuman-core/src/agent/session_host/mod.rs b/crates/openhuman-core/src/agent/session_host/mod.rs
index 30a18b8988..ed07fcf95e 100644
--- a/crates/openhuman-core/src/agent/session_host/mod.rs
+++ b/crates/openhuman-core/src/agent/session_host/mod.rs
@@ -73,4 +73,6 @@ mod orphaned_head_resume_tests;
#[cfg(test)]
mod transcript_compat_tests;
#[cfg(test)]
+mod typed_transcript_compat_tests;
+#[cfg(test)]
mod runtime_adapter_tests;
diff --git a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
index 8040eb2493..a2c1911370 100644
--- a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
@@ -228,7 +228,7 @@ fn place_fixture(root: &Path, scenario: &Scenario, stem: &str, variant: &str) {
fixture(&format!("{name}{variant}.jsonl")),
stem_path(root, stem),
)
- .expect("copy head fixture");
+ .expect("copy head fixture");
}
Layout::Chain => {
std::fs::copy(fixture(&format!("{name}.g0.jsonl")), stem_path(root, stem))
diff --git a/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs
new file mode 100644
index 0000000000..c1cab86065
--- /dev/null
+++ b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs
@@ -0,0 +1,185 @@
+//! Typed transcript rows against the #6872 compatibility corpus.
+//!
+//! The corpus in `tests/fixtures/session_compat/` was captured from the release
+//! that wrote string-envelope rows. Two gates, both reusing its goldens:
+//!
+//! - **Same rows, new on-disk form.** `<name>.typed.jsonl` is the legacy
+//! capture re-written by the current writer (tool calls, tool results and
+//! images stored as fields). Resuming it must give byte-identical committed
+//! history, frozen prefix, recorded tool list, journal projection and next
+//! provider request as the legacy file's golden: the typed form is purely an
+//! on-disk change.
+//! - **Old session, new binary.** A legacy file continued with a native tool
+//! round keeps its bytes, gains typed rows, and a fresh process resumes the
+//! mixed file to exactly what the continuing process held.
+//!
+//! Regenerate the `.typed` files only when deliberately re-deriving them:
+//! `OH_REGEN_SESSION_COMPAT=1 cargo test -p openhuman --lib regenerate_typed_session_compat -- --ignored`.
+
+use serde_json::{json, Value};
+use tinyagents_session::transcript::{read_transcript, write_transcript};
+use tinyinference_llm::message::ContentBlock;
+use tinyinference_llm::model::ModelResponse;
+
+use super::transcript_compat_tests::{
+ build_host, call, fixture, golden, model, response, run_async, snapshot_with, stem_path,
+ thread_id, Scenario, SCENARIOS,
+};
+
+/// Head fixtures that have a typed re-write (the chain and legacy layouts are
+/// multi-file and the compaction record is not a plain row list).
+const TYPED_SCENARIOS: &[&str] = &["plain", "native_tools", "image_user", "xml_tools"];
+
+fn scenario(name: &str) -> &'static Scenario {
+ SCENARIOS
+ .iter()
+ .find(|scenario| scenario.name == name)
+ .expect("scenario")
+}
+
+fn message_lines(raw: &str) -> Vec<Value> {
+ raw.lines()
+ .filter_map(|line| serde_json::from_str::<Value>(line).ok())
+ .filter(|value| value.get("role").is_some())
+ .collect()
+}
+
+#[test]
+fn typed_rewrites_of_the_corpus_resume_to_the_legacy_goldens() {
+ for name in TYPED_SCENARIOS {
+ run_async(async move {
+ let got = snapshot_with(scenario(name), ".typed").await;
+ assert_eq!(
+ got,
+ golden(name),
+ "{name}: typed rows must resume to the legacy golden"
+ );
+ });
+ }
+}
+
+#[test]
+fn typed_fixtures_really_use_the_typed_form() {
+ let shapes = |name: &str| -> Vec<String> {
+ let raw = std::fs::read_to_string(fixture(&format!("{name}.typed.jsonl"))).unwrap();
+ message_lines(&raw)
+ .iter()
+ .filter_map(|line| line.get("shape").and_then(Value::as_str).map(String::from))
+ .collect()
+ };
+ let native = shapes("native_tools");
+ assert!(native.iter().any(|shape| shape == "assistant_calls"));
+ assert!(native.iter().any(|shape| shape == "tool_result"));
+ assert!(shapes("image_user")
+ .iter()
+ .any(|shape| shape == "user_parts"));
+ assert!(shapes("plain").is_empty());
+ // The envelope string no longer appears in a typed row's content.
+ let raw = std::fs::read_to_string(fixture("native_tools.typed.jsonl")).unwrap();
+ for line in message_lines(&raw) {
+ if line.get("v").is_some() {
+ assert!(
+ !line["content"]
+ .as_str()
+ .unwrap_or_default()
+ .starts_with('{'),
+ "{line}"
+ );
+ }
+ }
+}
+
+#[test]
+fn an_old_session_continued_by_this_binary_reloads_identically() {
+ run_async(async {
+ let scenario = scenario("native_tools");
+ let root = tempfile::tempdir().expect("tempdir");
+ let text = |s: &str| response(vec![ContentBlock::Text(s.into())], Vec::new());
+ let thread = thread_id(scenario.name);
+
+ let mut first = build_host(
+ root.path(),
+ model(
+ vec![
+ response(
+ vec![ContentBlock::Text("one more call".into())],
+ vec![call("call_new", "echo", json!({"q": "later"}))],
+ ),
+ text("continued"),
+ ],
+ true,
+ ),
+ true,
+ &thread,
+ );
+ let stem = first.session_id().expect("session id");
+ let path = stem_path(root.path(), &stem);
+ std::fs::copy(fixture("native_tools.jsonl"), &path).expect("place legacy file");
+ let legacy_bytes = std::fs::read(&path).expect("legacy bytes");
+
+ assert!(first.resume_bound_session().await.expect("resume"));
+ first.turn("keep going").await.expect("continued turn");
+ let continued_history = serde_json::to_value(
+ first
+ .runtime_session
+ .as_ref()
+ .expect("runtime session")
+ .history(),
+ )
+ .expect("history");
+ drop(first);
+
+ // The old rows are byte-for-byte what was captured; new rows follow.
+ let after = std::fs::read(&path).expect("file after");
+ assert!(
+ after.starts_with(&legacy_bytes),
+ "existing bytes were rewritten"
+ );
+ let appended = String::from_utf8(after[legacy_bytes.len()..].to_vec()).unwrap();
+ let new_rows = message_lines(&appended);
+ let shape = |index: usize| new_rows[index].get("shape").and_then(Value::as_str);
+ assert!(
+ new_rows.iter().any(|row| row["shape"] == "assistant_calls")
+ && new_rows.iter().any(|row| row["shape"] == "tool_result"),
+ "continued tool round must be typed: {shape:?}",
+ shape = (0..new_rows.len()).map(shape).collect::<Vec<_>>()
+ );
+
+ // A fresh process resumes the mixed file to what the first one held.
+ let second = {
+ let mut host = build_host(
+ root.path(),
+ model(vec![ModelResponse::assistant("unused")], true),
+ true,
+ &thread,
+ );
+ assert!(host.resume_bound_session().await.expect("second resume"));
+ host
+ };
+ let runtime = second.runtime_session.as_ref().expect("runtime session");
+ assert_eq!(
+ serde_json::to_value(runtime.history()).expect("history"),
+ continued_history
+ );
+ let transcript = read_transcript(&path).expect("read mixed");
+ assert!(transcript
+ .messages
+ .iter()
+ .any(|row| row.content.contains("call_new")));
+ });
+}
+
+#[test]
+#[ignore = "re-derives the committed .typed fixtures; run deliberately (OH_REGEN_SESSION_COMPAT=1)"]
+fn regenerate_typed_session_compat() {
+ if std::env::var("OH_REGEN_SESSION_COMPAT").as_deref() != Ok("1") {
+ return;
+ }
+ for name in TYPED_SCENARIOS {
+ let transcript = read_transcript(&fixture(&format!("{name}.jsonl"))).expect("read legacy");
+ let dir = tempfile::tempdir().expect("tempdir");
+ let path = dir.path().join("typed.jsonl");
+ write_transcript(&path, &transcript.messages, &transcript.meta, None).expect("write typed");
+ std::fs::copy(&path, fixture(&format!("{name}.typed.jsonl"))).expect("store typed");
+ }
+}
diff --git a/tests/fixtures/session_compat/image_user.typed.jsonl b/tests/fixtures/session_compat/image_user.typed.jsonl
new file mode 100644
index 0000000000..4e3437c2c0
--- /dev/null
+++ b/tests/fixtures/session_compat/image_user.typed.jsonl
@@ -0,0 +1,4 @@
+{"_meta":{"version":1,"agent":"main","agent_id":"main","agent_type":"root","dispatcher":"native","model":"openrouter/deepseek/deepseek-v4-flash","created":"2026-10-01T06:17:46.479336587+00:00","updated":"2026-10-01T06:17:46.507756355+00:00","turn_count":1,"prefix_message_count":1,"input_tokens":0,"output_tokens":0,"cached_input_tokens":0,"charged_amount_usd":0.0,"thread_id":"compat-image_user","session_id":"compat-image_user-f13b7b316b8721efc95746c399791cbf.main-1f5962a2ce9803c8c2aef6860ee289f8"}}
+{"role":"system","content":"### SOUL.md\n\n# OpenHuman\n\nYou are OpenHuman, the user's AI teammate on their own machine. Warm, direct, no filler; say \"I'm not sure\" rather than guess. The user drives. When something fails, try another way, then say what failed.\n\n## When OpenHuman is criticized\n\nOwn real limits plainly. Don't validate FUD: ask what they actually hit, or correct it with specifics.\n\n### IDENTITY.md\n\n# Identity\n\nPrivacy first. Never invent metrics or integration data; say whether an answer came from a tool, memory or general knowledge.\n\n## Tool Use Protocol\n\nWhen you need a tool, call it in this response through native tool-calling.\nA short line saying what you are about to do is fine, but the tool call must be in the same message; never end a turn on an announcement.\nAfter the results arrive, keep going until you can give the final answer.\n\n## Safety\n\n- Do not exfiltrate private data.\n- Do not run destructive commands without asking.\n- Do not bypass oversight or approval mechanisms.\n- Prefer `trash` over `rm`.\n- When in doubt, ask before acting externally.\n\n## Current Date & Time\n\nThe `Current Date & Time:` line on the latest message is authoritative; match greetings and \"today\" to its local hour.\n\n## Grounding and tool use\n\n- Your tools are exactly the ones you have been given for this turn, whether they arrive as a tool list or are described in this prompt. You can only act through them. Check that list before saying you lack a capability, and if it is not there, say so plainly rather than pretending it exists.\n- Never invent tool names, arguments, ids, slugs, file paths, URLs, chain ids, addresses, quotes, metrics, or any other value. If you do not have it from a tool result or the user, ask for it or look it up with a tool.\n- Preserve numeric evidence exactly. For numbers, counts, sizes, dates, timestamps, durations, currencies, percentages, quotas, and ids, copy the exact value from the observed tool result, user message, or cited memory into your answer.\n- Do not round, convert units, rewrite relative times, or recalculate numeric values unless the user asks and you show the calculation from observed values. If sources disagree, name the discrepancy instead of choosing a plausible value.\n- Use your tools to act. Do not just describe what you would do and stop, and never end a turn with a promise of future action: do it now, or hand back a concrete result.\n- Never substitute plausible looking but fabricated output (made up data, invented file contents, synthesised tool or API responses) for results you could not actually produce. If a step failed, say it failed.\n- When a tool or delegated sub-agent hands back an incomplete or blocked result (for example a [SUBAGENT_INCOMPLETE] envelope), relay what it did accomplish and the blocker to the user. Do not present it as finished, fabricate the rest, or silently re-run the identical call: change the approach or ask the user.\n- Ground every factual claim in evidence you actually observed: a tool result, the user's message, or cited memory. If the evidence is missing, partial, or truncated, say so or fetch more instead of guessing.\n- Skills run only via `run_workflow`, and only the skills listed as installed exist. Do not invent skill ids.\n\n# Writing style\n\nText like a colleague: answer first, only useful context, no repeating the thread, emojis rarely. Never use em-dashes; use commas, colons or two sentences. Output for another agent is data: dense and complete.\n\n## Workspace\n\nTools resolve in `pwd`; outside it and scratch is blocked. Prefer stdout. Scratch: `/tmp/openhuman` or `$TMPDIR`, never `/tmp/<name>`.\n\n## Runtime\n\nHost: dragonfly | OS: linux | Model: openrouter/deepseek/deepseek-v4-flash"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:46 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\nlook [IMAGE:data:image/png;base64,iVBORw0KGgo=] please"}
+{"role":"assistant","content":"saw it","provider":"","model":"","usage":{"input":120,"output":30,"cached_input":100,"context_window":0,"cost_usd":0.000015948},"iteration":1,"ts":"2026-10-01T06:17:46.507702767+00:00"}
diff --git a/tests/fixtures/session_compat/native_tools.typed.jsonl b/tests/fixtures/session_compat/native_tools.typed.jsonl
new file mode 100644
index 0000000000..89639f305c
--- /dev/null
+++ b/tests/fixtures/session_compat/native_tools.typed.jsonl
@@ -0,0 +1,9 @@
+{"_meta":{"version":1,"agent":"main","agent_id":"main","agent_type":"root","dispatcher":"native","model":"openrouter/deepseek/deepseek-v4-flash","created":"2026-10-01T06:17:45.795119914+00:00","updated":"2026-10-01T06:17:46.475197917+00:00","turn_count":2,"prefix_message_count":1,"input_tokens":0,"output_tokens":0,"cached_input_tokens":0,"charged_amount_usd":0.0,"thread_id":"compat-native_tools","session_id":"compat-native_tools-e43c24fc75713ff56867e8b21877c7e5.main-1f5962a2ce9803c8c2aef6860ee289f8"}}
+{"role":"system","content":"### SOUL.md\n\n# OpenHuman\n\nYou are OpenHuman, the user's AI teammate on their own machine. Warm, direct, no filler; say \"I'm not sure\" rather than guess. The user drives. When something fails, try another way, then say what failed.\n\n## When OpenHuman is criticized\n\nOwn real limits plainly. Don't validate FUD: ask what they actually hit, or correct it with specifics.\n\n### IDENTITY.md\n\n# Identity\n\nPrivacy first. Never invent metrics or integration data; say whether an answer came from a tool, memory or general knowledge.\n\n## Tool Use Protocol\n\nWhen you need a tool, call it in this response through native tool-calling.\nA short line saying what you are about to do is fine, but the tool call must be in the same message; never end a turn on an announcement.\nAfter the results arrive, keep going until you can give the final answer.\n\n## Safety\n\n- Do not exfiltrate private data.\n- Do not run destructive commands without asking.\n- Do not bypass oversight or approval mechanisms.\n- Prefer `trash` over `rm`.\n- When in doubt, ask before acting externally.\n\n## Current Date & Time\n\nThe `Current Date & Time:` line on the latest message is authoritative; match greetings and \"today\" to its local hour.\n\n## Grounding and tool use\n\n- Your tools are exactly the ones you have been given for this turn, whether they arrive as a tool list or are described in this prompt. You can only act through them. Check that list before saying you lack a capability, and if it is not there, say so plainly rather than pretending it exists.\n- Never invent tool names, arguments, ids, slugs, file paths, URLs, chain ids, addresses, quotes, metrics, or any other value. If you do not have it from a tool result or the user, ask for it or look it up with a tool.\n- Preserve numeric evidence exactly. For numbers, counts, sizes, dates, timestamps, durations, currencies, percentages, quotas, and ids, copy the exact value from the observed tool result, user message, or cited memory into your answer.\n- Do not round, convert units, rewrite relative times, or recalculate numeric values unless the user asks and you show the calculation from observed values. If sources disagree, name the discrepancy instead of choosing a plausible value.\n- Use your tools to act. Do not just describe what you would do and stop, and never end a turn with a promise of future action: do it now, or hand back a concrete result.\n- Never substitute plausible looking but fabricated output (made up data, invented file contents, synthesised tool or API responses) for results you could not actually produce. If a step failed, say it failed.\n- When a tool or delegated sub-agent hands back an incomplete or blocked result (for example a [SUBAGENT_INCOMPLETE] envelope), relay what it did accomplish and the blocker to the user. Do not present it as finished, fabricate the rest, or silently re-run the identical call: change the approach or ask the user.\n- Ground every factual claim in evidence you actually observed: a tool result, the user's message, or cited memory. If the evidence is missing, partial, or truncated, say so or fetch more instead of guessing.\n- Skills run only via `run_workflow`, and only the skills listed as installed exist. Do not invent skill ids.\n\n# Writing style\n\nText like a colleague: answer first, only useful context, no repeating the thread, emojis rarely. Never use em-dashes; use commas, colons or two sentences. Output for another agent is data: dense and complete.\n\n## Workspace\n\nTools resolve in `pwd`; outside it and scratch is blocked. Prefer stdout. Scratch: `/tmp/openhuman` or `$TMPDIR`, never `/tmp/<name>`.\n\n## Runtime\n\nHost: dragonfly | OS: linux | Model: openrouter/deepseek/deepseek-v4-flash"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:45 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\nuse the tools"}
+{"role":"assistant","content":"checking","extra_metadata":{"reasoning_content":"plan the calls"},"reasoning_content":"plan the calls","tool_calls":[{"id":"call_echo","name":"echo","arguments":"{\"q\":\"hi\"}"},{"id":"call_boom","name":"boom","arguments":"{}"}],"v":2,"shape":"assistant_calls"}
+{"id":"call_echo","role":"tool","content":"echo:{\"q\":\"hi\"}","v":2,"shape":"tool_result","tool_call_id":"call_echo"}
+{"id":"call_boom","role":"tool","content":"boom: exit 1","failure":true,"v":2,"shape":"tool_result","tool_call_id":"call_boom"}
+{"role":"assistant","content":"done with tools","provider":"","model":"","usage":{"input":240,"output":60,"cached_input":200,"context_window":0,"cost_usd":0.000031896},"iteration":2,"ts":"2026-10-01T06:17:46.446471589+00:00"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:46 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\nand again"}
+{"role":"assistant","content":"second turn","provider":"","model":"","usage":{"input":120,"output":30,"cached_input":100,"context_window":0,"cost_usd":0.000015948},"iteration":1,"ts":"2026-10-01T06:17:46.475167808+00:00"}
diff --git a/tests/fixtures/session_compat/plain.typed.jsonl b/tests/fixtures/session_compat/plain.typed.jsonl
new file mode 100644
index 0000000000..65d5c7b244
--- /dev/null
+++ b/tests/fixtures/session_compat/plain.typed.jsonl
@@ -0,0 +1,6 @@
+{"_meta":{"version":1,"agent":"main","agent_id":"main","agent_type":"root","dispatcher":"native","model":"openrouter/deepseek/deepseek-v4-flash","created":"2026-10-01T06:17:45.717094947+00:00","updated":"2026-10-01T06:17:45.790970214+00:00","turn_count":2,"prefix_message_count":1,"input_tokens":0,"output_tokens":0,"cached_input_tokens":0,"charged_amount_usd":0.0,"thread_id":"compat-plain","session_id":"compat-plain-b58d0d9bde5033a22ee97c1a1a4e18b2.main-1f5962a2ce9803c8c2aef6860ee289f8"}}
+{"role":"system","content":"### SOUL.md\n\n# OpenHuman\n\nYou are OpenHuman, the user's AI teammate on their own machine. Warm, direct, no filler; say \"I'm not sure\" rather than guess. The user drives. When something fails, try another way, then say what failed.\n\n## When OpenHuman is criticized\n\nOwn real limits plainly. Don't validate FUD: ask what they actually hit, or correct it with specifics.\n\n### IDENTITY.md\n\n# Identity\n\nPrivacy first. Never invent metrics or integration data; say whether an answer came from a tool, memory or general knowledge.\n\n## Tool Use Protocol\n\nWhen you need a tool, call it in this response through native tool-calling.\nA short line saying what you are about to do is fine, but the tool call must be in the same message; never end a turn on an announcement.\nAfter the results arrive, keep going until you can give the final answer.\n\n## Safety\n\n- Do not exfiltrate private data.\n- Do not run destructive commands without asking.\n- Do not bypass oversight or approval mechanisms.\n- Prefer `trash` over `rm`.\n- When in doubt, ask before acting externally.\n\n## Current Date & Time\n\nThe `Current Date & Time:` line on the latest message is authoritative; match greetings and \"today\" to its local hour.\n\n## Grounding and tool use\n\n- Your tools are exactly the ones you have been given for this turn, whether they arrive as a tool list or are described in this prompt. You can only act through them. Check that list before saying you lack a capability, and if it is not there, say so plainly rather than pretending it exists.\n- Never invent tool names, arguments, ids, slugs, file paths, URLs, chain ids, addresses, quotes, metrics, or any other value. If you do not have it from a tool result or the user, ask for it or look it up with a tool.\n- Preserve numeric evidence exactly. For numbers, counts, sizes, dates, timestamps, durations, currencies, percentages, quotas, and ids, copy the exact value from the observed tool result, user message, or cited memory into your answer.\n- Do not round, convert units, rewrite relative times, or recalculate numeric values unless the user asks and you show the calculation from observed values. If sources disagree, name the discrepancy instead of choosing a plausible value.\n- Use your tools to act. Do not just describe what you would do and stop, and never end a turn with a promise of future action: do it now, or hand back a concrete result.\n- Never substitute plausible looking but fabricated output (made up data, invented file contents, synthesised tool or API responses) for results you could not actually produce. If a step failed, say it failed.\n- When a tool or delegated sub-agent hands back an incomplete or blocked result (for example a [SUBAGENT_INCOMPLETE] envelope), relay what it did accomplish and the blocker to the user. Do not present it as finished, fabricate the rest, or silently re-run the identical call: change the approach or ask the user.\n- Ground every factual claim in evidence you actually observed: a tool result, the user's message, or cited memory. If the evidence is missing, partial, or truncated, say so or fetch more instead of guessing.\n- Skills run only via `run_workflow`, and only the skills listed as installed exist. Do not invent skill ids.\n\n# Writing style\n\nText like a colleague: answer first, only useful context, no repeating the thread, emojis rarely. Never use em-dashes; use commas, colons or two sentences. Output for another agent is data: dense and complete.\n\n## Workspace\n\nTools resolve in `pwd`; outside it and scratch is blocked. Prefer stdout. Scratch: `/tmp/openhuman` or `$TMPDIR`, never `/tmp/<name>`.\n\n## Runtime\n\nHost: dragonfly | OS: linux | Model: openrouter/deepseek/deepseek-v4-flash"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:45 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\none"}
+{"role":"assistant","content":"alpha","provider":"","model":"","usage":{"input":120,"output":30,"cached_input":100,"context_window":0,"cost_usd":0.000015948},"iteration":1,"ts":"2026-10-01T06:17:45.762382535+00:00"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:45 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\ntwo"}
+{"role":"assistant","content":"beta","provider":"","model":"","usage":{"input":120,"output":30,"cached_input":100,"context_window":0,"cost_usd":0.000015948},"iteration":1,"ts":"2026-10-01T06:17:45.790957654+00:00"}
diff --git a/tests/fixtures/session_compat/xml_tools.typed.jsonl b/tests/fixtures/session_compat/xml_tools.typed.jsonl
new file mode 100644
index 0000000000..e8275c9dc8
--- /dev/null
+++ b/tests/fixtures/session_compat/xml_tools.typed.jsonl
@@ -0,0 +1,8 @@
+{"_meta":{"version":1,"agent":"main","agent_id":"main","agent_type":"root","dispatcher":"xml","model":"openrouter/deepseek/deepseek-v4-flash","created":"2026-10-01T06:17:46.511654057+00:00","updated":"2026-10-01T06:17:46.575495743+00:00","turn_count":1,"prefix_message_count":1,"input_tokens":0,"output_tokens":0,"cached_input_tokens":0,"charged_amount_usd":0.0,"thread_id":"compat-xml_tools","session_id":"compat-xml_tools-0e4ef2b226534cef4ef8a1fed4be449f.main-1f5962a2ce9803c8c2aef6860ee289f8"}}
+{"role":"system","content":"### SOUL.md\n\n# OpenHuman\n\nYou are OpenHuman, the user's AI teammate on their own machine. Warm, direct, no filler; say \"I'm not sure\" rather than guess. The user drives. When something fails, try another way, then say what failed.\n\n## When OpenHuman is criticized\n\nOwn real limits plainly. Don't validate FUD: ask what they actually hit, or correct it with specifics.\n\n### IDENTITY.md\n\n# Identity\n\nPrivacy first. Never invent metrics or integration data; say whether an answer came from a tool, memory or general knowledge.\n\n\n## Tool Use Protocol\n\nTo use a tool, wrap a JSON object in <tool_call></tool_call> tags:\n\n```\n<tool_call>\n{\"name\": \"tool_name\", \"arguments\": {\"param\": \"value\"}}\n</tool_call>\n```\n\nYou may emit multiple tool calls in a single response. After execution, results appear in <tool_result> tags. Continue reasoning with the results until you can give a final answer.\n\n### Available Tools\n\n- **echo**: echoes\n Parameters: `{\"properties\":{\"q\":{\"type\":\"string\"}},\"type\":\"object\"}`\n- **boom**: always fails\n Parameters: `{\"type\":\"object\"}`\n\n## Safety\n\n- Do not exfiltrate private data.\n- Do not run destructive commands without asking.\n- Do not bypass oversight or approval mechanisms.\n- Prefer `trash` over `rm`.\n- When in doubt, ask before acting externally.\n\n## Current Date & Time\n\nThe `Current Date & Time:` line on the latest message is authoritative; match greetings and \"today\" to its local hour.\n\n## Grounding and tool use\n\n- Your tools are exactly the ones you have been given for this turn, whether they arrive as a tool list or are described in this prompt. You can only act through them. Check that list before saying you lack a capability, and if it is not there, say so plainly rather than pretending it exists.\n- Never invent tool names, arguments, ids, slugs, file paths, URLs, chain ids, addresses, quotes, metrics, or any other value. If you do not have it from a tool result or the user, ask for it or look it up with a tool.\n- Preserve numeric evidence exactly. For numbers, counts, sizes, dates, timestamps, durations, currencies, percentages, quotas, and ids, copy the exact value from the observed tool result, user message, or cited memory into your answer.\n- Do not round, convert units, rewrite relative times, or recalculate numeric values unless the user asks and you show the calculation from observed values. If sources disagree, name the discrepancy instead of choosing a plausible value.\n- Use your tools to act. Do not just describe what you would do and stop, and never end a turn with a promise of future action: do it now, or hand back a concrete result.\n- Never substitute plausible looking but fabricated output (made up data, invented file contents, synthesised tool or API responses) for results you could not actually produce. If a step failed, say it failed.\n- When a tool or delegated sub-agent hands back an incomplete or blocked result (for example a [SUBAGENT_INCOMPLETE] envelope), relay what it did accomplish and the blocker to the user. Do not present it as finished, fabricate the rest, or silently re-run the identical call: change the approach or ask the user.\n- Ground every factual claim in evidence you actually observed: a tool result, the user's message, or cited memory. If the evidence is missing, partial, or truncated, say so or fetch more instead of guessing.\n- Skills run only via `run_workflow`, and only the skills listed as installed exist. Do not invent skill ids.\n\n# Writing style\n\nText like a colleague: answer first, only useful context, no repeating the thread, emojis rarely. Never use em-dashes; use commas, colons or two sentences. Output for another agent is data: dense and complete.\n\n## Workspace\n\nTools resolve in `pwd`; outside it and scratch is blocked. Prefer stdout. Scratch: `/tmp/openhuman` or `$TMPDIR`, never `/tmp/<name>`.\n\n## Runtime\n\nHost: dragonfly | OS: linux | Model: openrouter/deepseek/deepseek-v4-flash"}
+{"role":"user","content":"Current Date & Time: 2026-10-01 09:17:46 Asia/Kuwait (+03:00, UTC+03:00), Thursday\n\nxml please"}
+{"role":"assistant","content":"","provider":"","model":"","usage":{"input":0,"output":0,"cached_input":0,"context_window":0,"cost_usd":0.0},"tool_calls":[{"id":"openhuman-session-a8589833-ab67-474a-9da9-0966bccc2d22-model-1-tool-1","name":"echo","arguments":"{\"q\":\"x\"}"}],"iteration":1,"ts":"2026-10-01T06:17:46.575429416+00:00"}
+{"role":"user","content":"[Tool results]\n<tool_result id=\"openhuman-session-a8589833-ab67-474a-9da9-0966bccc2d22-model-1-tool-1\">\necho:{\"q\":\"x\"}\n</tool_result>\n"}
+{"role":"assistant","content":"","provider":"","model":"","usage":{"input":0,"output":0,"cached_input":0,"context_window":0,"cost_usd":0.0},"tool_calls":[{"id":"openhuman-session-a8589833-ab67-474a-9da9-0966bccc2d22-model-2-tool-1","name":"boom","arguments":"{}"}],"iteration":2,"ts":"2026-10-01T06:17:46.575440989+00:00"}
+{"role":"user","content":"[Tool results]\n<tool_result id=\"openhuman-session-a8589833-ab67-474a-9da9-0966bccc2d22-model-2-tool-1\">\nboom: exit 1\n</tool_result>\n","extra_metadata":{"openhuman_tool_failures":["openhuman-session-a8589833-ab67-474a-9da9-0966bccc2d22-model-2-tool-1"]}}
+{"role":"assistant","content":"xml done","provider":"","model":"","usage":{"input":360,"output":90,"cached_input":300,"context_window":0,"cost_usd":0.000047844},"iteration":3,"ts":"2026-10-01T06:17:46.575446819+00:00"}