@agentskit/runtime — for agents
Standalone agent runtime (ReAct loop) + speculate + topologies + durable execution + background agents.
#Purpose
Run an agent without a UI. Supports reflection, planning, multi-agent orchestration, durable step logs, cron + webhooks, speculative execution.
#Install
npm install @agentskit/runtime#Primary exports
createRuntime({ adapter, tools, memory, skills, observers, ... })— one-line agent;runtime.run(task)returns{ content, steps, ... }.createSharedContext— typed shared context across tools.speculate({ candidates, pick, timeoutMs })— race adapters, abort losers. See Speculative execution.supervisor,swarm,hierarchical,blackboard— multi-agent topologies. See Topologies.createCompareHandler,createVoteHandler,createDebateHandler,createAuctionHandler— cooperative fan-out-then-select topologies. Each is generic over the run context, takes a plain config + an injectedTopologyRunAgent, and returns aTopologyOutcome(ok/failed/paused). Compare selects byall/first/eval/judge/manual; vote talliesmajority/weighted/unanimous/quorumballots with a tie-break; debate runs a proponent/opponent/judge loop; auction picks the best bid bylowest-cost/highest-confidence/fastest/customunder a reserve price. Shared helpers:settleWithConcurrency,resolveConcurrency,DEFAULT_TOPOLOGY_CONCURRENCY,InMemoryScratchpadStore.createDurableRunner+createInMemoryStepLog/createFileStepLog— Temporal-style step-log durability. See Durable execution.createCronScheduler(5-field cron +every:<ms>) +createWebhookHandler+parseSchedule+cronMatches— background agents. See Background agents.compileFlow({ definition, registry })+validateFlow+flowToMermaid— compile a YAML / objectFlowDefinitioninto a durable DAG runner. See Visual flows.createChatTrigger({ adapter, agent, ... })— unified inbound trigger for chat-surface bots (Slack / Teams / Discord / WhatsApp). Wraps aChatSurfaceAdapterthat normalizes provider events into aChatSurfaceEventdiscriminated union (message/mention/reply/reaction/file_upload/installation). Returns a framework-agnosticWebhookHandler.createQuotaTracker+withQuotas— per-tool quota / blast-radius limits (count / cost / duration windows).createValidatorGuard+ built-in validatorsdenyPattern,lengthRange,isJson— agent-insurance primitive that rejects tool args / outputs against allow/deny rules before they propagate.piiDenyValidator(opts?)— aValidatorthat fails when the output still contains PII (bridges@agentskit/core/security's redactor into the guard chain); a deterministic last-line gate for redaction/export agents instead of trusting the prompt.invokeStructured({ adapter, tool, task, parse, skill? })— first-class structured output: run a skill that must call onesubmit_*tool, read it back fromresult.toolCalls, return the validated value. Replaces the hand-rolled "offer one tool, find the call, parse args" boilerplate every pipeline agent writes.
#Minimal example
import { createRuntime } from '@agentskit/runtime'
import { anthropic } from '@agentskit/adapters'
const runtime = createRuntime({
adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-sonnet-4-6' }),
})
const result = await runtime.run('Summarize the quarterly report.')
console.log(result.content)#Common patterns
- Survive crashes: wrap side effects in
runner.step(id, fn)(durable). - A/B across models:
speculateorreplayAgainst. - Compose agents: supervisor / swarm / hierarchical / blackboard.
- React to events:
createWebhookHandler+createCronScheduler.
#Related packages
#Source
- npm: https://www.npmjs.com/package/@agentskit/runtime
- repo: https://github.com/AgentsKit-io/agentskit/tree/main/packages/runtime
Explore nearby
- PeerFor agents — overview
Dense, LLM-friendly reference for every AgentsKit package. Designed to paste into an agent's context window.
- Peer@agentskit/core — for agents
Zero-dependency foundation. Contracts, chat controller, primitives, and a dozen feature subpaths.
- Peer@agentskit/adapters — for agents
Provider adapters (OpenAI-compatible + native) + router + ensemble + fallback + generic factory.