Skip to content

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

refactor(agent): add connected_identities_md helper to run contexts

Steven Enamakeld30d03a0c837
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 72b20d748b..1f38e95f37 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -74,11 +74,7 @@ struct OpenHumanTurnPrelude {
/// Host prompt/utilisation state, shared by the runtime hooks. It is not
/// generic conversation state and the runtime never persists it.
context: Arc<std::sync::Mutex<crate::agent::context::ContextManager>>,
- tool_policy: Arc<
- dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
- >,
+ tool_policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>,
tool_dispatcher: Arc<dyn tinytools_agent::dialect::ToolDialect>,
workspace_dir: std::path::PathBuf,
action_dir: std::path::PathBuf,
@@ -282,7 +278,9 @@ impl OpenHumanTurnPrelude {
.filter(|spec| !withheld.contains(&spec.name))
.filter(|spec| {
self.thread_id.is_some()
- || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(&spec.name)
+ || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(
+ &spec.name,
+ )
})
.map(|spec| spec.as_ref().clone())
.collect::<Vec<_>>();
@@ -334,9 +332,7 @@ impl OpenHumanTurnPrelude {
visible_tool_names: &visible_tool_names,
tool_call_format: self.tool_dispatcher.tool_call_format(),
connected_integrations: &mutable.connected_integrations,
- connected_identities_md: crate::agent::prompts::render_connected_identities(
- &self.dispatch_ctx(),
- ),
+ connected_identities_md: self.connected_identities_md(),
user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
personality_roster: vec![],
agents_md_global: agents_md.global,
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
index 81ad734f25..48f03756d2 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
@@ -73,6 +73,11 @@ pub(super) fn in_prompt_window(
impl OpenHumanTurnPrelude {
/// The context this session's turns run under, from the host environment
/// bound at the start of the turn.
+ /// The connected-identities prompt section, read under the session's context.
+ pub(in crate::agent::session_host) fn connected_identities_md(&self) -> String {
+ crate::agent::prompts::render_connected_identities(&self.dispatch_ctx())
+ }
+
pub(in crate::agent::session_host) fn dispatch_ctx(&self) -> crate::core::runtime::DispatchCtx {
match &self.host_env.core {
Some(core) => crate::core::runtime::DispatchCtx::new(Arc::clone(core)),
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index e471bb911e..fcbf673c96 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -13,8 +13,7 @@ use crate::agent::harness::artifact_offload::offload_run_result;
use crate::agent::harness::fork_context::ParentExecutionContext;
use crate::agent::harness::host_definition::{AgentDefinition, AgentDefinitionRegistry};
use crate::agent::prompts::{
- render_connected_identities, render_subagent_system_prompt_with_format, PromptContext,
- SubagentRenderOptions,
+ render_subagent_system_prompt_with_format, PromptContext, SubagentRenderOptions,
};
use crate::agent::subagent_host::definition_iter_cap;
use crate::agent::subagent_host::tool_prep::{
@@ -773,7 +772,7 @@ async fn run_typed_mode(
visible_tool_names: &visible_tool_names,
tool_call_format: prompt_tool_call_format,
connected_integrations: &connected_integrations_for_prompt,
- connected_identities_md: render_connected_identities(&options.run_context.dispatch_ctx()),
+ connected_identities_md: options.run_context.connected_identities_md(),
user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
personality_roster: vec![],
agents_md_global: agents_md.global.clone(),
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 864c762e3a..90db68b1d2 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -504,6 +504,11 @@ impl OpenHumanRunContext {
}
}
+ /// The connected-identities prompt section, read under this run's context.
+ pub(crate) fn connected_identities_md(&self) -> String {
+ crate::agent::prompts::render_connected_identities(&self.dispatch_ctx())
+ }
+
/// Sets the direct TinyTools workspace descriptor for this run.
pub fn with_workspace(mut self, workspace: tinytools::WorkspaceDescriptor) -> Self {
self.workspace = Some(workspace);