New:Socket for Asana Is Now Available.Learn more
Get Started

@agentskit/core

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agentskit/core

Portable AgentsKit runtime for chat orchestration, tools, memory, and retrieval.

latest
Source
npmnpm
Version
1.12.9
Version published
Weekly downloads
60K
169.81%
Maintainers
1
Weekly downloads
 
Created
Source

@agentskit/core

Profile: major-package

AgentsKit

The zero-dependency foundation that every AgentsKit package builds on — under the 10 KB gzip budget, edge-ready, works everywhere JavaScript runs.

npm version npm downloads bundle size license stability GitHub stars

Tags: ai · agents · llm · agentskit · typescript · orchestration · streaming · chat

Verified proof

How this fits the ecosystem

@agentskit/core is the contract layer: the tiny, stable foundation that makes adapters, tools, skills, memory, retrievers, and runtimes interchangeable.

  • AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
  • Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
  • Playbook: learn the production patterns behind this layer at playbook.agentskit.io.
  • AKOS: run the same concepts with enterprise deployment, governance, and observability at akos.agentskit.io.

Docs: package guide · agent handoff

Why core

  • Zero external dependencies — no npm bloat, no audit surprises; installs in milliseconds and works in Node, Deno, edge runtimes, and the browser
  • Stable contracts that unlock the whole ecosystem — six ADR-pinned interfaces (Adapter, Tool, Skill, Memory, Retriever, Runtime) make every package interchangeable
  • Chat state machine includedcreateChatController handles streaming, abort, and message history so you never implement that loop yourself
  • Under 10 KB gzipped, always — budget enforced in CI; the foundation you can commit to for the long term

Install

npm install @agentskit/core

Quick example

import { createChatController, createInMemoryMemory } from '@agentskit/core'
import { anthropic } from '@agentskit/adapters'

const controller = createChatController({
  adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-6' }),
  memory: createInMemoryMemory(),
})

await controller.send('Hello!')
console.log(controller.getState().messages)

Features

  • createChatController — streaming-capable chat state machine with abort support; memory is saved after successful turns, never after failed or aborted turns. Background memory and skill activation failures are surfaced through onError.
  • createInMemoryMemory — zero-config in-process memory for prototyping
  • createLocalStorageMemory — browser/demo persistence; malformed stored data raises MemoryError instead of silently becoming an empty history
  • createStaticRetriever — deterministic token-overlap retrieval for demos and fallbacks; use @agentskit/rag for semantic production retrieval
  • parseToolArgs — typed JSON argument parsing for adapters that need fail-closed validation; safeParseArgs remains the compatibility helper
  • TypeScript types for every contract: ToolDefinition, SkillDefinition, AgentEvent, Adapter, ChatMemory, Retriever, ChatController
  • Event emitter for AgentEvent streams — observability hooks attach here
  • AgentEvent.correlation is an optional, provider-neutral identity envelope: operationId is stable across boundaries while runId, sessionId, turnId, actionId, and traceId retain local meaning
  • Dual CJS/ESM output, strict TypeScript, no any

Error handling

AgentsKit ships a didactic error system inspired by the Rust compiler. Every error includes a code, a hint for the fix, and a docsUrl — no more vague "Something went wrong" messages.

import {
  AgentsKitError,
  AdapterError,
  ToolError,
  MemoryError,
  ConfigError,
  ErrorCodes,
} from '@agentskit/core'

try {
  await runtime.run(task)
} catch (err) {
  if (err instanceof ToolError) {
    // err.code     → 'AK_TOOL_EXEC_FAILED'
    // err.hint     → actionable suggestion
    // err.docsUrl  → https://www.agentskit.io/docs/agents/tools
    console.error(err.toString())
    // error[AK_TOOL_EXEC_FAILED]: ...
    //   --> Hint: ...
    //   --> Docs: https://www.agentskit.io/docs/agents/tools
  }
}

Available error codes (via ErrorCodes):

CodeThrown by
AK_ADAPTER_MISSINGadapter not provided to the controller
AK_ADAPTER_STREAM_FAILEDstreaming call to the provider fails
AK_TOOL_NOT_FOUNDrequested tool name is not registered
AK_TOOL_EXEC_FAILEDexecute() throws
AK_TOOL_PEER_MISSINGoptional tool peer dependency is not installed
AK_TOOL_INVALID_INPUTtool arguments or proposal are invalid
AK_TOOL_QUOTA_EXCEEDEDtool execution exceeds its configured quota
AK_TOOL_FORBIDDENtool execution is denied by policy
AK_MEMORY_LOAD_FAILEDmemory.load() fails
AK_MEMORY_SAVE_FAILEDmemory.save() fails
AK_MEMORY_CLEAR_FAILEDmemory.clear() fails
AK_MEMORY_DESERIALIZE_FAILEDpersisted state is corrupt
AK_MEMORY_PEER_MISSINGoptional memory backend is not installed
AK_MEMORY_REMOTE_HTTPremote memory request fails
AK_CONFIG_INVALIDrequired config is missing or wrong type
AK_RUNTIME_INVALID_INPUTruntime input is invalid
AK_RUNTIME_STEP_FAILEDa runtime step fails
AK_RUNTIME_DELEGATE_FAILEDdelegated agent execution fails
AK_SANDBOX_DENIEDsandbox policy denies execution
AK_SANDBOX_INVALID_TOOLtool is not valid for the sandbox
AK_SANDBOX_PEER_MISSINGoptional sandbox backend is not installed
AK_SANDBOX_BACKEND_FAILEDsandbox backend fails
AK_SKILL_INVALIDskill definition is invalid
AK_SKILL_DUPLICATEskill identity is duplicated

Type-safe tools with defineTool

defineTool infers the TypeScript type of execute's args parameter from the JSON Schema — no manual casting.

import { defineTool } from '@agentskit/core'

const greet = defineTool({
  name: 'greet',
  schema: {
    type: 'object',
    properties: { name: { type: 'string' } },
    required: ['name'],
  } as const,   // as const is required for inference
  execute(args) {
    // args.name → string  (inferred, not cast)
    return `Hello, ${args.name}!`
  },
})

Use InferSchemaType<typeof schema> to reference the inferred type elsewhere in your codebase.

Subpath exports (tree-shaken, zero main-bundle weight)

SubpathPurpose
@agentskit/core/agent-schemaDeclarative YAML/JSON agent definitions + validator
@agentskit/core/prompt-experimentsA/B prompts with PostHog / GrowthBook / custom flag providers
@agentskit/core/auto-summarizeChatMemory wrapper that folds old turns into a summary
@agentskit/core/hitlApproval gates + ApprovalStore
@agentskit/core/securityPII redactor + injection detector + rate limiter
@agentskit/core/fuzzy-matchDeterministic Jaro-Winkler matching for KYC, sanctions, deduplication, and entity resolution
@agentskit/core/findingCanonical Finding / Severity shape for review and compliance results
@agentskit/core/compose-toolChain N tools into one macro tool
@agentskit/core/self-debugRetry failing tools with LLM-corrected arguments
@agentskit/core/generative-uiTyped UI element tree + code / markdown / html / chart artifacts
@agentskit/core/a2aAgent-to-Agent protocol spec (JSON-RPC over any transport)
@agentskit/core/manifestSkill + tool manifest format (MCP-compatible)
@agentskit/core/eval-formatPortable eval dataset + run-result JSON
@agentskit/core/memory-validationBounded validation for untrusted serialized memory records
@agentskit/core/tool-proposalPublic helper for routing a validated proposal through controller authorization

See the core guide for agents for the full contract.

Ecosystem

PackageRole
@agentskit/adaptersLLM chat + embedding providers, router, ensemble, fallback
@agentskit/runtimecreateRuntime, speculate, topologies, durable execution, background agents
@agentskit/reactuseChat, headless chat components
@agentskit/vue · svelte · solid · react-native · angularSame ChatReturn contract, one package per framework
@agentskit/toolsBuilt-in tools, 20+ integrations, MCP bridge
@agentskit/memoryChat + vector + hierarchical + encrypted + graph stores
@agentskit/ragPlug-and-play RAG + reranker + loaders
@agentskit/skillsReady-made personas + marketplace
@agentskit/observabilityTraces, audit log, cost guard, devtools
@agentskit/sandboxSecure code execution + mandatory sandbox policy
@agentskit/evalEval suites, deterministic replay, snapshots, CI reporter
@agentskit/cliagentskit init / chat / run / ai / dev / doctor

Contributors

AgentsKit contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: stable — see docs/STABILITY.md
  • Node.js 20+ and TypeScript strict mode
  • Published as @agentskit/core

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.

Keywords

agentskit

FAQs

Package last updated on 03 Sep 2026

Related posts