Skip to content
providerkit
GitHub

BackgroundOptions

Defined in: agents/src/runs.ts:82

  • BackgroundBase
Type Parameter
T
agent: Agent<T>;

Defined in: agents/src/runs.ts:83


optional createContinuation?: (input) => Promise<BackgroundContinuationResult>;

Defined in: agents/src/runs.ts:105

Optional durable, owner-scoped create-or-reconcile capability. Required only to cancel a suspended logical run. Also used for answers when supplied. Never substitute a local cache or an idempotency flag for atomic host storage. See BackgroundContinuationInput.

Parameter Type
input BackgroundContinuationInput

Promise<BackgroundContinuationResult>

BackgroundBase.createContinuation

enqueue: (id) => Promise<void>;

Defined in: agents/src/runs.ts:112

Await durable queue acceptance. A worker calls runs.drive(id, background.handlers). The host must also run runs.sweep on boot and periodically, and drain on shutdown.

Parameter Type
id string

Promise<void>

BackgroundBase.enqueue

optional events?: EventDurability;

Defined in: agents/src/runs.ts:109

Coalesced progress uses emit by default. Awaited mode needs Run.append (server 0.21+).

BackgroundBase.events

optional historyLimit?: number;

Defined in: agents/src/runs.ts:125

How many of the session’s newest messages start loads.

BackgroundBase.historyLimit

kind: string;

Defined in: agents/src/runs.ts:99

Dedicated handler key for this agent version.

BackgroundBase.kind

optional memory?: (owner) =>
| MemoryBinding
| Promise<MemoryBinding>;

Defined in: agents/src/runs.ts:123

Authenticate scopes in start and again in the worker. A changed erasure revision refuses resume; this factory never recalls notes or ingests a completed run automatically.

Parameter Type
owner string

| MemoryBinding | Promise<MemoryBinding>

BackgroundBase.memory

optional onSegment?: SegmentHook;

Defined in: agents/src/runs.ts:116

Awaited before execution and after the SDK journal settles. May repeat after worker loss; the host must deduplicate/reconcile external effects. This is not host-row commit proof.

BackgroundBase.onSegment

policy: (context) =>
| BackgroundPolicy
| Promise<BackgroundPolicy>;

Defined in: agents/src/runs.ts:113

Parameter Type
context BackgroundContext

| BackgroundPolicy | Promise<BackgroundPolicy>

BackgroundBase.policy

optional prepareHistory?: (history) =>
| AgentMessage[]
| Promise<AgentMessage[]>;

Defined in: agents/src/runs.ts:127

Runs once in start, before the run is saved. See RunOptions.prepareHistory.

Parameter Type
history AgentMessage[]

| AgentMessage[] | Promise<AgentMessage[]>

BackgroundBase.prepareHistory

runs: BackgroundRuns;

Defined in: agents/src/runs.ts:101

Injected create must resolve after its transaction commits. Only then is enqueue called.

BackgroundBase.runs

optional session?: (owner, id) =>
| Session
| Promise<Session>;

Defined in: agents/src/runs.ts:120

Trusted. Return the session id names, after checking that owner may use it: an id from a request is not authorization. start reads its history inside the authenticated request; the worker gets it again, with the stored owner, to append the turn.

Parameter Type
owner string
id string

| Session | Promise<Session>

BackgroundBase.session