Skip to content

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

test: add tests for chat_agent_id selection and fallback behaviour

Steven Enamakelda9c1e3f9cb8
diff --git a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
index a0880f48e7..5f004387aa 100644
--- a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
@@ -496,3 +496,43 @@ fn fingerprint_diff_reports_every_differing_field() {
"{diff:?}"
);
}
+
+/// `[agent] chat_agent_id` is the only lever that moves the web-chat path off
+/// the orchestrator. A definition's `effective_max_iterations()` overwrites
+/// `agent.max_tool_iterations` in `session_host::builder::factory`, so an
+/// operator who needs a longer-running turn has to change *which agent
+/// answers*, not the cap — these cases pin that selection.
+#[test]
+fn chat_agent_id_selects_the_web_chat_agent_and_defaults_to_the_orchestrator() {
+ use super::pick_target_agent_id;
+
+ let mut config = crate::config::Config::default();
+ assert_eq!(
+ config.agent.chat_agent_id, None,
+ "the shipped default leaves it unset"
+ );
+ assert_eq!(
+ pick_target_agent_id(&config),
+ "orchestrator",
+ "unset falls back to what the app runs"
+ );
+
+ config.agent.chat_agent_id = Some("life_scenarios".to_string());
+ assert_eq!(pick_target_agent_id(&config), "life_scenarios");
+
+ // Padding is an operator typo in a hand-edited config.toml, not a request
+ // for an agent whose id has spaces in it.
+ config.agent.chat_agent_id = Some(" life_scenarios ".to_string());
+ assert_eq!(pick_target_agent_id(&config), "life_scenarios");
+
+ // Blank is "unset", not "an agent named empty string": a turn routed at an
+ // id the registry cannot answer would fail chat outright.
+ for blank in ["", " "] {
+ config.agent.chat_agent_id = Some(blank.to_string());
+ assert_eq!(
+ pick_target_agent_id(&config),
+ "orchestrator",
+ "blank {blank:?} falls back rather than routing nowhere"
+ );
+ }
+}