Skip to content

Configuration reference ​

setupAgentCore(options) ​

ts
const runtime = await setupAgentCore({
  storage,          // required — your database
  queue,            // required — durable dispatch
  bus,              // required — live fan-out
  kv,               // required — hot state
  streams,          // run streams; left out, kept in memory (one process only)
  resolveModel,     // required — registry key → { instance, contextWindow, modelId }
  admin,            // optional — defaults to SQLite, or Postgres via env
  pricer,           // optional — prices every model call (§4)
  tools,            // optional — { search, fetcher } for the built-in web tools
  log,              // optional — defaults to console
  config,           // optional — everything below
});

await matters: the operational store is opened here, and a store that cannot be opened should be a startup error.

config — every setting ​

Human in the loop ​

SettingDefaultMeaning
hitlTtlMs900000 (15 min)How long a parked approval stays answerable. On expiry it resolves as a timeout denial and the run continues.
reclaimGraceMs60000Grace beyond the TTL before orphan reclamation may claim a thread.

Deadlines and overload ​

The same four settings in both runtimes (Go names in brackets, as durations):

SettingDefaultMeaning
stepTimeoutMs (StepTimeout)0 (off)Bounds one model round trip; a step past it fails and the run takes the retry policy.
segmentTimeoutMs (SegmentTimeout)0 (off)Bounds one worker segment; a segment past it settles the run FAILED with stopReason timeout.
maxQueueWaitMs (MaxQueueWait)0 (off)A job picked up later than this fails with the reason instead of running.
maxQueueDepth (MaxQueueDepth)0 (off)A new run is refused (reason queue_full) before anything is written once this many jobs are ready and waiting. Needs a queue that can count.

In Go, a config built by hand keeps the default of every field left at zero where zero could never work (a step cap, a poll, a lease). The two booleans, RecordPayloads and PromptCaching, cannot tell "false" from "left out": start from DefaultConfig() to keep them on.

Run limits ​

SettingDefaultMeaning
maxSteps25Model round trips per run. The safety cap against runaway loops.
tokenBudgetundefinedDefault per-run token budget. Unbounded apart from maxSteps.
costBudgetMicrosundefinedDefault per-run money cap, in millionths of the pricer's currency. Needs a pricer. See Cost and pricing.
runMaxAttempts3Queue redrive attempts before a run finalizes FAILED.
stopPollMs500How often a running worker re-reads the stop signal. Also the window in which it notices a newer run replaced it.
runRetryBackoffMs / runRetryBackoffMaxMs5000 / 120000A failed run waits this long before its first retry, twice as long each time after, with jitter. The thread shows QUEUED while it waits.
runRedriveDelaySeconds2First delay before re-dispatching a job that found the run lock held. It doubles on each try, up to the lease.
runLockLeaseSeconds120 (2 min)Lease on the per-thread run lock. The worker renews it every sixth of the lease while it holds it, so an expired lock means a dead worker. A job blocked by a held lock gives up only after waiting at least one lease. Parked approvals hold no lock.

Subagents ​

SettingDefaultMeaning
subagentMaxDepth2Nesting cap.
subagentMaxConcurrent3Children running at once per run, at each depth.
subagentMaxSteps10Model round trips per child.
subagentResultCapChars8000Characters of a child's result handed to the parent.

Built-in tools ​

SettingDefaultMeaning
builtinToolResultCapChars20000The most characters a built-in tool hands the model in one result: a page's text, a reader's answer. Past it the text is cut and the result says truncated: true. See Web tools.
sandboxIdleTtlMs1800000 (30 min)A thread's sandbox ends after it has sat unused this long; the next call makes a fresh one. Go: SandboxIdleTTL. See Sandboxes.
sandboxMaxLifetimeMs86400000 (24 h)A thread's sandbox ends this long after it was made, however much it is used. Go: SandboxMaxLifetime.
sandboxScope'thread''thread' keeps one sandbox per thread; 'run' gives each run its own, ended with the run. Go: SandboxScope. See Sandboxes.
sandboxKeepOnParkfalseWith sandboxScope: 'run', keep the sandbox while the run waits for an approval or an answer. Go: SandboxKeepOnPark.
sandboxDefaults{}Merged into every sandbox made: network, envs, template, image, resources, extra. Go: SandboxDefaults.
sandboxStateDir'.agentenkit'Where the sandbox tools keep their own files. An absolute path keeps them out of the work folder. Go: SandboxStateDir.

Context and caching ​

SettingDefaultMeaning
contextCeilingTokens265000Universal ceiling.
contextOutputReserveTokens16000Held back for the completion.
compactionTrigger0.8Compact past this share of budget.
contextTailShare0.25Share of budget kept verbatim.
compactionModel'gpt-4o-mini'Registry key of the cheap model that writes the summary. Resolved through your own resolveModel, so a registry without that key must name its own.
promptCachingtrueStamp cache breakpoints on the stable prefix.
nativeWindows—Per-model windows below the ceiling. A contextWindow from resolveModel wins.

Run streams ​

Each run segment writes a short-lived run stream. Go names in brackets, as durations.

SettingDefaultMeaning
streamGraceMs (StreamGrace)600000 (10 min)How long a stream is kept after its segment ends. A tab that reconnects within it picks up inside the stream; one that comes later gets a snapshot, which has the final text in the messages.
streamTtlMs (StreamTTL)86400000 (24 h)How long a stream lives if nothing ever closes it. The last guard when the worker and the sweep both failed.
streamFlushMs (StreamFlush)50How long stream events wait to be appended together. A step end, a tool result, a park and a close go out at once. 0 sends every event as it comes.
streamFlushEvents (StreamFlushEvents)32Append at once when this many stream events are waiting.

Keep the grace short on Redis, where streams live in memory. On Postgres or SQLite it can be higher, since rows on disk cost little.

Operational history ​

SettingDefaultMeaning
recordPayloadstrueRecord prompts, step text and tool arguments/results. Turn off when payloads carry sensitive data.
payloadCapChars2000Characters kept per recorded value.

Provider options ​

SettingDefaultMeaning
providerOptions—Provider-specific settings applied to every run, keyed by provider namespace. An agent spec overrides it, and a run input overrides both. See Provider options.

Billing ​

SettingDefaultMeaning
billingPreCheck—({ threadId, runId?, state, stage, budget?, publishEvent }) => { ok, error? }. Runs at stage: 'dispatch', before anything is written (a refusal means the run never exists), and again at 'pickup', when a worker takes the job (a refusal fails the run; lowering budget.costBudgetMicros or budget.maxSteps caps this segment). The check can publish on the thread, and the platform publishes RUN_REFUSED.

Pricing is not a config setting — pricer sits on setupAgentCore beside the ports, because it decides what goes into the store rather than how the loop behaves. See Cost and pricing.

Environment variables ​

VariableRead byMeaning
AGENTIC_KIT_ADMIN_DATABASE_URLcorePostgres for the operational store. Unset means SQLite.
AGENTIC_KIT_ADMIN_DBcorePath to the SQLite operational store.
TEST_ADMIN_PGtest suitePostgres URL for the admin store tests.
SKIP_PG_TESTStest suiteSet to 1 to opt out of them deliberately.

Everything else — provider keys, your database URL, queue credentials — is read by your code, not the library's.

useAgentThread(options) ​

See React for the full table. In brief: routes, baseUrl, fetch, headers, openStream, defaultModel, persistence, labels, format, onEvent, onCustom, threadsRefreshMs, loadThreadsOnMount, initialThreadId.