JuliusBrussee/caveman · error
cave_tool_result_inline_limit
cave_tool_result_inline_limit
Error message
cave_tool_result_inline_limit
What it means
When a tool definition declares result policy "inline", the serialized result must fit within maxInlineBytes — either 32,768 bytes by default or artifact.maxInlineTokens*4 when an artifact is configured. Exceeding it throws this error rather than silently truncating or offloading.
Solutions
- Change the tool definition's result policy from "inline" to "page" so large results are offloaded automatically.
- Increase artifact.maxInlineTokens in the tool's artifact config if large outputs are expected.
- Truncate/summarize the tool output before returning.
- Move the bulk payload to an artifact and return a reference.
Example fix
// before
{ name: "dumpLogs", result: "inline" }
// after
{ name: "dumpLogs", result: "page", artifact: { maxInlineTokens: 8192 } } Defensive patterns
Strategy: validation
Validate before calling
const maxInlineBytes = definition.artifact ? definition.artifact.maxInlineTokens * 4 : 32768;
if (new TextEncoder().encode(text).byteLength > maxInlineBytes) {
text = summarizeOrOffload(text);
} Type guard
function fitsInline(text: string, maxInlineBytes: number): boolean {
return new TextEncoder().encode(text).byteLength <= maxInlineBytes;
} Try / catch
try {
return await callTool(args);
} catch (e) {
if (e?.message === 'cave_tool_result_inline_limit') {
return await callToolWithPaging(args);
}
throw e;
} Prevention
- Declare result policy "page" for tools that can return big outputs.
- Set artifact.maxInlineTokens to a realistic ceiling for the tool's normal output.
- Keep the default 32 KiB inline budget in mind when designing tool outputs.
When it happens
Trigger: A tool with definition.result === "inline" returns content whose encoded byteLength exceeds maxInlineBytes (32,768 default) at runtime.ts:3754.
Common situations: Registering a tool as inline but letting it return large outputs (long logs, big JSON); misconfigured maxInlineTokens on the artifact; version changes where outputs grew past the threshold.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- cave_tool_result_limit
- cave_subagent_invocation_limit
- cave_tool_result_requires_recovery
- rewriter: response exceeds
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/fb1349fd8a03d087.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/runtime.ts:3754
? await sandboxExecute(params, combined)
: await raceToolTimeout(
Promise.resolve(definition.execute(params, combined)),
definition.timeoutMs,
);
const text = typeof value === "string" ? value : JSON.stringify(value);
const raw = new TextEncoder().encode(text ?? "null");
const maxInlineBytes = definition.artifact === undefined
? 32_768
: definition.artifact.maxInlineTokens * 4;
if (deferLockedToolResult) {
if (raw.byteLength > 16 * 1024 * 1024) throw new Error("cave_tool_result_limit");
return {
content: [{ type: "text", text: text ?? "null" }],
details: { effect: definition.effect, resultPolicy: definition.result, lockedRoutePending: true },
};
}
if (definition.result === "inline") {
if (raw.byteLength > maxInlineBytes) throw new Error("cave_tool_result_inline_limit");
return {
content: [{ type: "text", text: text ?? "null" }],
details: { effect: definition.effect, resultPolicy: definition.result },
};
}
const mustOffload = definition.result === "page" ||
definition.result === "compress" ||
definition.result === "exact_ccr" ||
raw.byteLength > maxInlineBytes;
if (!mustOffload) {
return {
content: [{ type: "text", text: text ?? "null" }],
details: { effect: definition.effect, resultPolicy: definition.result },
};
}
const transformed = await engineCompress(raw, engineBin);
if (!transformed.handle || !recoveryHandles) {
throw new Error("cave_tool_result_requires_recovery");View on GitHub (pinned to 3ee70a1026)