Skip to content

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

feat(profiles): allow hosts to override every profile's system prompt

Steven Enamakel12151f0879e2
diff --git a/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs b/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
index c4a0f2e45a..bea853740f 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
@@ -16,8 +16,9 @@ impl OpenHumanSessionHost {
session_id: Option<&str>,
) -> anyhow::Result<Self> {
if let Some(capabilities) = crate::profiles::capabilities::ProfileCapabilities::current() {
- let definition = super::factory::resolve_target_definition(config, agent_id)?
+ let mut definition = super::factory::resolve_target_definition(config, agent_id)?
.ok_or_else(|| anyhow::anyhow!("profile agent definition is unavailable"))?;
+ capabilities.apply_system_prompt(&mut definition);
let factory = capabilities.factory(config);
return Self::from_config_host_only(config, &definition, Some(&factory), session_id);
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
index bf70522fad..f2ab2e16f8 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
@@ -60,8 +60,10 @@ pub(crate) fn route(ctx: &ChannelRuntimeContext, channel: &str) -> HostRoute {
crate::agent::harness::definition::AgentDefinitionRegistry::current(),
) {
if let Some(definition) = definitions.get("orchestrator") {
+ let mut definition = definition.clone();
+ capabilities.apply_system_prompt(&mut definition);
return HostRoute::Agent(Box::new(HostAgent {
- definition: definition.clone(),
+ definition,
config: config.as_ref().clone(),
host_tools: Some(capabilities.factory(config)),
context,
diff --git a/crates/openhuman-core/src/profiles/capabilities.rs b/crates/openhuman-core/src/profiles/capabilities.rs
index fa0041cfcb..a0931d5e00 100644
--- a/crates/openhuman-core/src/profiles/capabilities.rs
+++ b/crates/openhuman-core/src/profiles/capabilities.rs
@@ -22,6 +22,8 @@ pub struct ProfileCapabilities {
groups: Vec<super::tools::SaasToolGroup>,
/// The shared engine, resolved only under the forced profile memory root.
pub memory_engine: Option<Arc<dyn tinymemory_api::MemoryEngine>>,
+ /// The operator's whole system prompt, when set.
+ system_prompt: Option<String>,
}
impl ProfileCapabilities {
@@ -41,6 +43,26 @@ impl ProfileCapabilities {
channels,
groups,
memory_engine,
+ system_prompt: None,
+ }
+ }
+
+ /// Replace every profile's system prompt with `prompt`, verbatim: no
+ /// SOUL/IDENTITY files, routing text, tool guidance or style block.
+ #[must_use]
+ pub fn with_system_prompt(mut self, prompt: Option<String>) -> Self {
+ self.system_prompt = prompt;
+ self
+ }
+
+ /// Make `definition` render the operator's system prompt, if one is set.
+ pub fn apply_system_prompt(
+ &self,
+ definition: &mut crate::agent::harness::definition::AgentDefinition,
+ ) {
+ if let Some(prompt) = &self.system_prompt {
+ definition.system_prompt =
+ crate::agent::harness::definition::PromptSource::Verbatim(prompt.clone());
}
}
diff --git a/crates/openhuman-embed/src/profiles/host.rs b/crates/openhuman-embed/src/profiles/host.rs
index 84ba36e289..786649136f 100644
--- a/crates/openhuman-embed/src/profiles/host.rs
+++ b/crates/openhuman-embed/src/profiles/host.rs
@@ -15,6 +15,7 @@ pub(super) struct ProfileHostOptions {
permission: Option<Arc<dyn ToolHook>>,
channels: HashMap<String, PermissionLevel>,
memory: Option<Arc<dyn tinymemory_api::MemoryEngine>>,
+ system_prompt: Option<String>,
}
impl ProfileHostOptions {
@@ -41,6 +42,15 @@ impl ProfileHostOptions {
"profile channel permissions cannot be dangerous".into(),
));
}
+ if self
+ .system_prompt
+ .as_deref()
+ .is_some_and(|p| p.trim().is_empty())
+ {
+ return Err(ProfileError::Boot(
+ "the profile system prompt must not be empty".into(),
+ ));
+ }
Ok(Arc::new(
openhuman_core::profiles::capabilities::ProfileCapabilities::new(
self.tools,
@@ -49,7 +59,8 @@ impl ProfileHostOptions {
self.channels,
openhuman_core::profiles::tools::parse_allowlist(&config.tool_allowlist),
self.memory,
- ),
+ )
+ .with_system_prompt(self.system_prompt),
))
}
}
@@ -101,6 +112,18 @@ impl ProfileRuntimeBuilder {
self
}
+ /// Own every profile's system prompt. `prompt` is sent verbatim, as the
+ /// whole system prompt of every chat, relay and cron turn: it replaces
+ /// each profile's SOUL.md and IDENTITY.md and OpenHuman's own routing,
+ /// tool-guidance and style sections, so nothing in it can mention a tool
+ /// the host does not offer. Users cannot override it. An empty prompt is
+ /// refused at build time. Without this the built-in prompt is used.
+ #[must_use]
+ pub fn system_prompt(mut self, prompt: impl Into<String>) -> Self {
+ self.host_options.system_prompt = Some(prompt.into());
+ self
+ }
+
/// Bind an existing engine through each profile's forced memory namespace.
/// The binding is profile-local; the global SaaS engine refusal stays intact.
#[must_use]