Skip to content

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

fix(web_chat): key session leases by fork identity

Steven Enamakel0ba0f6add4e4
diff --git a/crates/openhuman-core/src/web_chat/turn_events.rs b/crates/openhuman-core/src/web_chat/turn_events.rs
index d9eb18fd01..82d0b4ee8e 100644
--- a/crates/openhuman-core/src/web_chat/turn_events.rs
+++ b/crates/openhuman-core/src/web_chat/turn_events.rs
@@ -424,9 +424,9 @@ impl EventSink<QueuedPayload> for WebEvents {
// A message that waited in a run queue and never started was never
// announced as a turn, so its being dropped is silent too.
let never_started = self.shared.was_queued(&request.request_id);
- let (projection, done, note) = match slot {
- Some(slot) => (slot.projection, slot.result, slot.cancel),
- None => (None, None, None),
+ let (projection, done, note, _session_lease) = match slot {
+ Some(slot) => (slot.projection, slot.result, slot.cancel, slot.session_lease),
+ None => (None, None, None, None),
};
if never_started && !matches!(event, TerminalEvent::Completed { .. }) {
log::debug!(
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rs
index cbf1322d04..4f188dd679 100644
--- a/crates/openhuman-core/src/web_chat/turn_host.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host.rs
@@ -95,11 +95,18 @@ impl WebHost {
// and commit the same transcript concurrently.
let tenant = ctx.tenant().map_err(|error| error.to_string())?;
let tenant_scope = crate::core::runtime::tenant::tenant_key(&tenant, "");
+ // A parallel fork has its own transcript identity, while the other
+ // queue modes resume the canonical thread session.
+ let session_identity = if policy == CheckoutPolicy::Fork {
+ format!("fork:{}", request.request_id)
+ } else {
+ request.thread_id.clone()
+ };
let lease = crate::agent::session_lease::SessionLease::acquire(
crate::agent::session_lease::SessionLeaseKey::new(
tenant_scope,
request.scope.agent_id.clone(),
- request.thread_id.clone(),
+ session_identity,
),
None,
)