Skip to content

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

refactor(integrations): move connected integration types out of agent prompts

Steven Enamakelf16861abbda2
diff --git a/crates/openhuman-core/src/agent/harness/fork_context.rs b/crates/openhuman-core/src/agent/harness/fork_context.rs
index 33c81818c6..2a3b8c7504 100644
--- a/crates/openhuman-core/src/agent/harness/fork_context.rs
+++ b/crates/openhuman-core/src/agent/harness/fork_context.rs
@@ -115,7 +115,7 @@ pub struct ParentExecutionContext {
pub channel: String,
/// Active Composio integrations the parent has fetched.
- pub connected_integrations: Vec<crate::agent::prompts::ConnectedIntegration>,
+ pub connected_integrations: Vec<crate::integrations::ConnectedIntegration>,
/// The parent's active tool-call format (Native / PFormat / Json).
/// Sub-agents render their system prompts with this format so the
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
index bdd5ed8a1e..9f9955369b 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
@@ -1,6 +1,6 @@
use super::{ArchetypeDelegationTool, DelegationTarget, SpawnSubagentTool, SpawnWorkerThreadTool};
use crate::agent::harness::ParentExecutionContext;
-use crate::agent::prompts::ConnectedIntegration;
+use crate::integrations::ConnectedIntegration;
use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use crate::threads::store as conversations;
use async_trait::async_trait;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
index e826a8cd1d..056d2c0ef4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -169,7 +169,7 @@ impl OpenHumanSessionHost {
}
/// Active Composio integrations fetched at session start.
- pub fn connected_integrations(&self) -> &[crate::agent::prompts::ConnectedIntegration] {
+ pub fn connected_integrations(&self) -> &[crate::integrations::ConnectedIntegration] {
&self.connected_integrations
}
@@ -192,7 +192,7 @@ impl OpenHumanSessionHost {
/// fetch result when the agent was built outside the normal turn loop).
pub fn set_connected_integrations(
&mut self,
- integrations: Vec<crate::agent::prompts::ConnectedIntegration>,
+ integrations: Vec<crate::integrations::ConnectedIntegration>,
) {
self.connected_integrations = integrations;
self.connected_integrations_initialized = true;
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 9c2575cae3..11b447901d 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -160,7 +160,7 @@ struct OpenHumanTurnPreludeMutable {
announced_skills: std::collections::HashSet<String>,
pending_skill_announcement: Vec<String>,
pending_skill_retraction: Vec<String>,
- connected_integrations: Vec<crate::agent::prompts::ConnectedIntegration>,
+ connected_integrations: Vec<crate::integrations::ConnectedIntegration>,
connected_integrations_initialized: bool,
connected_integrations_authoritative: bool,
/// A cold hydration seeded the announced sets; later ones diff instead.
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 e6076b9f60..044674ee02 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
@@ -75,7 +75,7 @@ impl OpenHumanTurnPrelude {
/// 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())
+ crate::integrations::render_connected_identities(&self.dispatch_ctx())
}
pub(in crate::agent::session_host) fn dispatch_ctx(&self) -> crate::core::runtime::DispatchCtx {
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index 4fa74e3d08..33cc59d6c8 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -488,7 +488,7 @@ async fn a_resumed_orchestrator_keeps_the_integration_actions_it_was_sent() {
prelude.adopt_recorded_tools(Some(&recorded));
{
let mut mutable = prelude.mutable.lock().expect("prelude state");
- mutable.connected_integrations = vec![crate::agent::prompts::ConnectedIntegration {
+ mutable.connected_integrations = vec![crate::integrations::ConnectedIntegration {
toolkit: "gmail".into(),
description: String::new(),
tools: Vec::new(),
@@ -700,7 +700,7 @@ async fn newly_connected_action_cannot_shadow_a_permanent_source() {
));
{
let mut mutable = prelude.mutable.lock().unwrap();
- mutable.connected_integrations = vec![crate::agent::prompts::ConnectedIntegration {
+ mutable.connected_integrations = vec![crate::integrations::ConnectedIntegration {
toolkit: "gmail".into(),
description: String::new(),
tools: Vec::new(),
diff --git a/crates/openhuman-core/src/agent/session_host/turn/context.rs b/crates/openhuman-core/src/agent/session_host/turn/context.rs
index 2d642835a8..530ddd593b 100644
--- a/crates/openhuman-core/src/agent/session_host/turn/context.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn/context.rs
@@ -58,7 +58,7 @@ impl OpenHumanSessionHost {
visible_tool_names: &prompt_visible_tool_names,
tool_call_format: self.tool_dispatcher.tool_call_format(),
connected_integrations: &self.connected_integrations,
- connected_identities_md: crate::agent::prompts::render_connected_identities(
+ connected_identities_md: crate::integrations::render_connected_identities(
&self.dispatch_ctx(),
),
user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index 589ee430a0..445903bfaf 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -392,7 +392,7 @@ pub struct OpenHumanSessionHost {
/// agent build time and threaded into each agent's `prompt.rs` so
/// the delegator / skill-executor voices can render their own
/// integration blocks.
- pub(super) connected_integrations: Vec<crate::agent::prompts::ConnectedIntegration>,
+ pub(super) connected_integrations: Vec<crate::integrations::ConnectedIntegration>,
/// Whether `connected_integrations` is an authoritative session-start
/// snapshot (prewarmed from the shared Composio cache or fetched
/// explicitly) versus the default empty placeholder installed by
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 60f37dbcac..e468211f5a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -593,7 +593,7 @@ async fn run_typed_mode(
// once the OAuth handshake reaches ACTIVE/CONNECTED, so this call
// returns the fresh list almost for free on the warm path. Fall back
// to the parent's frozen list when the live fetch returns empty.
- let live_integrations: Vec<crate::agent::prompts::ConnectedIntegration> = {
+ let live_integrations: Vec<crate::integrations::ConnectedIntegration> = {
let signed_in = config
.as_ref()
.ok()
@@ -723,7 +723,7 @@ async fn run_typed_mode(
definition.extensions.omit_safety_preamble,
);
- let connected_integrations_for_prompt: Vec<crate::agent::prompts::ConnectedIntegration> =
+ let connected_integrations_for_prompt: Vec<crate::integrations::ConnectedIntegration> =
live_integrations
.iter()
.filter(|ci| ci.connected)
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_ranking_tests.rs b/crates/openhuman-core/src/agent/subagent_host/tool_ranking_tests.rs
index 9c6ed69736..0294dacead 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_ranking_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_ranking_tests.rs
@@ -9,7 +9,7 @@
//! provider-neutral library crate, so this suite stays here rather than
//! moving up with the algorithm.
-use crate::agent::prompts::ConnectedIntegrationTool;
+use crate::integrations::ConnectedIntegrationTool;
use tinyagents_harness::tool::{MIN_CONFIDENT_HITS, SelectableTool, rank_tools_by_prompt};
fn rank_actions_by_prompt(
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 a1edd64da6..0c72ac6782 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -506,7 +506,7 @@ 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())
+ crate::integrations::render_connected_identities(&self.dispatch_ctx())
}
/// Sets the direct TinyTools workspace descriptor for this run.
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
index 364a882f84..518e490449 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs
@@ -7,7 +7,7 @@
//! * [`build_visible_tool_set`] — union of named tools + extra (delegation) tools.
use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};
-use crate::agent::prompts::ConnectedIntegration;
+use crate::integrations::ConnectedIntegration;
use crate::config::Config;
use crate::integrations::composio::{
cached_active_integrations, fetch_connected_integrations_status,
diff --git a/crates/openhuman-core/src/integrations/announcement_notes.rs b/crates/openhuman-core/src/integrations/announcement_notes.rs
index 5b3822f82b..037dc163ec 100644
--- a/crates/openhuman-core/src/integrations/announcement_notes.rs
+++ b/crates/openhuman-core/src/integrations/announcement_notes.rs
@@ -13,21 +13,21 @@ const ANNOUNCEMENT_TRAILER: &str = "This is a capability update, not a request:
respond to the user's message below and only use these if that message needs them. \
Do not tell the user to reconnect or restart.";
-pub(super) fn integration_announcement_note(slugs: &[String]) -> Option<String> {
+pub(crate) fn integration_announcement_note(slugs: &[String]) -> Option<String> {
(!slugs.is_empty()).then(|| format!(
"[integration update] These integration(s) connected during this conversation and are available now; their actions are reachable through tool_search: {}. {ANNOUNCEMENT_TRAILER}",
slugs.join(", ")
))
}
-pub(super) fn mcp_announcement_note(servers: &[String]) -> Option<String> {
+pub(crate) fn mcp_announcement_note(servers: &[String]) -> Option<String> {
(!servers.is_empty()).then(|| format!(
"[MCP update] These MCP server(s) connected during this conversation and are available now; their tools are reachable through tool_search: {}. {ANNOUNCEMENT_TRAILER}",
servers.join(", ")
))
}
-pub(super) fn skill_announcement_note(skill_ids: &[String]) -> Option<String> {
+pub(crate) fn skill_announcement_note(skill_ids: &[String]) -> Option<String> {
(!skill_ids.is_empty()).then(|| format!(
"[skills update] These skill(s) were installed during this conversation and are available now in your `## Installed Skills` list via `run_workflow`: {}. {ANNOUNCEMENT_TRAILER}",
skill_ids.join(", ")
diff --git a/crates/openhuman-core/src/integrations/composio/bus.rs b/crates/openhuman-core/src/integrations/composio/bus.rs
index 4fb90d17b3..f8b62d1dd7 100644
--- a/crates/openhuman-core/src/integrations/composio/bus.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus.rs
@@ -33,7 +33,7 @@ pub use trigger_subscriber::ComposioTriggerSubscriber;
/// Publishes the active toolkit set after the integrations cache was
/// re-warmed, so live sessions rebuild their delegation schema.
-fn publish_integrations_changed(entries: &[crate::agent::prompts::types::ConnectedIntegration]) {
+fn publish_integrations_changed(entries: &[crate::integrations::ConnectedIntegration]) {
let mut toolkits: Vec<String> = entries
.iter()
.filter(|entry| entry.connected)
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
index 2cc155f9ee..999c9106e3 100644
--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
@@ -5,7 +5,7 @@
//! helpers ([`connected_set_hash`], [`sync_cache_with_connections`]) that
//! keep it in sync with a fresh backend `list_connections` response.
-use crate::agent::prompts::ConnectedIntegration;
+use crate::integrations::ConnectedIntegration;
use crate::config::Config;
use sha2::{Digest, Sha256};
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch.rs
index 58fac4e563..0723de06c5 100644
--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch.rs
+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch.rs
@@ -4,7 +4,7 @@
use std::sync::atomic::Ordering;
-use crate::agent::prompts::ConnectedIntegration;
+use crate::integrations::ConnectedIntegration;
use crate::config::Config;
use super::cache::{
diff --git a/crates/openhuman-core/src/integrations/composio/mod.rs b/crates/openhuman-core/src/integrations/composio/mod.rs
index 4f0a2cf627..19f7c53053 100644
--- a/crates/openhuman-core/src/integrations/composio/mod.rs
+++ b/crates/openhuman-core/src/integrations/composio/mod.rs
@@ -60,7 +60,7 @@ pub mod tools;
pub(crate) mod trigger_history;
pub mod types;
-pub use crate::agent::prompts::types::ConnectedIntegration;
+pub use crate::integrations::types::ConnectedIntegration;
pub use crate::integrations::composio::contract::ProviderUserProfile;
pub use action_tool::ComposioActionTool;
pub(crate) use auth_probe::user_is_signed_in_to_composio;
diff --git a/crates/openhuman-core/src/integrations/composio/ops/mod.rs b/crates/openhuman-core/src/integrations/composio/ops/mod.rs
index 51d5330c6e..62eb115eac 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/mod.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/mod.rs
@@ -79,7 +79,7 @@ pub(crate) use super::connected_integrations::cache_key;
#[cfg(test)]
pub(crate) use super::connected_integrations::{CachedIntegrations, INTEGRATIONS_CACHE};
#[cfg(test)]
-pub(crate) use crate::agent::prompts::ConnectedIntegration;
+pub(crate) use crate::integrations::ConnectedIntegration;
#[cfg(test)]
pub(crate) use std::time::{Duration, Instant};
diff --git a/crates/openhuman-core/src/integrations/composio/ops_route_parity_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_route_parity_tests.rs
index 4f26b81ebf..d0376b8e00 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_route_parity_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_route_parity_tests.rs
@@ -78,7 +78,7 @@ struct Shape {
connections: Vec<(String, bool)>,
}
-fn shapes(integrations: Vec<crate::agent::prompts::ConnectedIntegration>) -> Vec<Shape> {
+fn shapes(integrations: Vec<crate::integrations::ConnectedIntegration>) -> Vec<Shape> {
let mut out: Vec<Shape> = integrations
.into_iter()
.map(|i| {
diff --git a/crates/openhuman-core/src/integrations/composio/tools_host_credential_tests.rs b/crates/openhuman-core/src/integrations/composio/tools_host_credential_tests.rs
index 38f32dd2e5..356dce185a 100644
--- a/crates/openhuman-core/src/integrations/composio/tools_host_credential_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools_host_credential_tests.rs
@@ -195,7 +195,7 @@ fn connected_integrations_cache_is_keyed_per_credential() {
cache.write().unwrap().insert(
cache_key(&agent_a),
CachedIntegrations {
- entries: vec![crate::agent::prompts::ConnectedIntegration {
+ entries: vec![crate::integrations::ConnectedIntegration {
toolkit: "gmail".into(),
description: String::new(),
tools: Vec::new(),
diff --git a/crates/openhuman-core/src/integrations/mod.rs b/crates/openhuman-core/src/integrations/mod.rs
index b52431ad7b..1486e2dd7c 100644
--- a/crates/openhuman-core/src/integrations/mod.rs
+++ b/crates/openhuman-core/src/integrations/mod.rs
@@ -20,7 +20,8 @@ pub(crate) use connected_identities::render_connected_identities;
pub use client::{build_client, pricing_for_config, IntegrationClient};
pub use types::{
- BackendResponse, IntegrationPricing, IntegrationPricingEntry, PricingIntegrations,
+ BackendResponse, ConnectedIntegration, ConnectedIntegrationTool, GatedIntegrationTool,
+ IntegrationConnection, IntegrationPricing, IntegrationPricingEntry, PricingIntegrations,
};
#[cfg(test)]
diff --git a/crates/openhuman-core/src/integrations/prelude_integrations.rs b/crates/openhuman-core/src/integrations/prelude_integrations.rs
index 68d21bc229..86508a8d7d 100644
--- a/crates/openhuman-core/src/integrations/prelude_integrations.rs
+++ b/crates/openhuman-core/src/integrations/prelude_integrations.rs
@@ -105,7 +105,7 @@ impl OpenHumanTurnPrelude {
definition: &crate::agent_registry::host_definition::AgentDefinition,
base: &[Box<dyn tinytools::Tool>],
synthesized: &[Box<dyn tinytools::Tool>],
- integrations: &[crate::agent::prompts::ConnectedIntegration],
+ integrations: &[crate::integrations::ConnectedIntegration],
integrations_are_authoritative: bool,
) -> Vec<Box<dyn tinytools::Tool>> {
let recorded = self
@@ -491,7 +491,7 @@ impl OpenHumanTurnPrelude {
/// there is neither a live answer nor any snapshot to fall back to.
async fn load_connected_integrations(
config: &crate::config::Config,
-) -> Option<(Vec<crate::agent::prompts::ConnectedIntegration>, bool)> {
+) -> Option<(Vec<crate::integrations::ConnectedIntegration>, bool)> {
use crate::integrations::composio::FetchConnectedIntegrationsStatus;
match crate::integrations::composio::fetch_connected_integrations_status(config).await {
FetchConnectedIntegrationsStatus::Authoritative(connected) => Some((connected, true)),
@@ -515,7 +515,7 @@ async fn load_connected_integrations(
/// hydrations therefore diff against the existing sets instead.
pub(super) fn apply_cold_hydration(
state: &mut super::OpenHumanTurnPreludeMutable,
- connected: Vec<crate::agent::prompts::ConnectedIntegration>,
+ connected: Vec<crate::integrations::ConnectedIntegration>,
authoritative: bool,
mcp_servers: std::collections::HashSet<String>,
) {
@@ -562,7 +562,7 @@ pub(super) fn apply_cold_hydration(
/// also carries every allowlisted toolkit with `connected: false`; those are
/// available to connect, not connected, and must never be announced as such.
fn connected_toolkit_slugs(
- items: &[crate::agent::prompts::ConnectedIntegration],
+ items: &[crate::integrations::ConnectedIntegration],
) -> std::collections::HashSet<String> {
items
.iter()
@@ -578,7 +578,7 @@ fn connected_toolkit_slugs(
fn merge_integration_announcements(
announced: &mut std::collections::HashSet<String>,
pending: &mut Vec<String>,
- current: &[crate::agent::prompts::ConnectedIntegration],
+ current: &[crate::integrations::ConnectedIntegration],
) {
let current_slugs = connected_toolkit_slugs(current);
announced.retain(|slug| current_slugs.contains(slug));
diff --git a/crates/openhuman-core/src/integrations/prelude_integrations_tests.rs b/crates/openhuman-core/src/integrations/prelude_integrations_tests.rs
index 0826e63131..313b90c163 100644
--- a/crates/openhuman-core/src/integrations/prelude_integrations_tests.rs
+++ b/crates/openhuman-core/src/integrations/prelude_integrations_tests.rs
@@ -1,8 +1,8 @@
use super::*;
use std::collections::HashSet;
-fn item(toolkit: &str, connected: bool) -> crate::agent::prompts::ConnectedIntegration {
- crate::agent::prompts::ConnectedIntegration {
+fn item(toolkit: &str, connected: bool) -> crate::integrations::ConnectedIntegration {
+ crate::integrations::ConnectedIntegration {
toolkit: toolkit.into(),
description: String::new(),
tools: Vec::new(),
diff --git a/crates/openhuman-core/src/integrations/recorded_tools.rs b/crates/openhuman-core/src/integrations/recorded_tools.rs
index 5d23902f1f..48060d4a8d 100644
--- a/crates/openhuman-core/src/integrations/recorded_tools.rs
+++ b/crates/openhuman-core/src/integrations/recorded_tools.rs
@@ -65,7 +65,7 @@ pub(crate) fn recorded_integration_actions(recorded: &[ToolSpec]) -> Vec<ToolSpe
pub(crate) fn rehydrate_integration_actions(
recorded: &[ToolSpec],
live: &[Box<dyn Tool>],
- integrations: &[crate::agent::prompts::ConnectedIntegration],
+ integrations: &[crate::integrations::ConnectedIntegration],
integrations_are_authoritative: bool,
) -> Vec<Box<dyn Tool>> {
let live_names: HashSet<&str> = live.iter().map(|tool| tool.name()).collect();
@@ -107,7 +107,7 @@ pub(crate) fn rehydrate_integration_actions(
/// The recorded TinySearch role tools (`web_search_tool`, `web_answer_tool`,
/// `web_contents_tool`), in recorded order.
-pub(super) fn recorded_search_tools(recorded: &[ToolSpec]) -> Vec<ToolSpec> {
+pub(crate) fn recorded_search_tools(recorded: &[ToolSpec]) -> Vec<ToolSpec> {
recorded
.iter()
.filter(|spec| is_search_role_tool(&spec.name))
@@ -125,7 +125,7 @@ fn is_search_role_tool(name: &str) -> bool {
/// answers with the actionable "no usable provider" error instead of an
/// unknown-tool failure.
#[cfg(feature = "modules")]
-pub(super) fn rehydrate_search_tools(
+pub(crate) fn rehydrate_search_tools(
recorded: &[ToolSpec],
live: &[&[Box<dyn Tool>]],
agent_id: &str,
diff --git a/crates/openhuman-core/src/integrations/recorded_tools_tests.rs b/crates/openhuman-core/src/integrations/recorded_tools_tests.rs
index 0cd2a3e876..d7516713a0 100644
--- a/crates/openhuman-core/src/integrations/recorded_tools_tests.rs
+++ b/crates/openhuman-core/src/integrations/recorded_tools_tests.rs
@@ -15,8 +15,8 @@ fn integration(
toolkit: &str,
connected: bool,
gated_tools: Vec<crate::agent::prompts::GatedIntegrationTool>,
-) -> crate::agent::prompts::ConnectedIntegration {
- crate::agent::prompts::ConnectedIntegration {
+) -> crate::integrations::ConnectedIntegration {
+ crate::integrations::ConnectedIntegration {
toolkit: toolkit.into(),
description: String::new(),
tools: Vec::new(),
diff --git a/crates/openhuman-core/src/integrations/session_delegation_refresh.rs b/crates/openhuman-core/src/integrations/session_delegation_refresh.rs
deleted file mode 100644
index 2548a3953b..0000000000
--- a/crates/openhuman-core/src/integrations/session_delegation_refresh.rs
+++ /dev/null
@@ -1,246 +0,0 @@
-//! Tool execution and Composio delegation refresh.
-
-use super::super::types::OpenHumanSessionHost;
-
-use std::sync::Arc;
-
-impl OpenHumanSessionHost {
- // ─────────────────────────────────────────────────────────────────
- // Sub-agent context snapshots
- // ─────────────────────────────────────────────────────────────────
-
- /// Fetches the user's active Composio connections and populates
- /// `self.connected_integrations` so the system prompt can surface them.
- ///
- /// Delegates to the shared [`crate::integrations::composio::fetch_connected_integrations`]
- /// which is the single source of truth for integration discovery.
- ///
- /// **No session-scoped Composio client is cached on the agent any
- /// more (#1710 Wave 2)**. Every downstream caller that needs to
- /// dispatch a Composio action now resolves a fresh client via
- /// [`crate::integrations::composio::client::resolve_composio_route`]
- /// at call time so the live `composio.mode` toggle is honoured
- /// without rebuilding the session — see `ComposioActionTool`,
- /// `ProviderContext::execute`, the 5 migrated agent tools in
- /// `composio/tools.rs`, and the spawn-time per-action tool build
- /// path in `subagent_host/ops.rs`.
- pub async fn fetch_connected_integrations(&mut self) {
- let config = match self.runtime_config.clone() {
- Some(config) => config,
- None => match crate::config::Config::load_or_init().await {
- Ok(config) => Arc::new(config),
- Err(e) => {
- log::debug!(
- "[agent] skipping connected integrations fetch: config load failed: {e}"
- );
- return;
- }
- },
- };
- self.connected_integrations =
- crate::integrations::composio::fetch_connected_integrations(&config).await;
- self.connected_integrations_initialized = true;
- }
-
- /// Re-synthesise `delegate_*` tools for the orchestrator's `subagents`
- /// declaration using the live `connected_integrations` slice, and
- /// reconcile the resulting set into `self.synthesized_tools` /
- /// `self.tool_specs` / `self.visible_tool_specs` / `self.visible_tool_names`.
- /// `self.tools` is never touched.
- ///
- /// **Reconciliation strategy** — full rebuild of the synthesised
- /// subset:
- ///
- /// 1. Drop every spec whose name was in [`Self::synthesized_tool_names`]
- /// from the previous synthesis. Direct tools (`query_memory`,
- /// `cron_add`, …) are untouched because their names are not in
- /// that set.
- /// 2. Append the fresh specs, and replace [`Self::synthesized_tools`]
- /// with the fresh instances — minus any name a durable tool owns,
- /// which the durable tool keeps (the same rule the builder applies).
- /// 3. Replace `synthesized_tool_names` with the new set so the
- /// next refresh has a clean mask to undo.
- ///
- /// This is safer than appending-only or strict-diff reconcile:
- ///
- /// * Stale tools after a revoke can never leak — anything from the
- /// previous synthesis is unconditionally dropped, the new set is
- /// authoritative.
- /// * Direct tools can never be accidentally removed — only names
- /// in `synthesized_tool_names` are touched, and a durable name is
- /// never added to that mask.
- /// * Duplicate registration is impossible — the fresh set replaces the
- /// previous one wholesale and is disjoint from `self.tools`, so a
- /// name is registered at most once across both sets.
- ///
- /// **When to call**: on turn 1 only when the session was built
- /// without a prewarmed Composio cache snapshot, and on any
- /// subsequent turn where the connection set has changed since the
- /// last reconcile (detected via
- /// [`Self::last_seen_integrations_hash`] vs.
- /// [`crate::integrations::composio::cached_active_integrations`]).
- ///
- /// **Concurrency**: this cannot fail on a shared session. The synthesised
- /// instances live in their own [`OpenHumanSessionHost::synthesized_tools`] `Arc`, which is
- /// *replaced* rather than mutated in place — so an in-flight turn or a
- /// spawned sub-agent holding a clone never blocks reconciliation. Those
- /// readers keep the previous, self-consistent set for the rest of their
- /// turn; the superseded instances are freed when the last of them drops.
- ///
- /// This is what makes the schema and the executable surface inseparable.
- /// Reconciling into `self.tools` instead required `Arc::get_mut`, which
- /// fails under exactly that sharing — and the old code proceeded to
- /// reconcile `tool_specs` anyway, so the two halves drifted: a newly
- /// connected toolkit's delegate had a spec with no instance (and no policy
- /// decision, so the fail-closed visibility filter hid it — silently missing
- /// until a unique-owner refresh) while a revoked toolkit's delegate kept its
- /// instance with no spec — still registered and callable (#6145).
- ///
- /// Returns nothing: with the synthesised set held in its own `Arc` there is
- /// no longer a way for this to half-apply, so the `bool` it used to hand
- /// back — and the caller rollback keyed on it — had no reachable `false`.
- pub fn refresh_delegation_tools(&mut self) {
- use crate::agent_registry::host_definition::AgentDefinitionRegistry;
- use crate::tools::orchestrator_tools::collect_orchestrator_tools;
-
- let Some(reg) = AgentDefinitionRegistry::current() else {
- // No registry — there's nothing we can do until the
- // registry is initialised. The agent's surface stays at
- // whatever the builder produced.
- return;
- };
- let Some(def) = self.resolved_definition() else {
- log::debug!(
- "[agent] refresh_delegation_tools: definition '{}' not in registry — skipping",
- self.agent_definition_id
- );
- return;
- };
- if def.subagents.is_empty() {
- return;
- }
-
- // A durable name wins a collision, exactly as at build time. Filtering
- // here also keeps such a name out of the mask below, so the spec
- // `retain` can never withdraw a durable tool's spec.
- let synthed = super::super::builder::drop_synthesized_name_collisions(
- &self.tools,
- collect_orchestrator_tools(&def, &reg, &self.connected_integrations),
- );
- let synthed_names: std::collections::HashSet<String> =
- synthed.iter().map(|t| t.name().to_string()).collect();
- let synthed_specs: Vec<Arc<tinytools::ToolSpec>> =
- synthed.iter().map(|t| Arc::new(t.spec())).collect();
-
- // Skip mutation when neither the previous nor the next synthesis
- // produced any names — saves work on agents without dynamic
- // delegation. `synthesized_tools` is already empty in that state, so
- // there is nothing to publish either.
- if self.synthesized_tool_names.is_empty() && synthed_names.is_empty() {
- return;
- }
-
- // Mask of the previous synthesis — the names whose `tool_specs` are
- // currently live (this set is kept in lock-step with `tool_specs`).
- let old_synth = std::mem::take(&mut self.synthesized_tool_names);
-
- // `tool_specs` are plain data and therefore cloneable. Drop exactly the
- // previous synthesised spec set, then append the fresh one.
- {
- let specs_vec = Arc::make_mut(&mut self.tool_specs);
- specs_vec.retain(|s| !old_synth.contains(&s.name));
- specs_vec.extend(synthed_specs);
- }
-
- // The executable instances are replaced wholesale. `synthed` already IS
- // the complete new set — `collect_orchestrator_tools` rebuilds every
- // delegate from the current connection set — so there is nothing to
- // retain and no mask to apply: assigning a fresh `Arc` drops exactly
- // the previous synthesis and nothing else.
- //
- // This is the step that used to be conditional on `Arc::get_mut`
- // succeeding against `self.tools`. It no longer touches `self.tools` at
- // all, so a concurrent reader cannot block it, and the specs above and
- // the instances here can never drift apart again (#6145).
- // Readers still holding the previous `Arc` keep a coherent set for the
- // rest of their turn; those instances are freed when the last one goes.
- let previous_instances = self.synthesized_tools.len();
- self.synthesized_tools = Arc::new(synthed);
- // The pack tool's handle holds a `Weak` into the allocation that was
- // just replaced. Without this re-bind it stops upgrading once the last
- // reader of the old set goes, and every packed delegate — `do_crypto`,
- // `make_presentation`, `create_image`, … — answers "no tool in skill"
- // instead of running: withheld from the wire and unreachable through
- // the route that replaced it.
- crate::tools::toolpacks::bind_synthesized_pack_registry(
- &self.tools,
- &self.synthesized_tools,
- );
-
- // `visible_tool_names` carries an explicit allowlist for
- // [`ToolScope::Named`] agents. Drop the previously-synthesised
- // names and add the new ones so the visible set tracks the
- // tool list. Wildcard-scope agents keep this empty ("no
- // filter") and never need touching.
- if !self.visible_tool_names.is_empty() {
- for name in &old_synth {
- self.visible_tool_names.remove(name);
- }
- for name in &synthed_names {
- self.visible_tool_names.insert(name.clone());
- }
- // The synthesis above re-adds delegate names wholesale, including
- // any that belong to a tool pack — so re-apply the withholding here
- // or a packed `delegate_*` tool would reappear on the wire on the
- // first Composio reconcile, silently undoing the compression.
- let agent_id = self.agent_definition_name.clone();
- crate::tools::toolpacks::strip_packed_from_visible(
- &mut self.visible_tool_names,
- &agent_id,
- );
- }
- // The synthesis above can carry `Deferred` entries (per-action
- // integration tools for a newly connected toolkit); keep them off the
- // wire and in the searchable set, exactly as the build did.
- self.recompute_deferred_tool_names();
-
- // Rebuild the visible-spec cache from the new tool_specs so the
- // next provider call carries the reconciled schema. Dedup
- // afterward so a delegate synthesised here (e.g.
- // `delegate_name = "plan"`) doesn't collide with a
- // same-named skill tool on the wire — Anthropic 400s on dup
- // tool names where OpenHuman's backend silently accepts.
- self.rebuild_tool_policy_session();
- self.sync_runtime_tool_surface();
-
- // Compute add/remove deltas for the log line — useful when
- // diagnosing a Composio connect/revoke that should have rebuilt
- // the surface but didn't. Materialise to owned `Vec<String>`
- // so we can move `synthed_names` into `self.synthesized_tool_names`
- // below without the log-statement reborrow blocking the move.
- let added: Vec<String> = synthed_names
- .iter()
- .filter(|n| !old_synth.contains(n.as_str()))
- .cloned()
- .collect();
- let removed: Vec<String> = old_synth
- .iter()
- .filter(|n| !synthed_names.contains(n.as_str()))
- .cloned()
- .collect();
-
- // Specs and instances reconciled to the same set in the same pass, so
- // the name mask tracks that set unconditionally.
- self.synthesized_tool_names = synthed_names.clone();
-
- log::info!(
- "[agent] refresh_delegation_tools: reconciled delegation surface for agent '{}' (display='{}'); now {} synthesised tool name(s); added={:?} removed={:?} superseded_instances={}",
- self.agent_definition_id,
- self.agent_definition_name,
- synthed_names.len(),
- added,
- removed,
- previous_instances
- );
- }
-}
diff --git a/crates/openhuman-core/src/tools/orchestrator_tools.rs b/crates/openhuman-core/src/tools/orchestrator_tools.rs
index 1e5e43b64e..36642a2d4e 100644
--- a/crates/openhuman-core/src/tools/orchestrator_tools.rs
+++ b/crates/openhuman-core/src/tools/orchestrator_tools.rs
@@ -33,7 +33,7 @@
//! [`SubagentEntry::Skills`]: tinyagents_definition::SubagentEntry::Skills
use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};
-use crate::agent::prompts::ConnectedIntegration;
+use crate::integrations::ConnectedIntegration;
use crate::integrations::composio::ComposioActionTool;
use tinyagents_definition::SubagentEntry;
@@ -197,7 +197,7 @@ pub fn collect_deferred_integration_actions(
let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
let mut tools: Vec<Box<dyn Tool>> = Vec::new();
for integration in integrations {
- let mut actions: Vec<&crate::agent::prompts::ConnectedIntegrationTool> =
+ let mut actions: Vec<&crate::integrations::ConnectedIntegrationTool> =
integration.tools.iter().collect();
actions.sort_by(|a, b| a.name.cmp(&b.name));
for action in actions {
diff --git a/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs b/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
index cde2293585..cc033a80d4 100644
--- a/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
+++ b/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
@@ -90,7 +90,7 @@ fn integration_with_actions(
let mut ci = integration(toolkit, description);
ci.tools = actions
.iter()
- .map(|name| crate::agent::prompts::ConnectedIntegrationTool {
+ .map(|name| crate::integrations::ConnectedIntegrationTool {
name: (*name).to_string(),
description: format!("{name} action"),
parameters: None,
@@ -329,7 +329,7 @@ fn unconnected_integrations_contribute_no_actions() {
ConnectedIntegration {
toolkit: "github".into(),
description: "GitHub access.".into(),
- tools: vec![crate::agent::prompts::ConnectedIntegrationTool {
+ tools: vec![crate::integrations::ConnectedIntegrationTool {
name: "GITHUB_CREATE_ISSUE".into(),
description: "Create an issue".into(),
parameters: None,