{"record":{"id":"4efe880dc59a754a","repo":"Hmbown/CodeWhale","slug":"cached-read-tool-executes","errorCode":null,"errorMessage":"cached read tool executes","messagePattern":"cached read tool executes","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":8120,"sourceCode":"    // Exercise the LRU with a deliberately deferred read-only fixture tool;\n    // production goal controls are eager and must not consume cache slots.\n    catalog\n        .iter_mut()\n        .find(|tool| tool.name == \"get_goal\")\n        .expect(\"goal read fixture\")\n        .defer_loading = Some(true);\n    let mut others = catalog\n        .iter()\n        .filter(|tool| tool.defer_loading == Some(true) && tool.name != \"get_goal\")\n        .map(|tool| tool.name.clone());\n    let mut warm = vec![\"get_goal\".to_string()];\n    warm.extend(others.by_ref().take(7));\n    let ninth = others.next().expect(\"ninth deferred child tool\");\n    let mut surface = SubAgentToolSurface::new(catalog, &warm);\n    model_request_tools(&mut surface);\n    execute_surface_tool(&registry, &mut surface, \"get_goal\", json!({}))\n        .await\n        .expect(\"cached read tool executes\");\n    surface.hydrate(&ninth).expect(\"ninth activation\");\n    assert!(model_tool_names(model_request_tools(&mut surface)).contains(\"get_goal\"));\n}\n\n#[test]\nfn small_surface_depth_cap_removes_only_agent() {\n    let mut runtime =\n        stub_runtime().with_agent_tool_surface_options(enabled_agent_surface_options());\n    runtime.worker_profile = WorkerRuntimeProfile::for_role(FleetRole::Builder);\n    runtime.spawn_depth = runtime.max_spawn_depth;\n    let registry = SubAgentToolRegistry::new(\n        runtime,\n        FleetRole::Builder,\n        None,\n        crate::tools::todo::new_shared_todo_list(),\n        crate::tools::plan::new_shared_plan_state(),\n    );\n    let mut surface = SubAgentToolSurface::new(","sourceCodeStart":8102,"sourceCodeEnd":8138,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L8102-L8138","documentation":"A `.expect(\"cached read tool executes\")` panic: executing the get_goal tool on a warm SubAgentToolSurface returned Err. The test verifies a warmed (loaded into the deferred cache) read-only tool can still execute; failure means cached tool execution is broken.","triggerScenarios":"execute_surface_tool(&registry, &mut surface, \"get_goal\", json!({})) at crates/tui/src/tools/subagent/tests.rs:8120 returns Err — get_goal not hydrated despite being warm, missing goal state in the test runtime, or argument schema rejecting json!({}).","commonSituations":"Changing SubAgentToolSurface so warm-list tools are listed but not hydrated for execution; altering get_goal's required arguments so an empty object is invalid; removing the shared goal state setup helper from the test fixture.","solutions":["Read the inner Err to distinguish hydration failure from handler failure.","Confirm warm-list tools are hydrated by model_request_tools(&mut surface) before execution.","Ensure the test installs the shared goal state (new_shared_goal_state) that get_goal reads.","Pass get_goal's now-required arguments if its schema changed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the tool is hydrated before executing\nassert!(surface.is_hydrated(\"get_goal\"), \"get_goal should be hydrated from the warm list\");","typeGuard":null,"tryCatchPattern":"execute_surface_tool(&registry, &mut surface, \"get_goal\", json!({}))\n    .await\n    .unwrap_or_else(|e| panic!(\"cached get_goal execution failed: {e}\"));","preventionTips":["Install the shared goal state before any get_goal execution.","Validate warm-list tools hydrate during model_request_tools, not only at execution.","Keep tool argument schemas backward-compatible or update test payloads in lockstep.","Log the hydration state on failure for faster triage."],"tags":["rust","test-panic","deferred-tools","tool-execution"],"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-22T06:17:15.046Z"}