{"record":{"id":"c3e7cdf9ab9db24d","repo":"Hmbown/CodeWhale","slug":"new-child-local-discovery","errorCode":null,"errorMessage":"new child-local discovery","messagePattern":"new child-local discovery","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":8002,"sourceCode":"    // authority. The child starts from its own filtered catalog/cache and can\n    // independently discover Web plus a tool the parent never searched for.\n    assert!(!model_tool_names(model_request_tools(&mut surface)).contains(\"Web\"));\n    execute_surface_tool(\n        &registry,\n        &mut surface,\n        TOOL_SEARCH_NAME,\n        json!({\"query\": \"web\", \"match\": \"regex\"}),\n    )\n    .await\n    .expect(\"fresh discovery despite forked context\");\n    execute_surface_tool(\n        &registry,\n        &mut surface,\n        TOOL_SEARCH_NAME,\n        json!({\"query\": \"apply_patch\", \"match\": \"regex\"}),\n    )\n    .await\n    .expect(\"new child-local discovery\");\n    let names = model_tool_names(model_request_tools(&mut surface));\n    assert!(names.contains(\"Web\"));\n    assert!(names.contains(\"apply_patch\"));\n}\n\n#[tokio::test]\nasync fn small_surface_denied_warm_tool_is_not_resurrected() {\n    let mut runtime =\n        stub_runtime().with_agent_tool_surface_options(enabled_agent_surface_options());\n    runtime.worker_profile = WorkerRuntimeProfile::for_role(FleetRole::Scout);\n    runtime.worker_profile.denied_tools.push(\"Web\".to_string());\n    let registry = SubAgentToolRegistry::new(\n        runtime,\n        FleetRole::Scout,\n        None,\n        crate::tools::todo::new_shared_todo_list(),\n        crate::tools::plan::new_shared_plan_state(),\n    );","sourceCodeStart":7984,"sourceCodeEnd":8020,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L7984-L8020","documentation":"A `.expect(\"new child-local discovery\")` panic: the tool_search call for query \"apply_patch\" with regex match failed inside a freshly created child-local SubAgentToolSurface. The test asserts that a child agent can independently discover tools; the panic means discovery returned Err rather than results.","triggerScenarios":"execute_surface_tool(&registry, &mut surface, TOOL_SEARCH_NAME, json!({\"query\":\"apply_patch\",\"match\":\"regex\"})) returns Err in crates/tui/src/tools/subagent/tests.rs:8002 — child catalog missing apply_patch, regex mode rejected, or surface not initialized with a catalog.","commonSituations":"Refactoring the child surface constructor so its catalog is empty; renaming apply_patch; changing tool_search query semantics so regex patterns no longer match tool descriptions.","solutions":["Run the test with --nocapture and inspect the underlying Err from tool_search.","Confirm the child-local catalog includes a tool named apply_patch and TOOL_SEARCH_NAME resolves.","Verify the child surface is constructed with the same catalog the parent used (SubAgentToolSurface::new(catalog, ...)).","Test the same query against the parent surface to isolate whether the child surface path is at fault."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"assert!(catalog.iter().any(|t| t.name == \"apply_patch\"), \"apply_patch missing from child catalog\");","typeGuard":"fn catalog_contains(catalog: &[Tool], name: &str) -> bool { catalog.iter().any(|t| t.name == name) }","tryCatchPattern":"match execute_surface_tool(&registry, &mut surface, TOOL_SEARCH_NAME, &args).await {\n    Ok(v) => v,\n    Err(e) => panic!(\"child-local discovery failed: {e}\"),\n}","preventionTips":["Build child surfaces from the same catalog source as the parent.","Test discovery against both literal and regex match modes to catch mode-specific regressions.","Rename tools through a single constant, never raw strings.","Run discovery tests after any SubAgentToolSurface constructor change."],"tags":["rust","test-panic","tool-search","subagent"],"backgroundTag":"tool-execution-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}