Low-level orchestration framework for building stateful, multi-actor applications with LLMs
API reference for channels, reducers, and state management.
Store last value, error on concurrent writes.
class LastValue<Value> extends BaseChannel<Value, Value, Value> {
constructor(initialValueFactory?: () => Value);
update(values: Value[]): boolean;
get(): Value;
}Apply reducer function for custom aggregation.
class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> {
constructor(
operator: BinaryOperator<ValueType, UpdateType>,
initialValueFactory?: () => ValueType
);
}
type BinaryOperator<ValueType, UpdateType> = (
a: ValueType,
b: UpdateType
) => ValueType;Accumulate messages as array.
class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[]> {
constructor(fields?: {
unique?: boolean;
accumulate?: boolean;
});
}function messagesStateReducer(
left: Messages,
right: Messages
): BaseMessage[];
const addMessages: typeof messagesStateReducer;function pushMessage(
message: BaseMessage | BaseMessageLike,
options?: RunnableConfig & { stateKey?: string | null }
): BaseMessage;See: Core Concepts for channel usage. See: State & Channels Guide for in-depth patterns.