Skip to content

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

feat(session_host): make announcement note constructors testable and add regression test

Steven Enamakelef7eb21dc09a
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 68efea2ce6..a1fb9768c0 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -11,7 +11,8 @@ use tinyinference_llm::message::Message;
use super::runtime_session::{
account_committed_turn_against_goal, begin_turn_resume, holistic_last_turn_usage,
- reconcile_synthesized_visibility, OpenHumanSessionState,
+ integration_announcement_note, mcp_announcement_note, reconcile_synthesized_visibility,
+ skill_announcement_note, OpenHumanSessionState,
};
use super::{OpenHumanSessionFactory, OpenHumanSessionHooks, OpenHumanTranscriptCodec};
use crate::agent::tinyagents::host::OpenHumanRunContext;
@@ -373,3 +374,34 @@ async fn runtime_adapter_passes_host_context_commits_before_finalize_and_emits_o
);
let _ = std::fs::remove_dir_all(root);
}
+
+/// Mid-conversation availability notes are prepended to the user's next
+/// message. They must read as status, never as a task: the old "act on them
+/// immediately" wording had the orchestrator delegate to the integrations
+/// agent in the middle of an unrelated exchange and answer "what are we doing
+/// with the inbox?" to "so lets do 20-30 days then?".
+#[test]
+fn availability_notes_are_status_not_instructions() {
+ let notes = [
+ integration_announcement_note(&["gmail".to_string()]).unwrap(),
+ mcp_announcement_note(&["filesystem".to_string(), "github".to_string()]).unwrap(),
+ skill_announcement_note(&["deploy".to_string()]).unwrap(),
+ ];
+ for note in &notes {
+ assert!(
+ !note.contains("immediately"),
+ "note must not order an action: {note}"
+ );
+ assert!(
+ note.contains("not a request") && note.contains("only use these if"),
+ "note must defer to the user's message: {note}"
+ );
+ assert!(note.contains("Do not tell the user to reconnect or restart"));
+ }
+ assert!(notes[0].contains("delegate_to_integrations_agent") && notes[0].contains("gmail"));
+ assert!(notes[1].contains("use_mcp_server") && notes[1].contains("filesystem, github"));
+ assert!(notes[2].contains("run_skill") && notes[2].contains("deploy"));
+ assert!(integration_announcement_note(&[]).is_none());
+ assert!(mcp_announcement_note(&[]).is_none());
+ assert!(skill_announcement_note(&[]).is_none());
+}
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 8d3c61209c..7dad67506a 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1241,21 +1241,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.";
-fn integration_announcement_note(slugs: &[String]) -> Option<String> {
+pub(super) 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 via delegate_to_integrations_agent with the matching toolkit slug: {}. {ANNOUNCEMENT_TRAILER}",
slugs.join(", ")
))
}
-fn mcp_announcement_note(servers: &[String]) -> Option<String> {
+pub(super) 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 via the use_mcp_server delegate: {}. {ANNOUNCEMENT_TRAILER}",
servers.join(", ")
))
}
-fn skill_announcement_note(skill_ids: &[String]) -> Option<String> {
+pub(super) 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_skill`: {}. {ANNOUNCEMENT_TRAILER}",
skill_ids.join(", ")