JuliusBrussee/caveman · error

caveman-code: no tool output recorded yet to prove recovery…

Error message

caveman-code: no tool output recorded yet to prove recovery on

What it means

proveRecovery demonstrates that engine compression is reversible by round-tripping the session's largest recorded tool output through compress/retrieve. If the session has not recorded any tool output samples yet, there is nothing to prove recovery on, so it throws.

Solutions

  1. Run at least one tool call in the session before calling proveRecovery
  2. Check session.agent.samples.length > 0 before invoking the proof
  3. Guard the proof step behind completion of a real agent run

Example fix

// before
const session = createSession(opts);
const proof = await proveRecovery(session);
// after
const session = await runAgentTask(opts, task);
if (session.agent.samples.length === 0) throw new Error("no tool output to prove");
const proof = await proveRecovery(session);
Defensive patterns

Strategy: validation

Validate before calling

if (!session.agent.samples.length) {
  throw new Error("proveRecovery requires at least one recorded tool output; run a tool first");
}

Type guard

const hasSamples = (s: CodingSession): boolean => s.agent.samples.length > 0;

Try / catch

try {
  const proof = await proveRecovery(session);
} catch (err) {
  if ((err as Error).message.includes("no tool output recorded yet")) {
    console.warn("Skipping recovery proof: session has no tool output");
  } else throw err;
}

Prevention

When it happens

Trigger: Calling proveRecovery immediately after creating a CodingSession before any tool has run; a session whose tool executions all failed to record samples; calling it on a fresh/empty session object.

Common situations: Writing a smoke test that checks recovery before running any tools; integrating the proof step into a pipeline that runs before the agent loop executes tool calls.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/d008cb036f390983. Report an issue: GitHub.

Appendix: source

Thrown at packages/agent/src/code.ts:957

  ];
}

// ---------------------------------------------------------------------------
// Recovery proof
// ---------------------------------------------------------------------------

export interface CodingRecoveryProof extends SegmentRecoveryProof {
  segment: string;
}

/**
 * Take the largest raw tool output this session produced, push it through the
 * same engine compress/retrieve pair the plan and `cave_retrieve` use, and
 * compare bytes. This is the reversibility proof, not a savings claim.
 */
export async function proveRecovery(session: CodingSession): Promise<CodingRecoveryProof> {
  const sample = session.agent.samples[0];
  if (!sample) throw new Error("caveman-code: no tool output recorded yet to prove recovery on");
  const proof = await proveSegmentRecovery({
    body: new TextEncoder().encode(sample.text),
    transformID: TOOL_RESULT_TRANSFORM,
    ...(session.options.engineBin === undefined ? {} : { engineBin: session.options.engineBin }),
  });
  return { ...proof, segment: sample.label };
}

export function formatRecoveryProof(proof: CodingRecoveryProof): string {
  if (proof.outcome === "recovered") {
    return `recovery proof: ${proof.segment} round-trip OK (sha256 match ${proof.originalSHA256.slice(0, 12)})`;
  }
  if (proof.outcome === "not_smaller") {
    return `recovery proof: ${proof.segment} not compressed — the engine kept the original bytes, nothing to recover`;
  }
  return `recovery proof: ${proof.segment} FAILED (sha256 mismatch) — the plan falls back to the original body`;
}

View on GitHub (pinned to 3ee70a1026)