@sema-agent/core
Version:
Stateless, task-oriented AI agent core
32 lines (31 loc) • 1.78 kB
TypeScript
import type { Brain } from "../core/types.js";
import { type StreamEngineConfig } from "./stream-engine.js";
export interface OpenResponsesBrainConfig extends StreamEngineConfig {
/** Base URL of the Open Responses endpoint, WITHOUT the trailing `/responses`. Overridden by `model.baseUrl`. */
baseUrl?: string;
/** API key. Overridden by per-call `options.apiKey`. */
apiKey?: string;
/** Extra headers merged into every request (auth + content-type are hard-locked after the merge). */
headers?: Record<string, string>;
/** Inject a custom fetch (tests / proxies); the default transport and the `fetchImpl` seat are
* `resolveFetch` (transport.ts). */
fetchImpl?: typeof fetch;
/**
* Replay prior assistant reasoning items back to the endpoint on the turns that carry tool calls
* (see the file header — an endpoint in thinking mode REQUIRES it there and ignores it elsewhere).
* **On by default.** Set `false` only for an endpoint that rejects the `reasoning` input item;
* with it off, a thinking-mode endpoint refuses every replayed tool-call turn.
*/
replayReasoning?: boolean;
/**
* Detect **degenerate repetition** (the model looping on the same char/phrase forever) mid-stream
* and cut it off — the turn ends `error` (`errorKind:"degenerate"`) so the loop stops paying.
* Default true. Same detector, same cadence, same salvage rules as the other two lanes.
*/
detectRepetition?: boolean;
}
/**
* Create a Brain that talks to an Open Responses endpoint. See the file header for the stateless
* invariant, the capability-audit posture, and the reasoning-replay rule.
*/
export declare function createOpenResponsesBrain(config?: OpenResponsesBrainConfig): Brain;