Skip to content
中文

Support · Recommended implementations & strategies ​

Shared contracts & helpers ​

Open group

SymbolKindPurpose
agentfunctionInstantiate an Engine configuration class without creating an Engine, budget or request.
AgenttypeOriginal Engine configuration; union branches retain their required App/model relationships.
AgentOptionstypeAgent id is an external pool identity, not an override of Core branch or request identity.
agentPoolconstant
AssociatedRegistrationinterfaceOwners retain their business fields; Support only reads model interface associations.
AssociationOptionsinterfaceShared independent tools and a default projection from existing contracts.
AssociationSourceinterfaceLocal provenance, never an extra model input requirement.
ClassDecorationtype
DecorationOptionsinterfaceNamespaces group external registration without changing Core options.
defineAssociatedCatalogfunctionCompile independent and owner-derived Tool declarations, validating all references eagerly.
DefinitionReaderinterfaceRead-only roots. A typed read describes the expected contract, not a static id/type lookup.
fragmentfunctionInstantiate a self-describing fragment class; the original builder owns formatting checks. Bind a host's formatter method into an original fragment configuration.
FragmenttypeA formatter and its original provenance, trust and budget configuration.
fragmentPoolconstant
IdentifiedDefinitioninterfaceRegistration identity; ids are unique within one kind and namespace.
IntentfunctionMark a WorkflowTool for demand discovery; alone this decorator registers nothing.
MethodDecorationtype
modelfunctionInstantiate and validate model options without creating a Runner or consuming calls.
ModeltypeOriginal Runner configuration; the decorator's pool id is not a model identity override.
ModelOptionstypeModel id is only a pool key; Core still owns the configured model/transport identities.
modelPoolconstant
nodefunctionInstantiate a node definition class once, injecting its id; graph validation stays in Workflow. Bind a named host method as run without renaming or manually binding the original object.
NodetypeA node implementation; its public id is supplied by
nodePoolconstant
Supportnamespace
toolfunctionInstantiate a tool definition class; schema and authorization stay with existing defineTool. Bind an existing host method as the tool's execute callback. A model-only tool method provides its synchronous resolver.
TooltypeA tool implementation with the original schema, authorization and execution contracts.
ToolAssociationtypeExplicit tool references or inline overrides of the owner's default model interface.
toolPoolconstant
workflowfunctionInstantiate and validate workflow options, leaving actual execution with the original Engine.
WorkflowtypeA complete graph definition whose workflow id is supplied by
workflowPoolconstant

Tools & capabilities ​

Open group

SymbolKindPurpose
CapabilityCatalogOptionsinterfaceCatalog construction options.
CapabilityModuleinterfaceMinimal composition contract; lifecycle and domain fields remain application-owned.
CapabilityToolReferencesinterfaceTool references declared by one owner module.
CompiledTooltypeTool definition type derived from a declaration literal, preserving input/output/id.
defineCapabilityCatalogfunctionBuild a frozen capability catalog from application module declarations. Each module must carry a non-empty description, and every contributed tool ID must be unique across modules. Reference projections run during construction and must be synchronous.
defineToolfunctionValidate one tool declaration and freeze a detached copy of it. authorize must settle with void; a rejection has to be thrown, so a returned false cannot silently pass. Handlers are bound to the declaration object, and the input schema is re-snapshotted so later mutation cannot widen the accepted input.
defineToolCatalogfunctionInfer the host context from existing executable definitions, without widening it to unknown. Explicit host typing remains available for contextually typed declaration lists.
SelectedToolstypeCatalog narrowed to the given ids: each kept tool's id literal is intersected with Id.
ToolCataloginterfaceFrozen tool catalog with model tools and per-request binding.
ToolCatalogEntrytypePublic declaration surface of one tool, without registry internals.
ToolModelViewinterfaceModel capability view of a tool catalog, retaining the host context type.
ToolOutputtypeOutput type of the tool whose id matches Id; never for any other id.
ToolRuntimeinterfaceCatalog bound to one App request.
validateToolReferencesfunctionValidate tool references against the complete registered set. Checking against every registered tool (not only the ones available in the current request) keeps the declaration honest: a module may reference a tool that this request filters out, but never one that does not exist.

Models & interaction ​

Open group

SymbolKindPurpose
chatCompletionFunctionOptionsfunctionBuild the tool-selection request fields for a function-calling stage. The adapter expects exactly one function call per response, so tool use is required and parallel calls are disabled.
chatCompletionMessagesfunctionMap Core and provider messages to chat-completions message payloads. Only declared message fields are sent. Assistant tool declarations become nested tool_calls, and tool results become tool_call_id; both are rewritten explicitly rather than forwarded as-is. Messages with images become a content-block array; images are accepted only on user messages and only as http(s) or data:image URLs.
chatCompletionPartsfunctionConvert one streamed choice.delta into Core model parts. Text is emitted only when non-empty; each tool-call fragment carries its index so Core can reassemble arguments that arrive across chunks.
CompatibleModelConfiginterfaceConfiguration of one OpenAI-compatible endpoint.
CompatibleModelPortsinterfaceAdapter ports the App may override without replacing the provider.
CompatibleModelProviderclassHTTP/SSE lifecycle shared by hosts. Apps supply config and user-visible error mapping only. A static configuration is validated and frozen in the constructor. A configuration function is called once per request instead, so credentials and models may rotate between calls.
CompatibleModelProviderOptionsinterfaceConstruction options for a compatible provider.
CompletionFailuretypeBuild the classified failure a policy throws; the provider records it like its own failures.
CompletionPolicyinterfaceDecision whether a finished stream satisfies the request.
completionPolicyCatalogconstant
CompletionRequestFactsinterfaceFacts the provider reads from the request it actually sends. functions reports the Core call options and keeps the default policy equivalent to the behavior that existed before policies were configurable. toolChoice is the effective field of the serialized body, so a host override, or a field dropped for being undefined, is visible exactly as the upstream receives it.
CompletionSessioninterfacePer-request completion state observed by one policy.
createJsonTransportfunctionCreate a typed JSON transport without a capability-selection envelope. The transport embeds the JSON Schema in the instruction and requires the response to be one complete JSON value. The returned response parser rejects native call events and invalid JSON, then validates the value through the supplied schema.
createModelStrategyfunctionCompose runner options in precedence order: budget preset, selected model, declared reasoning, exact budget, then explicit Core fields. The result is validated through the same Core binding rules but creates no runner and spends no calls.
createProviderObservationScopefunctionBind provider observations to a caller-owned destination across diagnostic child spans. attach returns a scoped diagnostic context; contexts that were not attached through this scope produce no observations. Child contexts inherit the owner and a parent/child span path.
createReplyPreviewfunctionCreate a model-output event handler that publishes preview bubbles. The handler resets on model.start, ignores other invocations, disables itself on unexpected output, and clears the preview when a call ends unsuccessfully. Rules are snapshotted at creation, and only explicitly registered prose fields are projected.
createReplyPreviewRulesfunctionGenerate frozen preview rules from capability and stage declarations. Capabilities without preview metadata are skipped even when their stage opts in. Default paths are text and bubbles[*], each kept only when the capability schema declares it.
createSessionModelTransportfunctionCreate a session transport.
createStageModelTransportfunctionBuild a transport that projects a capability source through declared stage references.
createTextTransportfunctionCreate a plain-text transport that trims the assembled response.
defaultCompletionPolicyconstant
defineModelToolsfunctionBuild a sealed capability catalog from typed declarations.
modelBudgetStrategiesconstant
ModelBudgetStrategytypePreset name, or an explicit partial set of Core runner settings.
ModelChildrenOptionsinterfaceGroup options: worker count, extra cancellation and accept/commit hooks.
ModelChildTaskinterfaceOne child call in a group: its own limits plus the work to run with the child runner.
ModelChoiceIndexinterfaceMinimal selector shape used while filtering the provider response choices.
modelInteractionCatalogconstant
ModelProviderErrorCodetypeStable failure classification reported by the compatible provider adapter.
ModelProviderFailureinterfaceFailure detail passed to the App's error factory.
ModelStageTransportRegistrationinterfaceStage IDs and capability references are App-owned; this adapter only compiles their relation.
ModelStrategyOptionstypeInput of createModelStrategy: model selection, optional reasoning and budget plus explicit Core overrides. Explicit Core fields win over every generated value.
PreparedSessionTransportinterfacePrepared session transport handed to the runner.
prepareSessionFunctionsfunctionBuild the session policy for one stage.
PreviewToolinterfaceA model tool with an explicit, presentation-only streaming preview contract.
ProviderAssistantMessageinterfaceAssistant turn; content may be empty when the turn is only a tool declaration.
ProviderErrorCaptureinterfaceCaptured upstream error body and whether it had to be truncated.
ProviderEventDescriptorinterfaceProvider event name plus its content class.
ProviderEventNametypeUnion of provider event names.
ProviderEventPayloadsinterfacePayload of each provider event. Content-bearing events are accepted explicitly.
ProviderMessagetypeMessage list a host may pass to the compatible provider directly.
ProviderObservationtypeOne observation: event name with its payload.
ProviderObserverinterfaceThe caller can correlate each observation using the original, request-local model options.
ProviderReasoningLeveltypeSupplier wire shape is explicit; levels express requested effort, not measured quality.
ProviderReasoningStrategytypeHow a reasoning level is translated into request fields. requestBody entries override generated fields, so a host can correct a provider that expects a different shape.
ProviderSystemMessageinterfaceSystem instruction turn; text only, so the union rejects images and tool fields here.
ProviderToolCalltypeOne tool call the assistant declared, in wire order; aliases the Core shape.
ProviderToolMessageinterfaceTool result answering one declared call.
ProviderUserMessageinterfaceUser turn; the only message type that may carry images, and never tool calls.
ReplyPreviewOptionsinterfaceSettings for createReplyPreview; sink receives every bubble list and is required.
ReplyPreviewRuleinterfaceOne projection rule: which stage/capability it matches and which prose fields may be shown. A rule without toolId may only match a registered plain-text stage.
ReplyPreviewStageinterfaceStage declaration: which tools it exposes and whether it previews text or arguments.
ReplyPreviewToolinterfaceCapability declaration used to derive preview rules. Omitted preview means the capability never previews, so previewing is an explicit opt-in.
ResolvedSessionCallinterfaceOne completed call with host-facing resolution; unknown tools and bad JSON stay non-fatal.
ResolvedSessionResultinterfaceComplete result of one session response after host-facing resolution.
runChildrenfunctionRun child tasks concurrently and return their values in declaration order. The first failure aborts the remaining group, but an already in-flight commit is still awaited because cancellation does not mean the write was rolled back.
sessionCompletionPolicyconstant
SessionFunctionOptionsinterfaceOptions a session transport may pass through to provider options.
SessionModelTransportRegistrationinterfaceRegistration for one session transport.

Context & journals ​

Open group

SymbolKindPurpose
ContextAssemblyOptionsinterfaceAssembly options for placement-based projections.
ContextBuilderinterfaceCompiled builder. It holds no request state and may be shared across invocations.
ContextBuilderOptionsinterfaceShared builder options.
ContextCompressionCallinterfaceOne compression request.
ContextCompressorinterfaceRegistered compressor handler.
ContextFragmentConfiginterfaceSelf-describing fragment declaration: metadata plus a formatter.
contextHandlerCallsfunction
ContextHandlerReferenceinterfaceReference to a registered compressor or selector handler.
ContextHistoryGroupingtypeHow a message history is split into groups for trimming.
contextHistoryStrategiesconstant
ContextModelCallinterfaceSame runner and same fixed invocation result as public model calls.
ContextModelRequestinterfaceOne model call made on behalf of a selector or compressor.
ContextNodeResultinterfaceOutcome of one context node: the built input, its prepared model call and the change report.
ContextPolicytypeDeclared context policy for one stage.
contextPolicyCatalogconstant
ContextProcessingNodeDefinitiontypeDefinition accepted by createContextProcessingNode. It is a normal Core WorkflowNode except that the node body is declared here: plan builds the context, update decides the committed state, and policy/handlers/timeout are validated when the node is created.
ContextProcessingOptionsinterfaceRuntime inputs for one processing run.
ContextProcessingReportinterfaceFacts recorded for one processing run.
ContextProjectiontypeOne declared projection: a single fragment or a placement expanded into fragments.
ContextRecentHistoryinterfaceRecent history that compression must keep verbatim.
ContextReductiontypeOne declared reduction step.
contextReductionCatalogconstant
ContextReductionNodeDefinitiontypeDefinition of a reduction node: one registered step is applied per node run. stepId may be fixed or derived from state, which lets a graph route over several steps.
ContextSelectiontypeSelection is independent of ownership; omitted selection preserves ordered execution.
ContextSelectionCallinterfaceEverything a selector may inspect for one decision.
ContextSelectionCandidateinterfaceCandidate step considered by selection, with its measured cost.
contextSelectionCatalogconstant
ContextSelectionNodeDefinitiontypeDefinition of a selection node: like a processing node, but update receives chosen step IDs.
ContextSelectionResultinterfaceSelection stage result: the chosen step IDs plus the unchanged stage snapshot.
ContextSelectorinterfaceModel or local selector that chooses which reductions to apply.
ContextStageResultinterfaceResult of a selection or reduction stage, before the node's update commits chosen fields.
ContextStrategyinterfaceValidated inputs ready to pass to a context processing node.
ContextStrategyOptionstypeOne history declaration that generates a step, or an explicit step list with optional history fields (fragment, field, preset, targetChars, keepGroups, grouping).
ContextStrategySettingstypeShared reduce-policy settings applied to the whole strategy. Trigger and target fields follow the Core policy contract; omitted values fall back to the plan budget or to the trigger. Supplying steps disables generation and uses the explicit list.
ContextTokenMeasurementinterfaceInjected token measurement for token-triggered policies.
createContextCompressorfunctionBuild a compressor that asks a model to rewrite one fragment. The request pairs a system instruction with a user message carrying the fragment ID, its current value and the target character count. Only the model's parsed value is returned; the caller decides whether the result fits the reduction contract.
createContextProcessingNodefunctionCreate one node that runs the complete context policy and returns the built context. Use this when the graph does not need to route between selection and reduction phases.
createContextReductionNodefunctionCreate a node that applies exactly one registered reduction step. Partial plans keep the full budget until final assembly, so intermediate nodes do not shrink the allowance reserved for the reply.
createContextSelectionNodefunctionCreate an ordinary node that selects reduction steps without executing them. The node reports the registered step IDs so the graph can route to reduction nodes itself.
createContextSelectorfunctionBuild a selector that asks a model to pick reduction steps. Without a custom parser the model must answer with a JSON object containing a stepIds array; with a custom parser the application owns that contract but must still return step IDs.
createContextStrategyfunctionBuild a reduction policy from one or more history declarations. recent keeps a window of recent groups; continuity summarizes older groups while preserving the most recent originals. Neither preset claims semantic quality, only bounded input size.
defineContextAssemblyfunctionCompile ordered context projections into a builder. A projection is either a single fragment (with its own formatter) or a placement whose contribution handler expands to any number of fragments at request time.
defineContextFragmentsfunctionCompile self-describing fragment declarations into a builder. Each definition carries its own trust, lifetime and size metadata, so no separate metadata catalog is needed. The budget may be a constant or a function of the request input.
processContextfunctionRun a complete context policy in one call: snapshot, execute and finalize.
reservedContextCallsfunction
selectContextStepsfunctionChoose steps that fit the remaining call budget. Feasibility uses exact trim previews and declared call ceilings; the reply reserve and the selector's own allowance are subtracted before candidates are considered, so neither can be spent on reductions.
transformContextTextfunctionApply a text transform to a fragment value, including strings nested inside objects. Structured values are walked through a JSON round trip, which is what the budget measurement serializes later; values that JSON cannot represent are therefore not preserved.
validateContextPolicyfunctionValidate a complete context policy and every handler it can reference. Handler IDs must be unique and each handler must declare a non-negative integer call ceiling. Reduction targets and selection modes are checked by their own catalog entries.
validateContextSelectionfunctionValidate selector declarations and the selection mode they serve.

Configuration, catalogs & policies ​

Open group

SymbolKindPurpose
defineRegistrationCatalogfunctionCompile an ordered installation plan. Predicates observe the effects of preceding installations at request time; a predicate that throws rejects the install instead of being treated as false. Callbacks are bound to their declaring definition so implementations may rely on this.
defineSchemafunctionRe-snapshot an existing adapter without changing its behavior. Used to detach a caller-owned adapter from later mutation before it is exposed or reused.
fromJsonSchemafunctionBuild an adapter from a caller-owned typed JSON Schema compiler. The schema is cloned and frozen before it reaches the compiler, so later mutation of the input cannot change validation. Compilation and validation must both be synchronous.
fromParserSchemafunctionWrap a library schema that already parses values (for example Zod or Valibot style). parse is delegated unchanged, so the library keeps ownership of coercion and error reporting; only the JSON Schema projection is produced here.
JsonSchemaOptionsinterfaceOptions for building an adapter from a JSON Schema compiler.
JsonSchemaValidatorinterfaceApp-owned JSON Schema compilers provide synchronous validation.
RegistrationDefinitioninterfaceOne install step.

Transport & streaming ​

Open group

SymbolKindPurpose
encodeSseEventfunctionEncode one event in the server-sent events wire format. Every line of data gets its own data: field, because a raw newline would start a new field.
JsonFrameLimitsinterfaceBounds applied while scanning a streamed text.
JsonTransportParttypeOne scanned span: a complete object frame or a character outside any frame.
parseJsonFramesfunctionParse complete object frames under explicit count and size limits. Only whitespace may appear outside frames; a stray closing brace is tolerated only up to maxExtraClosings, which covers transports that repeat the delimiter after the payload.
scanJsonObjectFramesfunctionExtract complete object-shaped spans from surrounding text, without parsing or selecting them.
SseOutputEventinterfaceOne outbound event before wire encoding.
SseWriterinterfaceDestination that reports backpressure instead of buffering without bound.
writeSseFramefunctionWrite one encoded frame and wait for drain when the writer reports backpressure. The signal is re-checked around the write and the drain wait, so cancellation does not leave a pending write considered successful.

Observation & diagnostics ​

Open group

SymbolKindPurpose
streamEventsfunctionBridge a push-style producer to a pull-style async iterable with a one-slot rendezvous. The producer must await every emit call before emitting again; concurrent emissions are rejected rather than buffered. The slot is released only after the consumer receives the event, so backpressure is exact.

API reference, usage examples and developer guides.