Function: buildChatCompletionsHistory()
ts
function buildChatCompletionsHistory(input: {
bucketOrder: ChatCompletionsBucketOrder;
filterThoughts: (
thoughts: Iterable<Thought>,
mode: "all-self" | "latest-self" | "all",
selfIdentity: string,
replayCompatibility: readonly string[],
) => Thought[];
memories: Iterable<Memory>;
messages: Iterable<Message>;
renderChatCompletionsSystemPrompt: (input: {
bucketOrder: ChatCompletionsBucketOrder;
memories: Iterable<Memory>;
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => string;
renderMemories: (
items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>,
) => string;
renderRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => string;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (
items: Iterable<Tokenizable>,
attrs?: StandingInstructionAttrs,
) => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
retrievables: Iterable<Retrievable>;
standingInstructions: Iterable<Tokenizable>;
systemPrompt: Tokenizable;
}) => string;
renderChatCompletionsToolCallResult: (input: {
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 | ChatCompletionsContentBlock[]>;
renderedToolCallResults: Map<string, string | ChatCompletionsContentBlock[]>;
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => string;
renderMemories: (
items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>,
) => string;
renderRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => string;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (
items: Iterable<Tokenizable>,
attrs?: StandingInstructionAttrs,
) => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => string;
renderThought: (
content: string,
attrs: ThoughtAttrs,
payload?: unknown,
) => string;
renderTimelineMessage: (input: {
message: Message;
selfIdentity: string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<ChatCompletionsMessage>;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
replayCompatibility: readonly string[];
retrievables: Iterable<Retrievable>;
selfIdentity: string;
standingInstructions: Iterable<Tokenizable>;
systemPrompt: Tokenizable;
thoughts: Iterable<Thought>;
thoughtSurfacing: "all-self" | "latest-self" | "all";
toolCalls: Iterable<ToolCall>;
tools: ToolRegistry;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}): Promise<{
messages: ChatCompletionsMessage[];
reasoningPayloads: {
id: string;
payload: unknown;
replayCompatibility: string;
}[];
}>;Parameters
| Parameter | Type |
|---|---|
input | { bucketOrder: ChatCompletionsBucketOrder; filterThoughts: (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[]; memories: Iterable<Memory>; messages: Iterable<Message>; renderChatCompletionsSystemPrompt: (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => string; renderChatCompletionsToolCallResult: (input: { 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 | ChatCompletionsContentBlock[]>; renderedToolCallResults: Map<string, | string | ChatCompletionsContentBlock[]>; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThought: (content: string, attrs: ThoughtAttrs, payload?: unknown) => string; renderTimelineMessage: (input: { message: Message; selfIdentity: string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<ChatCompletionsMessage>; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; replayCompatibility: readonly string[]; retrievables: Iterable<Retrievable>; selfIdentity: string; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; thoughts: Iterable<Thought>; thoughtSurfacing: "all-self" | "latest-self" | "all"; toolCalls: Iterable<ToolCall>; tools: ToolRegistry; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; } |
input.bucketOrder | ChatCompletionsBucketOrder |
input.filterThoughts | (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[] |
input.memories | Iterable<Memory> |
input.messages | Iterable<Message> |
input.renderChatCompletionsSystemPrompt | (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => string |
input.renderChatCompletionsToolCallResult | (input: { 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 | ChatCompletionsContentBlock[]> |
input.renderedToolCallResults | Map<string, | string | ChatCompletionsContentBlock[]> |
input.renderFirstPartyRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string |
input.renderMemories | (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string |
input.renderRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string |
input.renderRetrievableSafetyDirective | () => string |
input.renderStandingInstructions | (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string |
input.renderThirdPartyPrivateRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string |
input.renderThirdPartyPublicRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => string |
input.renderThought | (content: string, attrs: ThoughtAttrs, payload?: unknown) => string |
input.renderTimelineMessage | (input: { message: Message; selfIdentity: string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<ChatCompletionsMessage> |
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.systemPrompt | Tokenizable |
input.thoughts | Iterable<Thought> |
input.thoughtSurfacing | "all-self" | "latest-self" | "all" |
input.toolCalls | Iterable<ToolCall> |
input.tools | ToolRegistry |
input.unsupportedMediaPolicy | UnsupportedMediaPolicy |
input.warn? | (msg: string) => void |
Returns
Promise<{ messages: ChatCompletionsMessage[]; reasoningPayloads: { id: string; payload: unknown; replayCompatibility: string; }[]; }>