The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(e2e): add web_answer_tool e2e test and Gemini grounding mock
Steven Enamakelcaeb89e7fc21
diff --git a/app/test/e2e/specs/harness-search-tool-flow.spec.ts b/app/test/e2e/specs/harness-search-tool-flow.spec.tsindex 296d2a7353..419a8e602e 100644--- a/app/test/e2e/specs/harness-search-tool-flow.spec.ts+++ b/app/test/e2e/specs/harness-search-tool-flow.spec.ts@@ -8,6 +8,7 @@* Actual tool names discovered in crates/openhuman-core/src/tools/impl/:* - "memory_recall" — recall / search personal memories* - "web_search_tool" — search the web (NOT "web_search")+ * - "web_answer_tool" — grounded answer with citations (search role tools)* - "file_read" — read a file from the filesystem* - "memory_tree_search_entities" — search the memory tree for entities*@@ -33,6 +34,9 @@* S3.3 — File read: "read the README"* → LLM emits file_read tool call → canned snippet in second turn* → UI shows final reply containing the snippet.+ * S3.4 — Web answer: "what is the capital of Australia"+ * → LLM emits web_answer_tool tool call (the grounded-answer role+ * tool, served by Gemini by default) → canned final reply.** Observation strategy:* Tool call LLM requests: second LLM turn body will contain the tool name@@ -340,4 +344,53 @@ describe('Harness - Search tool-flow', () => {console.log(`${LOG_PREFIX} S3.3: PASSED`);});++ // ── S3.4 — Web answer ────────────────────────────────────────────────────++ it('S3.4 — web_answer_tool: "what is the capital of Australia" → final reply', async function () {+ this.timeout(120_000);+ console.log(`${LOG_PREFIX} S3.4: begin`);++ clearRequestLog();+ resetMockBehavior();++ const CANARY = 'canary-web-answer-g7h8';++ // Role tool: "web_answer_tool" returns a grounded answer with citations,+ // served by the first usable provider in the answer role (Gemini by+ // default). Whether it succeeds against the mock or fails, the forced+ // second turn always returns the canary.+ const FORCED = [+ {+ content: '',+ toolCalls: [+ {+ id: 'call_web_answer_1',+ name: 'web_answer_tool',+ arguments: JSON.stringify({ query: 'capital of Australia' }),+ },+ ],+ },+ { content: `The capital of Australia is Canberra. ${CANARY}` },+ ];+ setMockBehavior('llmForcedResponses', JSON.stringify(FORCED));+ setMockBehavior('llmStreamChunkDelayMs', '10');++ await navigateChatAndSend('what is the capital of Australia');++ await browser.waitUntil(async () => await textExists(CANARY), {+ timeout: 60_000,+ timeoutMsg: `S3.4: web-answer canary "${CANARY}" never appeared`,+ });+ expect(await waitForAssistantReplyContaining('Canberra', { logPrefix: LOG_PREFIX })).toBe(true);++ const log = getRequestLog() as Array<{ method: string; url: string; body?: string }>;+ const llmHits = log.filter(r => r.method === 'POST' && r.url.includes('/chat/completions'));+ expect(llmHits.length).toBeGreaterThanOrEqual(2);+ if (!findToolInLlmLog(log, 'web_answer_tool')) {+ console.warn(`${LOG_PREFIX} S3.4: "web_answer_tool" not found in LLM request bodies`);+ }++ console.log(`${LOG_PREFIX} S3.4: PASSED`);+ });});diff --git a/tests/raw_coverage/worker_b_raw_coverage_e2e.rs b/tests/raw_coverage/worker_b_raw_coverage_e2e.rsindex 824ffeb3db..9e8b34435f 100644--- a/tests/raw_coverage/worker_b_raw_coverage_e2e.rs+++ b/tests/raw_coverage/worker_b_raw_coverage_e2e.rs@@ -149,6 +149,10 @@ async fn serve_mock() -> MockHarness {.route("/v1/missing-models", get(mock_missing_models)).route("/v1/chat/completions", post(mock_chat_completions)).route("/agent-integrations/exa/search", post(mock_exa_search))+ .route(+ "/agent-integrations/gemini/models/{model}/generate-content",+ post(mock_gemini_generate),+ ).with_state(state.clone());let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await@@ -206,6 +210,32 @@ async fn mock_chat_completions(}))}+async fn mock_gemini_generate(+ State(state): State<MockState>,+ axum::extract::Path(model): axum::extract::Path<String>,+ Json(body): Json<Value>,+) -> Json<Value> {+ state.requests.lock().expect("requests lock").push(json!({+ "path": format!("/agent-integrations/gemini/models/{model}/generate-content"),+ "body": body+ }));+ Json(json!({+ "success": true,+ "data": {+ "modelVersion": model,+ "candidates": [{+ "content": {"role": "model", "parts": [{"text": "Worker B grounded answer."}]},+ "groundingMetadata": {+ "groundingChunks": [+ {"web": {"uri": "https://example.com/grounded", "title": "Grounded source"}}+ ]+ }+ }],+ "costUsd": 0.002+ }+ }))+}+async fn mock_exa_search(State(state): State<MockState>, Json(body): Json<Value>) -> Json<Value> {state.requests@@ -456,6 +486,75 @@ async fn inference_provider_success_paths_use_mock_models_and_chat() {mock.join.abort();}+#[tokio::test]+async fn tools_web_answer_uses_managed_gemini_grounding_and_returns_citations() {+ if std::env::var_os("TINYSEARCH_TEST_MODULE").is_none() {+ eprintln!("skipping: TINYSEARCH_TEST_MODULE is not set");+ return;+ }+ let _lock = env_lock();+ let mock = serve_mock().await;+ let harness = setup().await;+ configure_mock_provider(&harness.rpc_base, &mock.base).await;+ seed_session_token().await;++ let settings = rpc(+ &harness.rpc_base,+ 210,+ "openhuman.config_update_search_settings",+ json!({+ "enabled": true,+ "providers": {"gemini": {"enabled": true, "route": "managed"}},+ "roles": {"answer": ["gemini"]}+ }),+ )+ .await;+ let settings = payload(&settings, "config_update_search_settings");+ assert_eq!(+ settings.pointer("/effective_roles/answer/0").and_then(Value::as_str),+ Some("gemini"),+ "managed Gemini should serve the answer role: {settings}"+ );++ let answer = rpc(+ &harness.rpc_base,+ 211,+ "openhuman.tools_web_answer",+ json!({ "query": "who maintains worker b" }),+ )+ .await;+ let answer = payload(&answer, "tools_web_answer");+ assert_eq!(answer.get("provider").and_then(Value::as_str), Some("Gemini"));+ assert_eq!(answer.get("role").and_then(Value::as_str), Some("answer"));+ assert!(answer+ .get("answer")+ .and_then(Value::as_str)+ .is_some_and(|text| text.contains("Worker B grounded answer")));+ assert_eq!(+ answer.pointer("/citations/0/url").and_then(Value::as_str),+ Some("https://example.com/grounded")+ );++ let seen = mock.state.requests.lock().expect("requests lock").clone();+ let body = seen+ .iter()+ .find(|entry| {+ entry+ .get("path")+ .and_then(Value::as_str)+ .is_some_and(|path| path.starts_with("/agent-integrations/gemini/models/"))+ })+ .and_then(|entry| entry.get("body"))+ .expect("managed Gemini request body");+ assert!(+ body.pointer("/tools/0/googleSearch").is_some(),+ "grounded answers must request Google Search grounding: {body}"+ );++ harness.rpc_join.abort();+ mock.join.abort();+}+#[tokio::test]async fn tools_web_search_success_path_uses_backend_session_and_shapes_results() {// The search RPC runs through the TinySearch module; CI and