Skip to content

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

feat(core): expose agent state arc and log slot refcounts

Steven Enamakelde8dcdb582a9
diff --git a/crates/openhuman-core/src/core/runtime/context_agent.rs b/crates/openhuman-core/src/core/runtime/context_agent.rs
index 8ab6c016eb..a9f51f4966 100644
--- a/crates/openhuman-core/src/core/runtime/context_agent.rs
+++ b/crates/openhuman-core/src/core/runtime/context_agent.rs
@@ -80,6 +80,10 @@ impl CoreContext {
Arc::strong_count(self) > 1 || Arc::strong_count(&self.agent.state) > 1
}
+ pub fn agent_state_arc(&self) -> &Arc<super::super::agent_scope::AgentScopedState> {
+ &self.agent.state
+ }
+
/// The state slots this context owns.
pub fn agent_state(&self) -> &super::super::agent_scope::AgentScopedState {
&self.agent.state
diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rs
index 53ab2d87f8..fd186b1a91 100644
--- a/crates/openhuman-core/src/profiles/host.rs
+++ b/crates/openhuman-core/src/profiles/host.rs
@@ -579,6 +579,7 @@ impl ProfileHost {
/// or a turn still running on its context (a detached turn outlives the
/// request that started it).
fn in_use(slot: &Slot) -> bool {
+ log::debug!("[profiles] DEBUGPIN state={} ctx={} agent_state={}", Arc::strong_count(&slot.state), Arc::strong_count(&slot.state.context), Arc::strong_count(slot.state.context.agent_state_arc()));
Arc::strong_count(&slot.state) > 1 || slot.state.context.tenant_in_use()
}