UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

34 lines (33 loc) • 2.27 kB
/** * The session's prompt-cache key on the wire (`compat.sendPromptCacheKey`, `StreamOptions.promptCacheKey`). * * The key is the engine's: a Runner mints it per session and isolation scope (`legPromptCacheKey`, `core/runner/model-lane-seat.ts`) and writes it on * its main-loop calls; no host, client or model seat hands one in. An endpoint takes it only where its model entry says so: * `api: "openai-completions"` with `compat.sendPromptCacheKey: true`, sent as the body's top-level `prompt_cache_key`. Three * readers ask the one judge below and say the same sentence — the model door (`not_a_model_ref`), and each first-party brain as it * builds a request (`invalid_request`) — and the model lane hands the deployment Brain the key only on a hop whose entry declares * it ({@link hopOptionsWithCacheKey}). */ import type { Model, SimpleStreamOptions } from "../internal/llm.js"; /** The request-body key the OpenAI chat-completions brain writes the session's key under. */ export declare const PROMPT_CACHE_KEY_WIRE = "prompt_cache_key"; /** * Why `model`'s `compat.sendPromptCacheKey` is not a declaration the engine can read, or `undefined` when it is one (absent * included): a value that is not `true` or `false`, or `true` on an entry whose `api` is not `openai-completions` (no other wire * carries the key, so a declaration there would send nothing while it says it does). */ export declare function promptCacheKeyDefect(model: Pick<Model, "api"> & { readonly compat?: unknown; }): string | undefined; /** Does a request built for `model` carry the session's key? Only a judged `true` on the one carrying wire. */ export declare function sendsPromptCacheKey(model: Pick<Model, "api"> & { readonly compat?: unknown; }): boolean; /** * The options the model lane hands the deployment Brain for one hop: `options` itself when it holds no key or the hop's entry * declares one, else a copy without the member — a hop whose entry does not declare the key never sees it. Never writes `options` * (a later hop of the same walk reads it again). */ export declare function hopOptionsWithCacheKey<O extends SimpleStreamOptions>(sent: Pick<Model, "api"> & { readonly compat?: unknown; }, options: O | undefined): O | undefined;