{"record":{"id":"0ede6abbf8c9408f","repo":"Hmbown/CodeWhale","slug":"child-local-search","errorCode":null,"errorMessage":"child-local search","messagePattern":"child-local search","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":7917,"sourceCode":"    let actions = web.input_schema[\"properties\"][\"action\"][\"enum\"]\n        .as_array()\n        .expect(\"Web action enum\");\n    assert_eq!(actions, &[json!(\"search\"), json!(\"fetch\")]);\n\n    let mut surface = SubAgentToolSurface::new(catalog, &[]);\n    assert!(!model_tool_names(model_request_tools(&mut surface)).contains(\"Web\"));\n    let request_active = surface.active_names.clone();\n    let result = registry\n        .execute_from_surface(\n            \"agent_scout\",\n            \"\",\n            &mut surface,\n            &request_active,\n            TOOL_SEARCH_NAME,\n            json!({\"query\": \"web\", \"match\": \"regex\"}),\n        )\n        .await\n        .expect(\"child-local search\");\n    assert!(result.result.content.contains(\"\\\"tool_name\\\":\\\"Web\\\"\"));\n    let same_batch = registry\n        .execute_from_surface(\n            \"agent_scout\",\n            \"\",\n            &mut surface,\n            &request_active,\n            \"Web\",\n            json!({\"action\": \"search\", \"query\": \"codewhale\"}),\n        )\n        .await\n        .expect(\"same-batch first use hydrates instead of executing\");\n    assert!(same_batch.result.content.contains(\"deferred\"));\n    assert!(model_tool_names(model_request_tools(&mut surface)).contains(\"Web\"));\n}\n\n#[tokio::test]\nasync fn small_surface_fork_context_survives_fresh_child_discovery() {","sourceCodeStart":7899,"sourceCodeEnd":7935,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L7899-L7935","documentation":"A panic from `.expect(\"child-local search\")` in the test covering small-surface deferred tool discovery. The test calls `registry.execute_from_surface(..., TOOL_SEARCH_NAME, json!({\"query\": \"web\", \"match\": \"regex\"}))` and asserts the child-local tool search succeeds and returns a result mentioning `\"tool_name\":\"Web\"`; any error from the execution path (tool not found, hydration failure, argument rejection) becomes this panic.","triggerScenarios":"`execute_from_surface` returns `Err` for the TOOL_SEARCH tool — e.g. the tool-search tool is not on the child surface, the query arguments fail schema validation, or the deferred catalog contains no match for \"web\" so the tool returns an error.","commonSituations":"Renaming `TOOL_SEARCH_NAME` or the Web tool breaks the match; surface construction in the test (`SubAgentToolSurface::new(catalog, &[])`) drops the search tool; argument schema changes reject `{query, match}`.","solutions":["Read the `Err` variant by replacing `.expect(...)` temporarily with `match`/`unwrap_err` to see the underlying message","Confirm TOOL_SEARCH is active on the child surface before deferred hydration (check `surface.active_names`)","Verify the deferred catalog still contains a tool whose metadata matches the query \"web\"","Update the query JSON if the tool-search argument schema changed"],"exampleFix":"// before\n.await\n.expect(\"child-local search\");\n// after (to diagnose)\n.await\n.unwrap_or_else(|e| panic!(\"child-local search failed: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"assert!(surface.active_names.iter().any(|n| n == TOOL_SEARCH_NAME),\n    \"tool-search tool missing from active surface\");\nassert!(!catalog.is_empty(), \"deferred catalog empty before tool_search\");","typeGuard":null,"tryCatchPattern":"let result = registry.execute_from_surface(...).await\n    .unwrap_or_else(|e| panic!(\"child-local search failed: {e:?}\"));","preventionTips":["Log the underlying tool-execution error before asserting so failures are diagnosable","Keep TOOL_SEARCH_NAME and argument shapes in shared constants/types","Test hydration state (active_names) between call sites in the same test","Update argument fixtures whenever the tool-search schema changes"],"tags":["rust","async","tool-search","test-assertion"],"backgroundTag":"api-request-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}