Skip to content

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

fix(web_chat): scope session leases to the resolved target agent

Steven Enamakel304d501635f3
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
index 8cb709fc97..7fc741fffc 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
@@ -5,17 +5,6 @@ use tinyagents_harness::progress::AgentProgress;
use tinychannels_bus::module_progressive::ChannelOutputEvent;
use tokio::sync::mpsc;
-pub(super) async fn open_native_reply(
- ctx: &crate::channels::context::ChannelRuntimeContext,
- envelope: &tinychannels_bus::channel::ChannelInboundEnvelope,
- turn_id: &str,
-) -> anyhow::Result<Option<std::sync::Arc<NativeProgressiveReply>>> {
- let Some(target) = native_target(ctx, envelope)? else {
- return Ok(None);
- };
- target.open(turn_id).await.map(Some)
-}
-
/// Captured configured module target for a single inbound conversation.
/// Opening the progressive handle is deferred until TurnRunner checkout, so a
/// queued follow-up gets a fresh module handle after it wins admission.
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rs
index 30fae5f2ef..6c3536d690 100644
--- a/crates/openhuman-core/src/web_chat/turn_host.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host.rs
@@ -89,23 +89,28 @@ impl WebHost {
let ctx = Self::ctx_of(request)?;
let id = request.request_id.as_str();
let payload = &request.payload;
+ let lease_config = self
+ .shared
+ .with(id, |slot| slot.config.clone())
+ .ok_or_else(|| "web chat turn started without resolved configuration".to_owned())?;
// The harness lock is local to this WebRuntime. Native channel and
// relay runners use the same agent-domain lease before checking out
// this durable identity, so separate surface runners cannot resume
// 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, "");
+ let agent_id = super::session::pick_target_agent_id(&lease_config);
// 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()
+ crate::core::runtime::tenant::tenant_key(&tenant, &request.thread_id)
};
let lease = crate::agent::session_lease::SessionLease::acquire(
crate::agent::session_lease::SessionLeaseKey::new(
tenant_scope,
- request.scope.agent_id.clone(),
+ agent_id,
session_identity,
),
None,