agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
38 lines • 1.88 kB
JavaScript
/**
* wireManifest — what ACTUALLY crossed the wire, read back from the
* serialized request body itself.
*
* Pattern: one tiny extractor, shared by every adapter that states a
* manifest (the anthropicCacheWire precedent).
* Role: the wire seam's evidence. The recorded defect this exists for:
* the internal frame said a subsystem's tools were removed, and
* the adapter still serialized four schemas. A check that reads
* only the pre-serialization IR CANNOT see that bug — the IR was
* clean. So the manifest is read from the FINAL request body,
* after every transform (tool mapping, cache markers, tool_choice
* guards), at the last moment the adapter still holds it.
*
* HONEST ABSENCE: a provider that does not state a manifest simply leaves
* `LLMResponse.wireManifest` undefined, and the wire check treats that as
* incomparable — never as "nothing crossed". An EMPTY manifest is the
* opposite: a stated fact that zero tools rode the request.
*/
/**
* Read the manifest off the final request body's tools array. `undefined`
* tools (the field never written — Anthropic rejects an empty array, so
* adapters omit it) is a stated zero: no tools crossed.
*
* `outputConfig` is the body's `output_config` (Anthropic), passed by the
* adapters that can send one: its `format.type` is read back into
* `outputFormat`. A body without it gives the manifest it always gave.
*/
export function toolManifestOf(tools, outputConfig) {
const format = outputConfig?.format?.type === 'json_schema' ? { outputFormat: 'json_schema' } : {};
if (tools === undefined)
return { toolNames: [], ...format };
return {
toolNames: tools.map((t) => t.name).filter((name) => typeof name === 'string'),
...format,
};
}
//# sourceMappingURL=wireManifest.js.map