Hmbown/CodeWhale · error

child assignment

Error message

child assignment

What it means

A panic from `.expect("child assignment")` in the fork-context test. The test takes `child_messages.last()` and asserts the final child message contains "continue from parent"; if the child request has no messages (or the last message is not a text-bearing content block), `.last()` returns `None` or `message_text` yields nothing and the expect/`contains` panics. It guards that forked children receive their assignment as the final transcript message without mutating the parent context.

Solutions

  1. Print the child transcript (`dbg!(&child_messages)`) to see whether the assignment message exists and in what shape
  2. Update `message_text`/the extraction path if the assignment now lives in a different content-block type
  3. If request setup intentionally stopped appending the assignment, fix the request-setup code in the registry so forked children receive their task; otherwise update the assertion text to match the new wording

Example fix

// before
message_text(child_messages.last().expect("child assignment"))
    .contains("continue from parent")
// after (diagnose)
let last = child_messages.last().expect("child assignment");
assert!(!message_text(last).is_empty(), "last child message text: {last:?}");
Defensive patterns

Strategy: validation

Validate before calling

assert!(!child_messages.is_empty(), "child request has no messages");
let last = child_messages.last().unwrap();
assert!(!message_text(last).is_empty(), "last child message has no text: {last:?}");

Type guard

fn last_message_text(messages: &[Message]) -> Option<String> {
    messages.last().map(message_text).filter(|t| !t.is_empty())
}

Try / catch

let last = child_messages.last()
    .unwrap_or_else(|| panic!("child request produced no messages"));
assert!(
    message_text(last).contains("continue from parent"),
    "assignment text missing; last message: {last:?}"
);

Prevention

When it happens

Trigger: The child request message list is empty because `SubAgentToolRegistry` request setup failed to append the assignment, or the final message is a tool/system block with no extractable text so `message_text` returns an empty string and the assertion fails.

Common situations: Refactors of the child-request construction (message ordering, content-block shapes, system-prompt injection) drop or relocate the assignment text; forked-context plumbing changes prepend/append behavior.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

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

                    .to_string(),
                    is_error: None,
                    content_blocks: None,
                }],
            },
        ],
        structured_state_block: None,
        work_source: None,
    };
    let original_messages = context.messages.clone();
    let (child_messages, mut surface) =
        forked_child_request_fixture(&registry, &FleetRole::Builder, &context);
    assert_eq!(
        &child_messages[..original_messages.len()],
        original_messages.as_slice(),
        "the child request must retain the forked transcript prefix"
    );
    assert!(
        message_text(child_messages.last().expect("child assignment"))
            .contains("continue from parent")
    );
    assert_eq!(
        context.messages, original_messages,
        "child request setup must not mutate the captured parent context"
    );

    // A parent tool-search result is transcript context, not inherited tool
    // authority. The child starts from its own filtered catalog/cache and can
    // independently discover Web plus a tool the parent never searched for.
    assert!(!model_tool_names(model_request_tools(&mut surface)).contains("Web"));
    execute_surface_tool(
        &registry,
        &mut surface,
        TOOL_SEARCH_NAME,
        json!({"query": "web", "match": "regex"}),
    )
    .await

View on GitHub (pinned to 73e0f67d83)