agentskit.js

@agentskit/core — for agents

Zero-dependency foundation. Contracts, chat controller, primitives, and a dozen feature subpaths.

#Purpose

Stable TypeScript contracts (Adapter, Tool, Memory, Retriever, Skill, Runtime) + createChatController + primitives. Target: <10 KB gzipped, zero runtime deps.

#Install

npm install @agentskit/core

#Primary exports (main entry)

  • createChatController(config) — state machine behind every UI
  • proposeToolCall(...) — place a trusted, validated action into the same confirmation lifecycle; never executes directly binding. Returns { getState, subscribe, send, stop, retry, edit, regenerate, setInput, clear, approve, deny, updateConfig }.
  • defineTool(config) — typed tool factory with JSON-Schema input inference.
  • ChatConfig.authorizeToolCall — trusted host authorization before tool proposal and again before execution. Callback failures default to deny.
  • createInMemoryMemory / createLocalStorageMemory — default ChatMemory implementations.
  • createStaticRetriever / formatRetrievedDocuments — RAG-less retrieval.
  • executeToolCall, consumeStream, createEventEmitter, safeParseArgs, generateId, buildMessage — low-level helpers.
  • AgentsKitError, AdapterError, ToolError, MemoryError, ConfigError, RuntimeError, SandboxError, SkillError, ErrorCodes — error taxonomy.
  • Token budget: compileBudget, approximateCounter.
  • Progressive tool args: createProgressiveArgParser, executeToolProgressively.
  • createVirtualizedMemory — hot-window + cold-retriever wrapper (also re-exported from @agentskit/memory).
  • Untrusted-input fencing lives in the @agentskit/core/security entry: fenceUntrustedContent(content, opts?) + UNTRUSTED_CONTENT_DIRECTIVE wrap attacker-influenced text so the model treats it as data, not instructions (the mitigation companion to createInjectionDetector).
  • Multi-modal content parts: textPart, imagePart, audioPart, videoPart, filePart, partsToText, normalizeContent, filterParts.
  • Agent-loop internals (advanced): buildToolMap, activateSkills, executeSafeTool, createToolLifecycle.
  • Memory serialization: serializeMessages, deserializeMessages; validate untrusted records with validateMemoryRecord from @agentskit/core/memory-validation.

#Subpath exports (zero main-bundle weight)

SubpathPurposeRecipe
@agentskit/core/agent-schemaDeclarative agent YAML/JSON + validatorSchema-first agents
@agentskit/core/prompt-experimentsA/B prompts with feature flagsA/B prompts
@agentskit/core/auto-summarizeAuto-summarizing ChatMemory wrapperAuto-summarize
@agentskit/core/hitlApproval gates + ApprovalStoreHITL approvals
@agentskit/core/securityPII redactor + injection detector + fenceUntrustedContent + rate limiterPII, Injection, Rate limit
@agentskit/core/fuzzy-matchjaroWinkler / fuzzyMatchList — zero-dep fuzzy name matching for sanctions/KYC/dedup without an LLM
@agentskit/core/findingFinding / Severity / SEVERITY_ORDER — canonical issue shape so review/audit/compliance findings are interoperable
@agentskit/core/compose-toolChain N tools into oneTool composer
@agentskit/core/self-debugRetry tools with LLM-corrected argsSelf-debug
@agentskit/core/generative-uiTyped UI element tree + artifactsGen UI
@agentskit/core/a2aAgent-to-Agent protocol specOpen specs
@agentskit/core/manifestSkill + tool manifest format (MCP-compat)Open specs
@agentskit/core/eval-formatPortable eval dataset + run-resultOpen specs

#Minimal example

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

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

controller.subscribe(() => console.log(controller.getState().messages))
await controller.send('Hello')

#Common patterns

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.