JuliusBrussee/caveman · warning · Error
cave_harness_aborted
cave_harness_aborted
Error message
cave_harness_aborted
What it means
`adapter.run` checks `isAborted(frozenRequest.signal)` immediately before dispatching to the harness `invoke`. If the caller's AbortSignal is already aborted at that instant, the run is discarded and `cave_harness_aborted` throws — no provider call is made, nothing is billed. This is a cooperative-cancellation checkpoint, not a harness failure.
Solutions
- Create a fresh `AbortController` for each attempt and pass its signal
- Check `signal.aborted` before building the request, not only after
- Treat this code as cancellation — do not count it in error budgets or retry with the same aborted signal
Example fix
// before
const ac = sharedController; // already aborted by a previous attempt
await adapter.run({ ...req, signal: ac.signal });
// after
const ac = new AbortController();
const t = setTimeout(() => ac.abort(), timeoutMs);
try { await adapter.run({ ...req, signal: ac.signal }); } finally { clearTimeout(t); } Defensive patterns
Strategy: validation
Validate before calling
if (req.signal?.aborted) {
throw new Error('run skipped: signal already aborted before dispatch');
}
// fresh controller per attempt — never reuse one from a previous aborted run
const ac = new AbortController();
return adapter.run({ ...req, signal: ac.signal }); Try / catch
try {
return await adapter.run(req);
} catch (e) {
if (e instanceof Error && e.message === 'cave_harness_aborted') {
// intentional cancellation: propagate as a Cancelled sentinel,
// don't count toward error budgets, and don't retry the same signal
throw cancelSentinel(e);
}
throw e;
} Prevention
- Create a fresh AbortController for every attempt
- Check signal.aborted before building the request, not only in a catch block
- Don't share controllers across queued jobs or racing branches
When it happens
Trigger: Caller `abort()`s a shared controller (timeout, user cancel, losing a race) before `await adapter.run(...)` executes; a retry loop reusing one controller whose previous attempt already aborted it; a shutdown signal fired while jobs were still queued.
Common situations: `Promise.race` cancellation where the loser's abort fires before the winner starts; global shutdown controllers triggered during drain; deadline timers that expire while the request waits in a queue.
Related errors
- artifactId is required
- assemble requires model and sessionId
- cave artifact response missing artifact_id
- cave_async_jobs_unavailable
- cave checkpoint response missing source_ref or messages
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/29cd426e5807a7c1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/adapters.ts:129
version: identity.adapterVersion,
manifest,
contractSHA256,
async run(request: HarnessRequest): Promise<HarnessResult> {
const frozenRequest = snapshotRequest(request);
const prepared = prepareLockedHarnessExecution({
build: frozenRequest.build,
harness: id,
adapterVersion: identity.adapterVersion,
upstreamVersion: identity.upstreamVersion,
contextIR: frozenRequest.contextIR,
plan: frozenRequest.plan,
});
const { build, planSHA256, contextIRSHA256 } = prepared;
if (typeof frozenRequest.prompt !== "string" || frozenRequest.prompt.length === 0 ||
typeof frozenRequest.runID !== "string" || frozenRequest.runID.length === 0) {
throw new Error("cave_harness_request_invalid");
}
if (isAborted(frozenRequest.signal)) throw new Error("cave_harness_aborted");
validateTransformEvidence(frozenRequest, frozenRequest.plan);
const execution = snapshotExecution(await invoke(frozenRequest));
if (isAborted(frozenRequest.signal)) throw new Error("cave_harness_aborted");
validateExecution(execution, frozenRequest.plan);
return {
terminal: execution.terminal,
text: execution.text,
provider: execution.provider,
model: execution.model,
inputTokens: execution.inputTokens,
outputTokens: execution.outputTokens,
cacheReadTokens: execution.cacheReadTokens,
cacheWriteTokens: execution.cacheWriteTokens,
reasoningTokens: execution.reasoningTokens,
totalTokens: execution.totalTokens,
costUsd: execution.costUsd,
usageBasis: execution.usageBasis,
priceBasis: execution.priceBasis,View on GitHub (pinned to 766dce6b13)