Variable: defaultBuildOpenAIResponsesInput
const defaultBuildOpenAIResponsesInput: (input: {
bucketOrder: ChatCompletionsBucketOrder;
descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema;
filterThoughts: (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[];
fingerprintOpenAIResponsesPrefix: (input: {
input: OpenAIResponsesInputItem[];
instructions?: string;
model: string;
throughItem?: number;
tools?: OpenAIResponsesTool[];
}) => Promise<string>;
memories: Iterable<Memory>;
messages: Iterable<Message>;
model: string;
reasoningReplay: ReasoningReplayMode;
renderChatCompletionsSystemPrompt: (input: {
bucketOrder: ChatCompletionsBucketOrder;
memories: Iterable<Memory>;
renderCtx?: unknown;
renderFirstPartyRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string) => Promise<string>;
renderMemories: (items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>) => string;
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderFirstPartyRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: ... | ...;
estimatedTokens?: ... | ...;
lineCount: number;
}) => string) => Promise<string>;
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: ...;
byteLength: ...;
callId: ...;
encoding?: ...;
estimatedTokens?: ...;
lineCount: ...;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderThirdPartyPublicRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: ...;
byteLength: ...;
callId: ...;
encoding?: ...;
estimatedTokens?: ...;
lineCount: ...;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string;
renderThirdPartyPrivateRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderThirdPartyPublicRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
retrievables: Iterable<Retrievable>;
standingInstructions: Iterable<Tokenizable>;
systemPrompt: Tokenizable;
}) => Promise<string>;
renderCtx?: unknown;
renderedToolCallResults: Map<string,
| string
| OpenAIResponsesInputContentBlock[]>;
renderFirstPartyRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string) => Promise<string>;
renderMemories: (items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>) => string;
renderOpenAIResponsesMediaBlocks: (input: {
media: Media;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<OpenAIResponsesInputContentBlock[]>;
renderOpenAIResponsesReasoningItem: (input: {
prefixFingerprint: string;
reasoningReplay: ReasoningReplayMode;
replayCompatibility: readonly string[];
thought: Thought;
warn?: (msg: string) => void;
}) =>
| OpenAIResponsesReasoningItem
| undefined;
renderOpenAIResponsesTimelineMessage: (input: {
message: Message;
renderOpenAIResponsesMediaBlocks: (input: {
media: Media;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<OpenAIResponsesInputContentBlock[]>;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
selfIdentity: string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<
| OpenAIResponsesInputItem
| null>;
renderOpenAIResponsesToolCallResult: (input: {
renderArtifactHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderOpenAIResponsesMediaBlocks: (input: {
media: Media;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<OpenAIResponsesInputContentBlock[]>;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
results: | Tokenizable
| SpooledArtifact
| Media
| Media[]
| SpooledArtifact[];
tool: | Tool<SpooledArtifact>
| ArtifactTool
| undefined;
toolCall: ToolCall;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<
| string
| OpenAIResponsesInputContentBlock[]>;
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderFirstPartyRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string) => Promise<string>;
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderThirdPartyPublicRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string;
renderThirdPartyPrivateRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderThirdPartyPublicRetrievables: (items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>, deps: {
renderRetrievableHandleBody?: (input: {
artifact: unknown;
byteLength: number;
callId: string;
encoding?: string;
estimatedTokens?: number;
lineCount: number;
}) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
}) => Promise<string>;
renderThought: (content: string, attrs: ThoughtAttrs, payload?: unknown) => string;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string;
replayCompatibility: readonly string[];
retrievables: Iterable<Retrievable>;
selfIdentity: string;
standingInstructions: Iterable<Tokenizable>;
strict?: boolean;
systemPrompt: Tokenizable;
systemPromptChannel: SystemPromptChannel;
thoughts: Iterable<Thought>;
thoughtSurfacing: "all-self" | "latest-self" | "all";
toolCalls: Iterable<ToolCall>;
tools: ToolRegistry;
toolsToOpenAIResponsesTools: (tools: readonly (
| Tool<SpooledArtifact>
| ArtifactTool)[], deps: {
descriptionToChatCompletionsJsonSchema: (d: unknown) => JsonSchema;
strict?: boolean;
}) => OpenAIResponsesTool[];
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<{
fingerprintableLength: number;
input: OpenAIResponsesInputItem[];
instructions?: string;
tools?: OpenAIResponsesTool[];
}> = buildOpenAIResponsesInput;Defined in: src/batteries/llm/openai_responses/helpers.ts:1061
Default history assembler; alias of buildOpenAIResponsesInput.
Implements OpenAIResponsesHelpers.buildOpenAIResponsesInput.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | { bucketOrder: ChatCompletionsBucketOrder; descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; filterThoughts: (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[]; fingerprintOpenAIResponsesPrefix: (input: { input: OpenAIResponsesInputItem[]; instructions?: string; model: string; throughItem?: number; tools?: OpenAIResponsesTool[]; }) => Promise<string>; memories: Iterable<Memory>; messages: Iterable<Message>; model: string; reasoningReplay: ReasoningReplayMode; renderChatCompletionsSystemPrompt: (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderCtx?: unknown; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: ... | ...; estimatedTokens?: ... | ...; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: ...; byteLength: ...; callId: ...; encoding?: ...; estimatedTokens?: ...; lineCount: ...; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: ...; byteLength: ...; callId: ...; encoding?: ...; estimatedTokens?: ...; lineCount: ...; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => Promise<string>; renderCtx?: unknown; renderedToolCallResults: Map<string, | string | OpenAIResponsesInputContentBlock[]>; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderOpenAIResponsesMediaBlocks: (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]>; renderOpenAIResponsesReasoningItem: (input: { prefixFingerprint: string; reasoningReplay: ReasoningReplayMode; replayCompatibility: readonly string[]; thought: Thought; warn?: (msg: string) => void; }) => | OpenAIResponsesReasoningItem | undefined; renderOpenAIResponsesTimelineMessage: (input: { message: Message; renderOpenAIResponsesMediaBlocks: (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]>; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; selfIdentity: string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise< | OpenAIResponsesInputItem | null>; renderOpenAIResponsesToolCallResult: (input: { renderArtifactHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderOpenAIResponsesMediaBlocks: (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]>; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; results: | Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[]; tool: | Tool<SpooledArtifact> | ArtifactTool | undefined; toolCall: ToolCall; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise< | string | OpenAIResponsesInputContentBlock[]>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThought: (content: string, attrs: ThoughtAttrs, payload?: unknown) => string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; replayCompatibility: readonly string[]; retrievables: Iterable<Retrievable>; selfIdentity: string; standingInstructions: Iterable<Tokenizable>; strict?: boolean; systemPrompt: Tokenizable; systemPromptChannel: SystemPromptChannel; thoughts: Iterable<Thought>; thoughtSurfacing: "all-self" | "latest-self" | "all"; toolCalls: Iterable<ToolCall>; tools: ToolRegistry; toolsToOpenAIResponsesTools: (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: unknown) => JsonSchema; strict?: boolean; }) => OpenAIResponsesTool[]; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; } | - |
input.bucketOrder | ChatCompletionsBucketOrder | - |
input.descriptionToChatCompletionsJsonSchema | (d: DescriptionLike) => JsonSchema | - |
input.filterThoughts | (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[] | - |
input.fingerprintOpenAIResponsesPrefix | (input: { input: OpenAIResponsesInputItem[]; instructions?: string; model: string; throughItem?: number; tools?: OpenAIResponsesTool[]; }) => Promise<string> | - |
input.memories | Iterable<Memory> | - |
input.messages | Iterable<Message> | - |
input.model | string | - |
input.reasoningReplay | ReasoningReplayMode | - |
input.renderChatCompletionsSystemPrompt | (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderCtx?: unknown; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: ... | ...; estimatedTokens?: ... | ...; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: ...; byteLength: ...; callId: ...; encoding?: ...; estimatedTokens?: ...; lineCount: ...; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: ...; byteLength: ...; callId: ...; encoding?: ...; estimatedTokens?: ...; lineCount: ...; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => Promise<string> | - |
input.renderCtx? | unknown | Live dispatch context used to resolve a DYNAMIC systemPrompt via .render(ctx). Forwarded to renderChatCompletionsSystemPrompt, whose own renderCtx seam exists for this. Without it a context-reading system prompt renders against undefined and silently loses whatever it was reading. |
input.renderedToolCallResults | Map<string, | string | OpenAIResponsesInputContentBlock[]> | - |
input.renderFirstPartyRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string> | - |
input.renderMemories | (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string | - |
input.renderOpenAIResponsesMediaBlocks | (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]> | - |
input.renderOpenAIResponsesReasoningItem | (input: { prefixFingerprint: string; reasoningReplay: ReasoningReplayMode; replayCompatibility: readonly string[]; thought: Thought; warn?: (msg: string) => void; }) => | OpenAIResponsesReasoningItem | undefined | - |
input.renderOpenAIResponsesTimelineMessage | (input: { message: Message; renderOpenAIResponsesMediaBlocks: (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]>; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; selfIdentity: string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise< | OpenAIResponsesInputItem | null> | - |
input.renderOpenAIResponsesToolCallResult | (input: { renderArtifactHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderOpenAIResponsesMediaBlocks: (input: { media: Media; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<OpenAIResponsesInputContentBlock[]>; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; results: | Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[]; tool: | Tool<SpooledArtifact> | ArtifactTool | undefined; toolCall: ToolCall; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise< | string | OpenAIResponsesInputContentBlock[]> | - |
input.renderRetrievableHandleBody? | (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string | - |
input.renderRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderRetrievableSafetyDirective | () => string | - |
input.renderStandingInstructions | (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string | - |
input.renderThirdPartyPrivateRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderThirdPartyPublicRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderThought | (content: string, attrs: ThoughtAttrs, payload?: unknown) => string | - |
input.renderTrustedContent | (content: string, attrs: TrustedContentAttrs) => string | - |
input.renderUntrustedContent | (content: string, attrs: UntrustedContentAttrs) => string | - |
input.replayCompatibility | readonly string[] | - |
input.retrievables | Iterable<Retrievable> | - |
input.selfIdentity | string | - |
input.standingInstructions | Iterable<Tokenizable> | - |
input.strict? | boolean | - |
input.systemPrompt | Tokenizable | - |
input.systemPromptChannel | SystemPromptChannel | - |
input.thoughts | Iterable<Thought> | - |
input.thoughtSurfacing | "all-self" | "latest-self" | "all" | - |
input.toolCalls | Iterable<ToolCall> | - |
input.tools | ToolRegistry | - |
input.toolsToOpenAIResponsesTools | (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: unknown) => JsonSchema; strict?: boolean; }) => OpenAIResponsesTool[] | - |
input.unsupportedMediaPolicy | UnsupportedMediaPolicy | - |
input.warn? | (msg: string) => void | - |
Returns
Promise<{ fingerprintableLength: number; input: OpenAIResponsesInputItem[]; instructions?: string; tools?: OpenAIResponsesTool[]; }>
Remarks
Algorithm (mirrors the plan's Part 2 spec exactly):
- Leading
instructions(or leadingdeveloper/system-role item, persystemPromptChannel) — ALWAYS ADK-rendered viarenderChatCompletionsSystemPrompt; there is no consumer-facing escape hatch. - Timeline: messages/thoughts/tool-calls merged and sorted by
createdAt. A tool call renders as two SIBLING top-level items (function_callthenfunction_call_output), with composite id splitting. A thought replays as a nativereasoningitem only whenreasoningReplay !== 'off'and a valid, prefix-matched signature exists; otherwise it renders as plain text. - Reasoning-pairing enforcement pass — walks
inputleft to right, dropping anyreasoningitem not immediately followed by its paired output item, and stripping theidfrom an output item whose paired reasoning item was just dropped. - Trailing buckets (
bucketOrderlabels after'timeline') render as a trailing{type:'message', role:'system', ...}item.
Load-bearing invariants
These are consequences of the step ORDER above, not incidental details. Both were unwritten once, and both were violated in ways that silently disabled reasoning replay — so they are stated here explicitly and pinned by executable tests (see tests/unit/batteries/llm/openai_responses/reasoning_replay.cross.spec.ts, "assembly invariants").
The step-3 sweep only ever sees a PREFIX of the final
input. Step 4 appends the trailing bucket AFTER the sweep has run, so any item added there is invisible to every fingerprint the sweep computes. A reasoning-replay fingerprint must therefore cover only the sweep-visible region — that is what the returnedfingerprintableLengthmarks, and whypersistThoughtpasses it asthroughItem. Hashing the wholeinputinstead cannot match on the next turn whenever a trailing bucket exists, and drops every replayed item as stale.A reasoning item must sort STRICTLY BEFORE the output item it is paired with. The step-2 timeline pushes messages before thoughts and then applies a STABLE sort by
createdAt, so on an identical timestamp the message wins the tie and lands ahead of its own reasoning item — leaving that item unpaired, and the step-3 sweep drops it. Callers persisting a thought and its message from one response must therefore assign strictly increasing timestamps rather than calling a clock twice (twoDateTime.now()calls collide ~998 times in 1000).toolsisundefined, never[], when the registry is empty (see the return shape). Fingerprints on both the persist and validate side must use that same shape:canonicalFingerprintserialisesundefinedand[]to different bytes, so coercing on one side only makes every hash mismatch for tool-less agents.