Hmbown/CodeWhale · error

child-local search

Error message

child-local search

What it means

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.

Solutions

  1. Read the `Err` variant by replacing `.expect(...)` temporarily with `match`/`unwrap_err` to see the underlying message
  2. Confirm TOOL_SEARCH is active on the child surface before deferred hydration (check `surface.active_names`)
  3. Verify the deferred catalog still contains a tool whose metadata matches the query "web"
  4. Update the query JSON if the tool-search argument schema changed

Example fix

// before
.await
.expect("child-local search");
// after (to diagnose)
.await
.unwrap_or_else(|e| panic!("child-local search failed: {e:?}"));
Defensive patterns

Strategy: try-catch

Validate before calling

assert!(surface.active_names.iter().any(|n| n == TOOL_SEARCH_NAME),
    "tool-search tool missing from active surface");
assert!(!catalog.is_empty(), "deferred catalog empty before tool_search");

Try / catch

let result = registry.execute_from_surface(...).await
    .unwrap_or_else(|e| panic!("child-local search failed: {e:?}"));

Prevention

When it happens

Trigger: `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.

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

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

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

    let actions = web.input_schema["properties"]["action"]["enum"]
        .as_array()
        .expect("Web action enum");
    assert_eq!(actions, &[json!("search"), json!("fetch")]);

    let mut surface = SubAgentToolSurface::new(catalog, &[]);
    assert!(!model_tool_names(model_request_tools(&mut surface)).contains("Web"));
    let request_active = surface.active_names.clone();
    let result = registry
        .execute_from_surface(
            "agent_scout",
            "",
            &mut surface,
            &request_active,
            TOOL_SEARCH_NAME,
            json!({"query": "web", "match": "regex"}),
        )
        .await
        .expect("child-local search");
    assert!(result.result.content.contains("\"tool_name\":\"Web\""));
    let same_batch = registry
        .execute_from_surface(
            "agent_scout",
            "",
            &mut surface,
            &request_active,
            "Web",
            json!({"action": "search", "query": "codewhale"}),
        )
        .await
        .expect("same-batch first use hydrates instead of executing");
    assert!(same_batch.result.content.contains("deferred"));
    assert!(model_tool_names(model_request_tools(&mut surface)).contains("Web"));
}

#[tokio::test]
async fn small_surface_fork_context_survives_fresh_child_discovery() {

View on GitHub (pinned to 73e0f67d83)