Skip to content

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

fix(agent): reuse transcript locator on resumed turns

Steven Enamakel3a16fc2c13d4
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 15481e0a21..4bf2f09468 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -486,6 +486,53 @@ fn a_subagent_thread_binding_claims_no_session_identity() {
assert_eq!(child.session_id(), None);
}
+/// The resume hook and builder must name the same transcript locator instance.
+/// A distinct locator for the same directory lets a new thread commit, then
+/// rejects a cold resumed thread before inference with InvalidSessionState (#6608).
+#[test]
+fn a_cold_resumed_thread_can_send_again() {
+ std::thread::Builder::new()
+ .stack_size(crate::core::runtime::AGENT_WORKER_STACK_BYTES)
+ .spawn(|| {
+ tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .build()
+ .expect("test runtime")
+ .block_on(cold_resumed_thread_can_send_again());
+ })
+ .expect("test thread")
+ .join()
+ .expect("test thread panicked");
+}
+
+async fn cold_resumed_thread_can_send_again() {
+ let root = tempfile::tempdir().expect("tempdir");
+ let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =
+ Arc::new(tinyagents_harness::testkit::ScriptedModel::new(vec![
+ tinyinference_llm::model::ModelResponse::assistant("first reply"),
+ tinyinference_llm::model::ModelResponse::assistant("second reply"),
+ ]));
+ let new_host = || {
+ crate::agent::SessionHostBuilder::new()
+ .chat_model(model.clone())
+ .tools(Vec::new())
+ .workspace_dir(root.path().join("workspace"))
+ .action_dir(root.path().to_path_buf())
+ .memory(crate::memory::test_support::noop_memory())
+ .tool_dispatcher(Box::new(tinytools_agent::dialect::XmlDialect))
+ .build()
+ .expect("session build")
+ };
+ let mut host = new_host();
+ host.set_thread_id(Some("thread-resume-regression"));
+
+ assert_eq!(host.turn("first message").await.unwrap(), "first reply");
+ drop(host);
+ let mut host = new_host();
+ host.set_thread_id(Some("thread-resume-regression"));
+ assert_eq!(host.turn("second message").await.unwrap(), "second reply");
+}
+
/// The PRODUCTION turn path must wire an artifact store, rooted where the READ
/// path will look for it (#6408).
///
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 5a6f3e93ea..f501f87542 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1432,14 +1432,19 @@ impl OpenHumanSessionHost {
// than minting a new stem and resuming whichever one happens to be
// newest. Everything else — sub-agents, unthreaded CLI turns — keeps
// the stem path, where a fresh transcript per run is correct.
+ // The builder's initial binding and the per-turn resume hook must
+ // share one locator allocation. The runtime compares locator identity
+ // once a durable transcript is bound; separately constructed locators
+ // for the same workspace reject the first turn after a cold resume.
+ let session_locator = self.session_locator();
let resume_target = match self.session.clone() {
Some(session) => TranscriptTarget::for_session(
- self.session_locator(),
+ session_locator.clone(),
session,
self.runtime_transcript_meta(),
),
None => TranscriptTarget::new(
- self.session_locator(),
+ session_locator.clone(),
self.runtime_transcript_stem(),
self.runtime_transcript_meta(),
)
@@ -1831,11 +1836,7 @@ impl OpenHumanSessionHost {
.hooks(hooks)
.retain_recorded_tools(true);
if let Some(session) = self.session.clone() {
- builder = builder.session(
- self.session_locator(),
- session,
- self.runtime_transcript_meta(),
- );
+ builder = builder.session(session_locator, session, self.runtime_transcript_meta());
}
self.runtime_session = Some(
builder