Skip to content

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

chore(session): remove unused imports and dead code

Steven Enamakel4b507fe35f0d
diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rs
index 6095eafe79..75d2a3922a 100644
--- a/crates/openhuman-core/src/agent/session_store/mod.rs
+++ b/crates/openhuman-core/src/agent/session_store/mod.rs
@@ -139,7 +139,7 @@ pub fn transcripts_or_files(
workspace_dir: &std::path::Path,
) -> Arc<dyn tinyagents_session::transcript::TranscriptLocator> {
transcripts_for(agent_id).unwrap_or_else(|| {
- match crate::core::runtime::agent_scope::current_agent_id() {
+ match current_embedded_agent() {
Some(embedded) => {
log::debug!(
"[session_store] transcripts under the agent's directory agent={embedded}"
@@ -154,15 +154,27 @@ pub fn transcripts_or_files(
}
/// The workspace root transcripts are written under: the agent's own
-/// directory under an embedded agent's context, else `workspace_dir`.
+/// directory under an embedded agent's context, else `workspace_dir` — which
+/// for a SaaS profile's default agent is that profile's own workspace.
#[must_use]
pub fn transcript_root(workspace_dir: &std::path::Path) -> std::path::PathBuf {
- match crate::core::runtime::agent_scope::current_agent_id() {
+ match current_embedded_agent() {
Some(agent) => agent_transcript_root(workspace_dir, &agent),
None => workspace_dir.to_path_buf(),
}
}
+/// The embedded agent the calling tenant runs as, if any. A SaaS profile's
+/// default agent has none: its transcripts live at its workspace root, which
+/// no other profile shares. A SaaS task with no scope has none either; the
+/// workspace it was handed is the only one it touches.
+#[must_use]
+pub fn current_embedded_agent() -> Option<String> {
+ crate::core::runtime::current_tenant()
+ .ok()
+ .and_then(|tenant| tenant.agent)
+}
+
/// The stores of the tenant the current [`CoreContext`] works for, keyed by
/// [`session_key`](crate::core::runtime::session_key): the agent it was
/// derived for ([`CoreContext::session_agent`]), else [`DEFAULT_AGENT`],
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
index b143b03f2b..ed9dfce3bf 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -70,7 +70,7 @@ pub(crate) async fn append_to_origin_transcript(
FileTranscriptLocator, SessionRef, TranscriptMessage,
};
let session = SessionRef::scoped(append.thread_id.to_string(), append.agent_id.to_string());
- if let Some(agent) = crate::core::runtime::agent_scope::current_agent_id() {
+ if let Some(agent) = crate::agent::session_store::current_embedded_agent() {
use tinyagents_session::transcript::TranscriptLocator;
crate::agent::session_store::AgentTranscriptFiles::new(workspace_dir, &agent)
.session_exists(&session);
diff --git a/crates/openhuman-core/src/storage/agents.rs b/crates/openhuman-core/src/storage/agents.rs
index b8f4c63d6f..7aee80764d 100644
--- a/crates/openhuman-core/src/storage/agents.rs
+++ b/crates/openhuman-core/src/storage/agents.rs
@@ -174,9 +174,12 @@ pub fn context_for(agent: &str) -> Option<Arc<CoreContext>> {
}
/// Runs `fut` in the `local` scope: under the process default context when
-/// the caller is acting for an agent, as-is otherwise.
+/// the caller is an embedded agent outside any SaaS profile, as-is otherwise.
+/// A SaaS profile (or a SaaS task with no scope) never switches to the
+/// process default context, which is the operator's.
async fn in_local<F: Future>(fut: F) -> F::Output {
- let acting = CoreContext::current().is_some_and(|context| context.session_agent().is_some());
+ let acting = crate::core::runtime::current_tenant()
+ .is_ok_and(|tenant| tenant.profile.is_none() && tenant.agent.is_some());
match CoreContext::default_context() {
Some(default) if acting => CoreContext::scope(default, fut).await,
_ => fut.await,