Hmbown/CodeWhale · warning
worker record remains inspectable
Error message
worker record remains inspectable
What it means
A test assertion in `crates/tui/src/tools/subagent/tests.rs` that fetches a subagent worker record via `get_worker_record("agent_cancel_probe")` and expects `Some`. The expect encodes the test's premise that a previously cancelled worker's record must still be readable and inspectable after cancellation. If the manager dropped, evicted, or never persisted the record, this panics with 'worker record remains inspectable'.
Solutions
- Re-run the test and check the preceding `cancel_agent` calls succeeded (their own expects would have failed first otherwise); if they pass, record retention was broken by a recent change.
- Inspect get_worker_record and the cancel path in the SubAgentManager to confirm cancelled records are kept in the map, not removed.
- Confirm the agent id string matches exactly ('agent_cancel_probe') in registration and lookup.
- If eager cleanup of terminal workers is now intended product behavior, update the test to assert on the new contract rather than keeping the record.
Example fix
// before
let record = manager
.read()
.await
.get_worker_record("agent_cancel_probe")
.expect("worker record remains inspectable");
// after
let record = manager
.read()
.await
.get_worker_record("agent_cancel_probe")
.unwrap_or_else(|| panic!("worker record for agent_cancel_probe missing after cancel; retained keys: {:?}", manager.read().await.worker_ids())); Defensive patterns
Strategy: type-guard
Validate before calling
// Before asserting, ensure the manager still holds the id: assert!(manager.read().await.worker_ids().contains(&"agent_cancel_probe".to_string()), "record pruned after cancel");
Type guard
fn record_of<'a>(m: &'a SubAgentManager, id: &str) -> Option<&'a AgentWorkerRecord> { m.get_worker_record(id) } Prevention
- Pin record-retention-after-cancel with a dedicated regression test.
- Never prune terminal worker records without updating the tests that inspect them.
- Extract agent ids into constants shared between registration and lookup.
When it happens
Trigger: Running the cancel-idempotency test when `SubAgentManager` fails to retain the worker record after `cancel_agent` — e.g. a change that removes the record on cancel, cleans up terminal workers eagerly, or a typo in the agent id ('agent_cancel_probe').
Common situations: A refactor of SubAgentManager's record lifecycle (e.g. garbage-collecting cancelled workers, changing the storage map keying, or moving records behind a new persistence layer) breaks the invariant the test guards.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- worker record
- first coordination interrupt
- first Stop
- agent should stay registered
- first timed-out API attempt should reach the test server
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/dcede2c077cb5e39.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/tests.rs:6529
.read()
.await
.get_result("agent_cancel_probe")
.expect("agent remains listed");
assert_eq!(snapshot.status, SubAgentStatus::Cancelled);
let second = tool
.execute(
json!({"action": "cancel", "agent_id": "agent_cancel_probe"}),
&context,
)
.await
.expect("repeated cancel stays idempotent");
assert_eq!(second.metadata.as_ref().unwrap()["action"], json!("cancel"));
let record = manager
.read()
.await
.get_worker_record("agent_cancel_probe")
.expect("worker record remains inspectable");
assert_eq!(
record
.events
.iter()
.filter(|event| event.status == AgentWorkerStatus::Cancelled)
.count(),
1,
"repeated stop must not append a second terminal outcome"
);
}
#[tokio::test]
async fn model_wait_cancel_fans_in_once_and_preserves_checkpoint() {
use tokio_util::sync::CancellationToken;
let tmp = tempdir().expect("tempdir");
let mut manager = SubAgentManager::new(tmp.path().to_path_buf(), 2);
let agent_id = "agent_model_wait_cancel".to_string();View on GitHub (pinned to 73e0f67d83)