Skip to content

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

fix: enforce local only search on rpc routes

Steven Enamakelbd334a9c38a4
diff --git a/app/test/e2e/specs/chat-live-history-parity.spec.ts b/app/test/e2e/specs/chat-live-history-parity.spec.ts
index 8455f13a1f..c7136ae94c 100644
--- a/app/test/e2e/specs/chat-live-history-parity.spec.ts
+++ b/app/test/e2e/specs/chat-live-history-parity.spec.ts
@@ -136,6 +136,10 @@ function hasFinalReply(blocks: Block[]): boolean {
return blocks.some(block => block.kind === 'text' && block.text.includes(CANARY_FINAL));
}
+function normalizeRenderedText(text: string): string {
+ return text.replace(/\s+/g, ' ').trim();
+}
+
async function distanceFromBottom(): Promise<number> {
return (await browser.execute(() => {
const viewport = document.querySelector('[data-slot="aui_thread-viewport"]');
@@ -278,7 +282,9 @@ describe('Chat live/history parity', () => {
block => block.kind === 'text' && block.text.includes(CANARY_FINAL)
);
expect(finalBlock).toBeDefined();
- expect(finalBlock?.text).toEqual(FINAL_ANSWER);
+ expect(normalizeRenderedText(finalBlock?.text ?? '')).toEqual(
+ normalizeRenderedText(FINAL_ANSWER)
+ );
// Reopen through the visible thread list after dropping runtime state, so
// the conversation is reloaded from persisted messages and the transcript.
diff --git a/crates/openhuman-core/src/search/tools.rs b/crates/openhuman-core/src/search/tools.rs
index 36792f8586..c237144fb5 100644
--- a/crates/openhuman-core/src/search/tools.rs
+++ b/crates/openhuman-core/src/search/tools.rs
@@ -180,7 +180,7 @@ impl Tool for TinySearchTool {
}
}
-fn local_only_search_block(tool_name: &str) -> Option<String> {
+pub(crate) fn local_only_search_block(tool_name: &str) -> Option<String> {
crate::security::egress::local_only_tool_block(&crate::security::egress::EgressDescriptor::new(
"tinysearch",
tool_name,
diff --git a/crates/openhuman-core/src/tools/schemas/web_search.rs b/crates/openhuman-core/src/tools/schemas/web_search.rs
index f3475faa4f..ba3dd3619e 100644
--- a/crates/openhuman-core/src/tools/schemas/web_search.rs
+++ b/crates/openhuman-core/src/tools/schemas/web_search.rs
@@ -47,6 +47,11 @@ async fn run_role_tool_with(
if !config.search.is_enabled() {
return Err("web search is disabled in settings".to_string());
}
+ // JSON-RPC, MCP, and agent callers share this dispatcher; enforce egress
+ // policy here so non-agent routes cannot bypass LocalOnly mode.
+ if let Some(message) = crate::search::tools::local_only_search_block(tool) {
+ return Err(message);
+ }
ensure_servable(config, tool, &arguments)?;
let request = tinysearch_bus::ExecuteToolRequest {
name: tool.to_string(),