{"record":{"id":"a3486e4727224259","repo":"Hmbown/CodeWhale","slug":"child-assignment","errorCode":null,"errorMessage":"child assignment","messagePattern":"child assignment","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":7975,"sourceCode":"                    .to_string(),\n                    is_error: None,\n                    content_blocks: None,\n                }],\n            },\n        ],\n        structured_state_block: None,\n        work_source: None,\n    };\n    let original_messages = context.messages.clone();\n    let (child_messages, mut surface) =\n        forked_child_request_fixture(&registry, &FleetRole::Builder, &context);\n    assert_eq!(\n        &child_messages[..original_messages.len()],\n        original_messages.as_slice(),\n        \"the child request must retain the forked transcript prefix\"\n    );\n    assert!(\n        message_text(child_messages.last().expect(\"child assignment\"))\n            .contains(\"continue from parent\")\n    );\n    assert_eq!(\n        context.messages, original_messages,\n        \"child request setup must not mutate the captured parent context\"\n    );\n\n    // A parent tool-search result is transcript context, not inherited tool\n    // 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","sourceCodeStart":7957,"sourceCodeEnd":7993,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L7957-L7993","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Print the child transcript (`dbg!(&child_messages)`) to see whether the assignment message exists and in what shape","Update `message_text`/the extraction path if the assignment now lives in a different content-block type","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"],"exampleFix":"// before\nmessage_text(child_messages.last().expect(\"child assignment\"))\n    .contains(\"continue from parent\")\n// after (diagnose)\nlet last = child_messages.last().expect(\"child assignment\");\nassert!(!message_text(last).is_empty(), \"last child message text: {last:?}\");","handlingStrategy":"validation","validationCode":"assert!(!child_messages.is_empty(), \"child request has no messages\");\nlet last = child_messages.last().unwrap();\nassert!(!message_text(last).is_empty(), \"last child message has no text: {last:?}\");","typeGuard":"fn last_message_text(messages: &[Message]) -> Option<String> {\n    messages.last().map(message_text).filter(|t| !t.is_empty())\n}","tryCatchPattern":"let last = child_messages.last()\n    .unwrap_or_else(|| panic!(\"child request produced no messages\"));\nassert!(\n    message_text(last).contains(\"continue from parent\"),\n    \"assignment text missing; last message: {last:?}\"\n);","preventionTips":["Assert non-empty transcript before checking content so empty-list and wrong-content failures are distinct","Keep child-assignment wording in a shared constant used by both setup and tests","Cover request-setup message ordering with one canonical fork-context test","When changing content-block shapes, update message_text helpers before tests run"],"tags":["rust","test-assertion","message-transcript","fork-context"],"backgroundTag":"empty-result-set","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"}