Hmbown/CodeWhale · error
; additionally failed to persist contention receipt
Error message
{error}; additionally failed to persist contention receipt: {persist_error} What it means
After a spawn attempt fails (e.g. contention acquiring the coordination process lock), the manager tries to persist a contention receipt so the failure is durably recorded. If that persistence also fails, the original error is rethrown augmented with the persistence failure, because the durable record of the contention could not be written. The pre-persist snapshot of worker_records/coordination is restored first to avoid partial in-memory mutation.
Solutions
- Fix the underlying persistence problem reported in the {persist_error} suffix (disk full, permissions, missing directory) and retry the spawn.
- Check filesystem space and write permissions on the session/state directory.
- If the primary {error} was transient contention, retry after the holder releases the coordination lock; then verify the state file is writable.
Example fix
// before (state dir read-only) $ ls -l ~/.local/state/codewhale # dr--r--r-- // after $ chmod u+w ~/.local/state/codewhale && retry spawn
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: ensure the state file location is writable fs.accessSync(stateDir, fs.constants.W_OK); fs.accessSync(statePath, fs.constants.W_OK);
Try / catch
if (err.message.contains("failed to persist contention receipt")) {
let persist_err = err.message.rsplit(": ").next();
fix_storage_issue(persist_err); // disk space / permissions
} Prevention
- Monitor disk space and permissions on the session state directory.
- Ensure the state directory is created with write permissions at session start.
- Retry spawns only after fixing the persistence fault; the receipt must be durable.
When it happens
Trigger: A spawn fails with error E, then persist_state_synchronously() also returns Err(persist_error) while a durable_launch_snapshot exists — producing "E; additionally failed to persist contention receipt: persist_error".
Common situations: Coordination state file on a full or read-only filesystem; permission problems on the session state directory; disk I/O failure during a contention retry storm.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- failed to durably register write-capable sub-agent before…
- failed to record sub-agent verification approval
- failed to register sub-agent work
- sub-agent transcript history shrank from
- 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/9303cc94d5298384.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/mod.rs:7139
options.isolated_worktree,
claim,
)?
};
self.register_claim_with_presence(claim, options.isolated_worktree)
})
.transpose()
} else {
Ok(None)
};
let persisted_claim = match persisted_claim {
Ok(claim) => claim,
Err(error) => {
if let Err(persist_error) = self.persist_state_synchronously() {
if let Some((worker_records, coordination)) = durable_launch_snapshot.as_ref() {
self.worker_records = worker_records.clone();
self.coordination = coordination.clone();
}
return Err(anyhow!(
"{error}; additionally failed to persist contention receipt: {persist_error}"
));
}
return Err(anyhow!(error));
}
};
let mut projection_capabilities = tools.clone().unwrap_or_else(|| {
["Bash", "File", "Git", "Run", "Web"]
.into_iter()
.map(str::to_string)
.collect()
});
projection_capabilities.push(agent_type.as_str().to_string());
if let Some(role) = assignment.role.as_ref()
&& !projection_capabilities.contains(role)
{
projection_capabilities.push(role.clone());
}View on GitHub (pinned to 73e0f67d83)