Skip to content
1 min read · 221 words

Function: renderArtifactHandleBody()

ts
function renderArtifactHandleBody(input: {
  artifact: unknown;
  byteLength: number;
  callId: string;
  encoding?: string;
  estimatedTokens?: number;
  lineCount: number;
}): string;

Defined in: src/batteries/llm/chat_common/helpers.ts:394

Render the "handle" body for a spooled-artifact tool result that the producer marked inline: false: a directions-bearing text block telling the model the result was NOT inlined (to preserve context budget) and exactly which forged artifact_* tools to call — with this callId — to read it incrementally.

Parameters

ParameterType
input{ artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }
input.artifactunknown
input.byteLengthnumber
input.callIdstring
input.encoding?string
input.estimatedTokens?number
input.lineCountnumber

Returns

string

Remarks

This is THE machinery that makes the spool/thrift pattern usable by the model: a large tool result (a tool catalog, a search-hit set, a scraped doc) stays out of the prompt, and the model pulls only the slices it needs via artifact_json_get/artifact_grep/etc. Without it the adapter would either dump the whole body (defeating the purpose) or hand the model an opaque artifact it cannot read. Shared verbatim across the OpenAI, Ollama, transformers.js, and LiteRT-LM batteries so the model sees the SAME contract regardless of backend. The toolMethods list is read off the artifact's constructor (each SpooledArtifact subclass advertises its own query tools).