/** * Flags tools whose JSON schema is large enough to be worth knowing about. * * A tool's schema is re-sent on every request for the life of a run, so an * oversized one is a standing tax on both cost and latency rather than a * one-off. The case that prompted this: `std::syntax::highlight` took a * `theme` parameter that accepted a nested color-scheme object, which * serialized to roughly 17,000 characters against a norm of a few hundred * for the rest of the stdlib. Nothing failed, so nothing surfaced it. */ /** Tools longer than this warn unless `agency.json` says otherwise. Every * well-formed stdlib tool measured under 1,100 characters, so this leaves * roughly 2x headroom before a schema is worth a second look. */ export declare const DEFAULT_MAX_TOOL_SCHEMA_CHARS = 2000; export type OversizedTool = { name: string; chars: number; }; /** `ToolDefinition.schema` is typed `unknown`, so the shape is checked at * runtime rather than assumed. */ type ToolLike = { name?: string; schema?: unknown; }; /** * Return the serialized length of a tool's JSON schema, or null when the * tool has no schema or the schema cannot be serialized. A tool that cannot * be measured is not a tool worth failing over, so callers treat null as * "nothing to report". */ export declare function toolSchemaChars(tool: ToolLike): number | null; /** * Return the tools whose schema exceeds `threshold`, largest first. * * A threshold of 0 (or less) disables the check, matching how * `maxToolResultChars` treats 0. */ export declare function findOversizedTools(tools: ToolLike[], threshold: number): OversizedTool[]; /** The warning text a flagged tool produces. */ export declare function oversizedToolMessage(tool: OversizedTool, threshold: number): string; /** The slice of RuntimeContext this module needs; typed structurally so the * runtime's generic context type does not have to be imported here. */ type SchemaWarnHost = { maxToolSchemaChars?: number; warnedToolSchemas?: Record; }; /** The one logging method this module calls, on the logger of the run the * tools were offered in. */ type SchemaWarnLog = { warn: (payload: { warnType: "toolSchemaSize"; message: string; functionName: string; schemaChars: number; threshold: number; }) => Promise; }; /** Report any tool whose JSON schema is over the configured threshold. The * schema rides along on every request in the run, so this is a standing * cost the caller usually cannot see: nothing fails, the bill is just * higher and the context fuller. Warned once per tool name per run — * repeating it on all 26 calls of a run would bury the signal in the * statelog it is meant to surface in. * * Never throws. A tool the runtime cannot measure is skipped, and a * statelog post that fails is swallowed: a diagnostic must not be able to * take down the call it is describing. */ export declare function warnOnOversizedToolSchemas(ctx: SchemaWarnHost, log: SchemaWarnLog, tools: { name: string; schema?: unknown; }[]): void; export {};