@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
44 lines (43 loc) • 3.09 kB
TypeScript
import { RunItem } from '../items';
import { UserError } from '../errors';
import { AgentInputItem, AgentOutputItem } from '../types';
export type AgentInputItemPool = Map<string, AgentInputItem[]>;
export declare class CompactionItemValidationError extends UserError {
}
export declare function toAgentInputList(originalInput: string | AgentInputItem[]): AgentInputItem[];
export declare function assertValidCompactionItems(items: readonly AgentInputItem[]): void;
export declare function getAgentInputItemKey(item: AgentInputItem): string;
export declare function buildAgentInputPool(items: AgentInputItem[]): AgentInputItemPool;
export declare function takeAgentInputFromPool(pool: AgentInputItemPool, key: string): AgentInputItem | undefined;
export declare function removeAgentInputFromPool(pool: AgentInputItemPool, item: AgentInputItem): boolean;
/**
* Deduplicates provider-identified items while preserving causal ordering.
*
* The latest payload wins. Calls, compaction, reasoning, and approval requests stay at their
* earliest occurrence so they cannot move behind a required follower; other identified items
* stay at their latest occurrence so stale outputs are not moved earlier. Items without stable
* provider identity, including ordinary messages, remain untouched.
*/
export declare function deduplicateAgentInputItemsPreferringLatest(items: AgentInputItem[]): AgentInputItem[];
export declare function agentInputSerializationReplacer(_key: string, value: unknown): unknown;
export type ReasoningItemIdPolicy = 'preserve' | 'omit';
export declare function invalidateOutputItemNormalization(items: RunItem[]): void;
export declare function stripReasoningItemIdForPolicy(item: AgentInputItem, reasoningItemIdPolicy?: ReasoningItemIdPolicy): AgentInputItem;
export declare function extractOutputItemsFromRunItems(items: RunItem[], reasoningItemIdPolicy?: ReasoningItemIdPolicy): AgentInputItem[];
export declare function dropOrphanToolCalls(items: AgentInputItem[], options?: {
pruningIndexes?: Set<number>;
}): AgentInputItem[];
export declare function prepareModelInputItems(originalInput: string | AgentInputItem[], generatedItems: RunItem[], reasoningItemIdPolicy?: ReasoningItemIdPolicy): AgentInputItem[];
/**
* Extracts generated output without including input admitted while resuming a run.
*/
export declare function getRunOutput(generatedItems: RunItem[], reasoningItemIdPolicy?: ReasoningItemIdPolicy): AgentOutputItem[];
/**
* Constructs the model input array for the current turn by combining the original turn input with
* any new run items (excluding tool approval placeholders). This helps ensure that repeated calls
* to the Responses API only send newly generated content.
*
* See: https://platform.openai.com/docs/guides/conversation-state?api-mode=responses.
*/
export declare function getTurnInput(originalInput: string | AgentInputItem[], generatedItems: RunItem[], reasoningItemIdPolicy?: ReasoningItemIdPolicy): AgentInputItem[];
export declare function trimToLatestCompaction<T extends AgentInputItem | RunItem>(items: T[]): T[];