Hmbown/CodeWhale · error · anyhow::Error
sub-agent transcript record is missing its message
Error message
sub-agent transcript record is missing its message
What it means
Each record of a sub-agent transcript JSONL artifact must contain both an `index` and a `message` field. When a record lacks the `message` key, the parser cannot deserialize a `Message` for it and throws this error instead of letting serde produce a vaguer failure.
Solutions
- Open the transcript file and repair or delete the record that lacks a `message` field.
- If the last line is truncated/partial, truncate the file at the last complete JSON line.
- Regenerate the sub-agent session so a fresh, complete transcript is written.
- If a custom tooling wrote the transcript, fix it to always emit both `index` and `message` per record.
Example fix
// before (incomplete record)
{"index":3}
// after
{"index":3,"message":{"role":"assistant","content":"..."}} Defensive patterns
Strategy: validation
Validate before calling
// pre-check every record has a message
let complete = records.iter().all(|r| r.get("message").map_or(false, |m| m.is_object()));
if !complete { /* drop or repair incomplete records first */ } Type guard
fn has_message(record: &Value) -> bool {
record.get("message").map_or(false, |m| m.is_object())
} Prevention
- Stop writers cleanly so the last JSONL line is never truncated mid-record.
- Tolerate a torn final line by truncating to the last complete newline before parsing.
- Keep writer and reader versions in sync on the record schema.
When it happens
Trigger: Calling transcript-parsing code on a JSONL line that has an `index` but no `message` field — e.g. `serde_json::from_value` path where `record.get("message")` returns `None`.
Common situations: A partially written or truncated last line in the JSONL file; manual editing dropped the message; a writer bug or schema change emitted metadata-only records; log rotation truncated lines.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- runtime API thread response missing id
- runtime API turn response missing turn.id
- sub-agent transcript artifact must have a parent directory
- sub-agent transcript message index
- agent action=claim widens an enforced write scope, and the…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/2a1a2a4b6c42b334.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/mod.rs:8592
if record.get("kind").and_then(Value::as_str) != Some("message") {
return Err(anyhow!("unknown sub-agent transcript artifact record"));
}
let index = record
.get("index")
.and_then(Value::as_u64)
.and_then(|value| usize::try_from(value).ok())
.ok_or_else(|| anyhow!("sub-agent transcript message is missing its index"))?;
if index != messages.len() {
return Err(anyhow!(
"sub-agent transcript message index {index} does not follow {}",
messages.len()
));
}
let message = serde_json::from_value::<Message>(
record
.get("message")
.cloned()
.ok_or_else(|| anyhow!("sub-agent transcript record is missing its message"))?,
)?;
messages.push(message);
}
Ok(messages)
}
fn remove_subagent_transcript_artifact(state_root: &Path, agent_id: &str) -> Result<bool> {
let state_root = normalize_subagent_workspace(state_root);
let path = checked_subagent_transcript_artifact_path(&state_root, agent_id)?;
reject_root_relative_symlinks(&state_root, &path)?;
let metadata = match fs::symlink_metadata(&path) {
Ok(metadata) => metadata,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(false),
Err(err) => return Err(err.into()),
};
if metadata.file_type().is_symlink() || !metadata.file_type().is_file() {
return Err(anyhow!(
"sub-agent transcript artifact is not a regular file: {}",View on GitHub (pinned to 73e0f67d83)