Hmbown/CodeWhale · error

cached read tool executes

Error message

cached read tool executes

What it means

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.

Solutions

  1. Read the inner Err to distinguish hydration failure from handler failure.
  2. Confirm warm-list tools are hydrated by model_request_tools(&mut surface) before execution.
  3. Ensure the test installs the shared goal state (new_shared_goal_state) that get_goal reads.
  4. Pass get_goal's now-required arguments if its schema changed.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the tool is hydrated before executing
assert!(surface.is_hydrated("get_goal"), "get_goal should be hydrated from the warm list");

Try / catch

execute_surface_tool(&registry, &mut surface, "get_goal", json!({}))
    .await
    .unwrap_or_else(|e| panic!("cached get_goal execution failed: {e}"));

Prevention

When it happens

Trigger: 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!({}).

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/4efe880dc59a754a. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/subagent/tests.rs:8120

    // Exercise the LRU with a deliberately deferred read-only fixture tool;
    // production goal controls are eager and must not consume cache slots.
    catalog
        .iter_mut()
        .find(|tool| tool.name == "get_goal")
        .expect("goal read fixture")
        .defer_loading = Some(true);
    let mut others = catalog
        .iter()
        .filter(|tool| tool.defer_loading == Some(true) && tool.name != "get_goal")
        .map(|tool| tool.name.clone());
    let mut warm = vec!["get_goal".to_string()];
    warm.extend(others.by_ref().take(7));
    let ninth = others.next().expect("ninth deferred child tool");
    let mut surface = SubAgentToolSurface::new(catalog, &warm);
    model_request_tools(&mut surface);
    execute_surface_tool(&registry, &mut surface, "get_goal", json!({}))
        .await
        .expect("cached read tool executes");
    surface.hydrate(&ninth).expect("ninth activation");
    assert!(model_tool_names(model_request_tools(&mut surface)).contains("get_goal"));
}

#[test]
fn small_surface_depth_cap_removes_only_agent() {
    let mut runtime =
        stub_runtime().with_agent_tool_surface_options(enabled_agent_surface_options());
    runtime.worker_profile = WorkerRuntimeProfile::for_role(FleetRole::Builder);
    runtime.spawn_depth = runtime.max_spawn_depth;
    let registry = SubAgentToolRegistry::new(
        runtime,
        FleetRole::Builder,
        None,
        crate::tools::todo::new_shared_todo_list(),
        crate::tools::plan::new_shared_plan_state(),
    );
    let mut surface = SubAgentToolSurface::new(

View on GitHub (pinned to 73e0f67d83)