Skip to content

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

chore: files changed crates/openhuman-core/src/agent/debug/mod.rs,crates/openhuman-core/src/agent/se

Steven Enamakel437b5f366b81
diff --git a/crates/openhuman-core/src/agent/debug/mod.rs b/crates/openhuman-core/src/agent/debug/mod.rs
index 19d14e738c..8c489f6030 100644
--- a/crates/openhuman-core/src/agent/debug/mod.rs
+++ b/crates/openhuman-core/src/agent/debug/mod.rs
@@ -94,6 +94,9 @@ pub async fn dump_agent_prompt(options: DumpPromptOptions) -> Result<DumpedPromp
options.model_override.clone(),
)
.await?;
+ let ctx = crate::core::runtime::DispatchCtx::host_default();
+ #[cfg(all(feature = "flows", feature = "skills"))]
+ crate::skills::bundled::flow_authoring::prewarm(&ctx, &config, None).await;
// Ensure the registry is populated — `from_config_for_agent`
// errors for any non-orchestrator id when the global registry
@@ -101,7 +104,7 @@ pub async fn dump_agent_prompt(options: DumpPromptOptions) -> Result<DumpedPromp
AgentDefinitionRegistry::init_global(&config.workspace_dir)
.context("initialising AgentDefinitionRegistry for prompt dump")?;
- render_via_session(&config, &options.agent_id).await
+ render_via_session(&ctx, &config, &options.agent_id).await
}
/// Dump every registered agent's system prompt in one shot.
@@ -115,6 +118,9 @@ pub async fn dump_all_agent_prompts(
) -> Result<Vec<DumpedPrompt>> {
let config =
load_dump_config(workspace_dir_override, config_path_override, model_override).await?;
+ let ctx = crate::core::runtime::DispatchCtx::host_default();
+ #[cfg(all(feature = "flows", feature = "skills"))]
+ crate::skills::bundled::flow_authoring::prewarm(&ctx, &config, None).await;
AgentDefinitionRegistry::init_global(&config.workspace_dir)
.context("initialising AgentDefinitionRegistry for prompt dump")?;
@@ -131,7 +137,7 @@ pub async fn dump_all_agent_prompts(
let mut results = Vec::with_capacity(ids.len());
for id in ids {
- let dumped = render_via_session(&config, &id)
+ let dumped = render_via_session(&ctx, &config, &id)
.await
.with_context(|| format!("rendering prompt for agent `{id}`"))?;
results.push(dumped);
@@ -174,9 +180,13 @@ async fn load_dump_config(
/// Build a real [`Agent`] via `from_config_for_agent`, populate live
/// connected integrations, and render the turn-1 system prompt.
-async fn render_via_session(config: &Config, agent_id: &str) -> Result<DumpedPrompt> {
+async fn render_via_session(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+ agent_id: &str,
+) -> Result<DumpedPrompt> {
let mut agent = OpenHumanSessionHost::from_config_for_agent(
- &crate::core::runtime::DispatchCtx::host_default(),
+ ctx,
config,
agent_id,
)
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 1b3f224e13..7ce042368f 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -795,7 +795,7 @@ impl OpenHumanSessionHost {
.workspace_dir(config.workspace_dir.clone())
.action_dir(config.action_dir.clone())
.workspace_descriptor(workspace_descriptor)
- .workflows(workflows::session_workflows(config, host_only))
+ .workflows(workflows::session_workflows(ctx, config, host_only))
.post_turn_hooks(post_turn_hooks)
.agent_definition_name(agent_id.to_string())
.omit_memory_context(effective_omit_memory_context)
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory_workflows.rs b/crates/openhuman-core/src/agent/session_host/builder/factory_workflows.rs
index 1d9945eb2d..a15054c189 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory_workflows.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory_workflows.rs
@@ -3,11 +3,15 @@
use crate::config::Config;
use tinyskills::Skill as Workflow;
-pub(super) fn session_workflows(config: &Config, host_only: bool) -> Vec<Workflow> {
+pub(super) fn session_workflows(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+ host_only: bool,
+) -> Vec<Workflow> {
if host_only {
return Vec::new();
}
- let catalogue = crate::skills::load_workflow_metadata(&config.workspace_dir);
+ let catalogue = crate::skills::load_workflow_metadata_for(ctx, config);
#[cfg(feature = "flows")]
let catalogue = {
let mut catalogue = catalogue;
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
index 5756c00d85..bdb2b69ac2 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -124,6 +124,8 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->
// user-configured `[agent].agent_timeout_secs` (#5027).
// Model, tools and the identity-refreshing system prompt (`turn_parts`),
// shared with the hosted-channel relay.
+ #[cfg(all(feature = "flows", feature = "skills"))]
+ crate::skills::bundled::flow_authoring::prewarm(&dispatch, &config, None).await;
let parts = build_channel_turn_parts(&dispatch, &config, &security, PromptToolDescs::Fixed)?;
let model = parts.model.clone();
let workspace = config.workspace_dir.clone();
@@ -134,7 +136,7 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->
// ignored. Idempotent + shares a process-global OnceLock with the
// `bootstrap_core_runtime` site, so it registers exactly once regardless of
// which startup path runs first (web-chat-only cores never reach here).
- crate::skills::bus::ensure_triggered_workflow_subscriber(&workspace);
+ crate::skills::bus::ensure_triggered_workflow_subscriber_for(&dispatch, &config, None);
if !skills.is_empty() {
println!(
diff --git a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
index 7d9dfe7093..23253236d9 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
@@ -170,7 +170,7 @@ pub(crate) fn build_channel_turn_parts(
let skills = if capabilities.is_some() {
Vec::new()
} else {
- crate::skills::load_workflow_metadata(&workspace)
+ crate::skills::load_workflow_metadata_for(dispatch, config)
};
let tool_descs: Vec<(String, String)> = if capabilities.is_some() {
diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rs
index b13698d42c..233b97dfd2 100644
--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs
+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs
@@ -34,6 +34,12 @@ pub(crate) async fn bootstrap_core_runtime(
};
let workspace_dir = cfg.workspace_dir.clone();
+ // The workflow metadata loader is synchronous. Resolve the module-owned
+ // flow-authoring files before any subscriber or session can snapshot it;
+ // this optional prewarm is bounded and fails open for ordinary chat.
+ #[cfg(all(feature = "flows", feature = "skills"))]
+ crate::skills::bundled::flow_authoring::prewarm(ctx, &cfg, Some(domains)).await;
+
// --- Legacy store import ---------------------------------------------
// With a storage backend installed, bring the workspace's per-domain
// SQLite files (approvals, devices, notifications, task sources) into it
@@ -249,7 +255,11 @@ pub(crate) async fn bootstrap_core_runtime(
// Gated on the Skills domain (#4808 review): under `harness()`/`none()` the
// skills controllers are absent, so their trigger subscriber must not install.
if domains.allows(crate::core::all::DomainGroup::Skills) {
- crate::skills::bus::ensure_triggered_workflow_subscriber(&workspace_dir);
+ crate::skills::bus::ensure_triggered_workflow_subscriber_for(
+ ctx,
+ &cfg,
+ Some(domains),
+ );
} else {
log::debug!("[boot] triggered-workflow subscriber SKIPPED — Skills domain disabled");
}
diff --git a/crates/openhuman-core/src/skills/bus.rs b/crates/openhuman-core/src/skills/bus.rs
index 0039582677..5c34489ab7 100644
--- a/crates/openhuman-core/src/skills/bus.rs
+++ b/crates/openhuman-core/src/skills/bus.rs
@@ -207,6 +207,19 @@ pub fn ensure_triggered_workflow_subscriber(workspace: &std::path::Path) {
});
}
+/// Idempotently install the subscriber from the exact startup Config and
+/// profile context after async builtin prewarming has completed.
+pub(crate) fn ensure_triggered_workflow_subscriber_for(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &crate::config::Config,
+ domains: Option<crate::core::runtime::DomainSet>,
+) {
+ TRIGGERED_WORKFLOW_HANDLE.get_or_init(|| {
+ let workflows = crate::skills::load_workflow_metadata_for_domains(ctx, config, domains);
+ register_triggered_workflow_subscriber(&workflows)
+ });
+}
+
#[cfg(test)]
#[path = "bus_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/skills/stub.rs b/crates/openhuman-core/src/skills/stub.rs
index 7c150c7878..554254d0f6 100644
--- a/crates/openhuman-core/src/skills/stub.rs
+++ b/crates/openhuman-core/src/skills/stub.rs
@@ -119,6 +119,15 @@ pub mod bus {
pub fn ensure_triggered_workflow_subscriber(_workspace: &std::path::Path) {
log::debug!("[skills-stub] ensure_triggered_workflow_subscriber skipped (skills disabled)");
}
+
+ /// No-op with skills compiled out.
+ pub fn ensure_triggered_workflow_subscriber_for(
+ _ctx: &crate::core::runtime::DispatchCtx,
+ _config: &crate::config::Config,
+ _domains: Option<crate::core::runtime::DomainSet>,
+ ) {
+ log::debug!("[skills-stub] scoped triggered-workflow subscriber skipped (skills disabled)");
+ }
}
// NOTE: no `tools` module here. The `pub use skills::tools::*` glob in