UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

56 lines (55 loc) • 2.74 kB
/** * toolChoice/compose — the tools slot's armed tail, behind the same `import()`. * * Pattern: one function the slot awaits under `.toolChoice()` — ask, decide, * file the row, hand back what to commit. * Role: core/ layer. Called ONLY by `slots/buildToolsSlot.ts · * composeStage` after `mergeWire`, through `import()` (the * optional-family law of docs-next's site budget: everything this * family adds to a model call lives off the default graph, and the * slot keeps six lines). What it returns is committed by the slot's * own `commitWire`, so the decoration, the receipt and the served * view see the narrowed list at the one site they always read. */ import type { LLMToolSchema } from '../../../provider-contract/types.js'; import type { InjectionRecord } from '../../../recorders/core/types.js'; import type { Classifier } from '../../../classify/types.js'; import { type ToolChoiceScope } from './record.js'; import type { ToolChoiceEntry } from './types.js'; export interface ComposeToolChoiceInput { readonly scope: ToolChoiceScope & { $getEnv(): { signal?: AbortSignal; }; }; readonly classifier: Classifier; /** Serve the top-N plus the doors; absent = advisory only. */ readonly top?: number; readonly alwaysServe?: readonly string[]; readonly iteration: number; /** The merged wire, in order, and the slot record with the tool NAME behind each entry. */ readonly merged: readonly LLMToolSchema[]; readonly injections: readonly InjectionRecord[]; readonly injectionNames: readonly string[]; readonly userMessage: string; readonly currentSkillId?: string; /** The parent's rows — a frozen mount arg the slot never writes. */ readonly prior: readonly ToolChoiceEntry[]; readonly wrapUpAsked: boolean; /** The run's tools are off after the evidence revision: nothing is served. */ readonly toolsOff?: boolean; } /** What the slot commits: the served list, its record, and the narrowed names when narrowed. */ export interface ComposedToolChoice { readonly served: readonly LLMToolSchema[]; readonly servedInjections: readonly InjectionRecord[]; readonly narrowedTo: ReadonlySet<string> | undefined; } /** * Ask the classifier about the merged wire minus the doors, decide what is * served, file the `pick` / `pick-error` row (the row records the offer the * classifier read and the list really served), and return the list to * commit. A call with nothing to choose among makes no classifier call and * files no row. */ export declare function composeToolChoice(input: ComposeToolChoiceInput): Promise<ComposedToolChoice>;