AgentOS is an open-source TypeScript AI agent framework for building agents that remember, adapt, work in multi-agent teams, and write their own tools.
Install and quick start · Docs · Examples · Workbench · Benchmarks · Website · npm · Discord · Blog · Star on GitHub
Give an agent sessions that carry conversation history through long-running exchanges and add optional persistent cognitive memory. Put several agents on a team under one of 7 orchestration strategies, and run them on any of 14 LLM providers through one API. Apache-2.0.
Node.js 22 or newer (ESM). Types ship with the package; it is built with TypeScript 5.4+ (peer range >=5.0.0).
npm install @framers/agentos
export ANTHROPIC_API_KEY=sk-ant-...Save this as tutor.mjs:
import { agent } from '@framers/agentos';
const tutor = agent({
provider: 'anthropic',
instructions: 'You are a patient CS tutor.',
});
const first = await tutor.session('student-1').send('Explain recursion with an analogy.');
console.log(first.text);node tutor.mjsIt prints the tutor's analogy. To try another provider, change provider and set its credential or URL, such as OPENAI_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY or OLLAMA_BASE_URL; omit provider to use environment auto-detection.
Full quickstart · Examples cookbook · API reference
| Build | With | Start from |
|---|---|---|
| A tutor, assistant or companion that remembers each user | agent() sessions, cognitive memory, souledAgent() |
Quick start, high-level-api.mjs |
| A research and writing team | agency() with the graph, sequential or hierarchical strategy |
agency-graph.mjs, agency-sequential-handoff.mjs |
| An agent that adds the tools and specialists it is missing | forge_tool, spawn_specialist |
emergent-hierarchical-spawning.mjs |
| Grounded answers over your own documents | QueryRouter, RAG, hybrid search, reranking |
query-router.mjs, text-hybrid-search.mjs |
| A round table of models from several providers | agency() with a provider and reasoning effort per seat; the script leaves out a seat without an API key and needs keys for at least two seats, with an Anthropic or OpenAI key for its chair |
agency-roundtable.mjs |
| Voice agents and phone lines | the voice pipeline, telephony providers, your own reasoning endpoint behind a voice agent | Voice Pipeline, examples/voice-platform |
| A simulation with many agents | agent() with HEXACO personalities over a deterministic kernel |
Mars Genesis, Paracosm |
flowchart TB
App([Your app]) --> API["API surface<br/>AgentOS.create() · agent() · agency() · generateText() · streamText() · generateObject() · generateImage()"]
API -->|"the helpers and the lightweight agent()"| IO
API -->|"tools on agent(), generateText() and streamText()"| Tools
API -->|"memoryProvider hooks on agent()"| Memory
API -->|"the full runtime"| GMI["Cognitive substrate (GMI)<br/>persona · mood · reasoning trace"]
API -->|"agent() with runtime: 'gmi'"| AgentGMI["GMI of agent()<br/>persona · mood · reasoning trace"]
API --> Orchestration["Orchestration<br/>workflow() · AgentGraph · mission() · checkpoints"]
GMI --> Memory["Memory + RAG<br/>cognitive memory · vector stores · GraphRAG · HyDE · reranking"]
GMI --> Tools["Tools, skills, extensions<br/>extension packs · SKILL.md skills · forged tools"]
GMI --> Safety["Guardrails + human approval<br/>PII · classifiers · grounding · approval gates"]
GMI --> IO["I/O + providers<br/>14 LLM providers · voice · channels · image, video, audio"]
AgentGMI -->|"tools"| Tools
AgentGMI -->|"cognitive memory"| Memory
Orchestration -->|"gmi, tool and guardrail nodes, through host-supplied executors"| GMI
Orchestration --> Tools
Orchestration --> Safety
Seven layers: the API at the top, providers at the floor, cognition, memory and safety in the middle. The lightweight agent() and the generation helpers call providers without going through a GMI; the lightweight agent takes tools and memoryProvider hooks, and generateText() and streamText() take tools. The full runtime serves sessions through GMIs with its guardrails, retrieval, voice and channels. agent() opts in with runtime: 'gmi': its GMIs run tools and cognitive memory, and the runtime's guardrails, retrieval, voice and channels do not run on that path. Workflows, graphs and missions run on one graph runtime, whose nodes call GMIs, tools and guardrails through the executors the host passes to compile(). System architecture →
- Memory that lasts. Persistent cognitive memory with Ebbinghaus decay and 8 neuroscience-backed mechanisms, among them retrieval-induced forgetting, reconsolidation and source-confidence decay. Its published LongMemEval-S and LongMemEval-M results, with their readers, judge and sample size, are in the benchmark section.
- Tools the agent writes. On the full runtime with emergent tooling on, an agent writes a JavaScript function with JSON Schemas for its input and output, the declared test cases run it, an LLM judge reviews the result, and on approval the tool joins the session's tool list. Forged code runs in an in-process
node:vmcontext or, withQuickJSExecutor, in a QuickJS WebAssembly instance of its own for each call. - Teams of agents.
agency()runs sequential, parallel, debate, review-loop, hierarchical, graph and panel teams, with human approval gates and specialists a manager spawns at runtime. - Everything around the model. Optional HEXACO personality, guardrails, RAG, voice and telephony, 37 channel packs in the extension catalog; 100+ extensions and 88 skills ship as separate packages with registries that load them.
The main features, grouped by the job they do, with links to the guides:
| Job | What AgentOS gives you |
|---|---|
| Choose a model provider | LLM providers: 14 (12 by API key or base URL + 2 local CLI): OpenAI, Anthropic, Gemini, Groq, Ollama, OpenRouter, Requesty, LiteLLM, Together, Mistral, xAI, MiniMax, Claude CLI, Gemini CLI. Plus image, video and audio generation providers. Providers |
| Cache prompts | Prompt caching: on by default, with no configuration, for the providers and models that support it (the automatic fallback chain's legs send without it): automatic Anthropic breakpoints incl. multi-turn history (direct + OpenRouter) · OpenAI cache-key routing · normalized cache usage + leak detection · per-call TTL, prefix-only and opt-out. Guide |
| Remember | Cognitive memory: 8 mechanisms: reconsolidation, retrieval-induced forgetting, involuntary recall, FOK, gist extraction, schema encoding, source decay, emotion regulation. Cognitive memory |
| Retrieve | RAG pipeline: 7 vector backends · 3 retrieval strategies and a skip mode · GraphRAG · HyDE · reranking: a local cross-encoder, Cohere or an LLM judge on any model |
| Give it a character | HEXACO personality: 6 traits modulate memory, retrieval bias, response style. GMI runtime: per-session persona, mood and reasoning trace · sentiment-triggered metaprompts (opt-in per persona) · mood-weighted memory bridge · bounded adapt_personality trait changes (opt-in) |
| Grow its own tools | Emergent capabilities: runtime tool forging · 4 self-improvement tools · tiered promotion · skill export. Emergent capabilities |
| Work as a team | Multi-agent teams: 7 coordination strategies · manager delegation and specialist spawning · model pools with seating policies and strict per-seat credentials · a panel strategy with a provider and vendor quorum · HITL approval gates. Multi-agent |
| Run multi-step processes | Orchestration: workflow() DAGs · AgentGraph router, personality and discovery edges · mission() graphs from plan templates · checkpointing in memory or in SQLite and Postgres (SqlCheckpointStore) |
| Stay safe | Guardrails: 6 packs (PII, ML classifiers, topicality, code safety, grounding, content policy). Guardrails |
| Talk and listen | Voice agents & telephony: ElevenLabs, Deepgram, Whisper · Twilio, Telnyx, Plivo. Voice Pipeline |
| Reach people where they are | Channels: 37 channel packs in the extension catalog (Telegram, Discord, Slack, WhatsApp, webchat, ...) and 12 messaging adapters in the core package. Channels |
| Run it in production | Observability: OpenTelemetry · usage ledger · cost guard · circuit breaker |
The .mjs examples linked above are runnable scripts in examples/; the files in examples/voice-platform export a run(options) function for a host to call. The examples import the local build, so run them from a clone, with Node.js 22.13 or later and pnpm 10 (development setup):
The graph example defaults to OpenAI and uses OPENAI_API_KEY. With the ANTHROPIC_API_KEY from the quick start, run the last command as AGENTOS_PROVIDER=anthropic node examples/agency-graph.mjs.
git clone https://github.com/framerslab/agentos.git && cd agentos
pnpm install && pnpm build
node examples/agency-graph.mjs| More examples | What it shows |
|---|---|
single-agent-briefing.mjs |
One agent handles a whole task: the baseline before agency() |
agency-streaming.mjs |
Raw live output beside finalized, approved output |
citation-verification-agent.mjs |
agent({ verifyCitations }): citation verification on generate() |
rerank-local-cross-encoder.mjs |
Reranking with a local cross-encoder |
office-documents.mjs |
Office documents read to text, with bounds on what they inflate to |
workflow-dsl.mjs |
A workflow() DAG on the graph runtime, with checkpoints and its run events |
More in the examples cookbook: a customer service agency, a research team, a call center over a WebSocket, a code review bot, a multi-channel support bot and others.
Both headline results use a per-category reader router (gpt-4o answers temporal-reasoning and single-session-user questions, gpt-5-mini the other four types), with the gpt-4o-2024-08-06 judge, full N=500, single-CLI reproduction with bootstrap 95% CIs and per-benchmark judge-FPR probes.
| Benchmark | Score | Detail |
|---|---|---|
| LongMemEval-S | 85.6% | $0.0090/correct, 3,558 ms p50. With gpt-4o reading every question, the same retrieval scores 84.2%. Mastra's published figures for Observational Memory: 84.23% with a gpt-4o actor and 94.87% with a gpt-5-mini actor, both with gemini-2.5-flash as observer and reflector. |
| LongMemEval-M | 70.2% | 1.5M-token haystacks, 500 sessions. As of its 2026-04-29 M entry, the leaderboard records this as the first open-source result above 65% on M with reproducible methodology. |
Full leaderboard and methodology → · Transparency audit → · LongMemEval paper (Wu et al., ICLR 2025)
| vs. | AgentOS differentiator |
|---|---|
| LangChain / LangGraph | Cognitive memory (8 neuroscience-backed mechanisms), HEXACO personality, runtime tool forging |
| Vercel AI SDK | Multi-agent teams (7 strategies), 7 vector backends, guardrails, voice/telephony, default-on prompt caching for supported providers |
AgentOS supports unified orchestration across DAGs, graphs and missions, plus personality-driven routing. The memory benchmarks give the published LongMemEval-S and LongMemEval-M results and link to the reproduction method.
With history enabled, each send() records the exchange, its tool calls and results, and any signed thinking the model returns. A turn that a structured-output validation retry answered keeps the user message and the accepted attempt's whole exchange, signed thinking included; the invalid replies and the repair feedback are not stored. This works whether cognitive memory is on or off. History is evicted oldest-first at about 120K tokens by default, keeping the newest eight turns. On runtime: 'gmi', requests replay the history that fits the prompt budget.
import { agent } from '@framers/agentos';
const tutor = agent({
provider: 'anthropic', // resolves to claude-sonnet-5-5 (provider default)
// model: 'claude-opus-5-5', // pin a specific model to override the default
instructions: 'You are a patient CS tutor.',
personality: { openness: 0.9, conscientiousness: 0.95 },
});
// Provider auto-detected from env when `provider` is omitted.
// Cognitive memory, sentiment tracking and metaprompts: runtime: 'gmi' (see GMIs below).
const session = tutor.session('student-1');
const first = await session.send('Explain recursion with an analogy.');
console.log(first.text);
const second = await session.send('Can you expand on that?'); // remembers context
console.log(second.text);The two-turn tutor prints both replies. The session sends the first exchange again with the follow-up question.
const stateless = agent({ model, memory: false, history: false }).session('job-1');
const bounded = agent({ model, history: { maxTokens: 60_000 } }).session('job-2');
bounded.reseed([{ role: 'user', content: 'compact resume snapshot' }]);history: false disables transcript recording and replay. A configured memory provider can still recall earlier turns. history: { maxTokens } changes the eviction threshold, reseed() replaces the history with messages you build, and close() ends the session; on the default runtime it also frees the history, and on runtime: 'gmi' the closed handle still reads its old transcript.
High-Level API guide → · GMI session reference →
Three things accumulate across a session and compose into behavior: memory (what was said, decided, retrieved), the tool surface (which grows when an agent forges a tool the judge approves), and an optional HEXACO personality vector that shapes the prompt and scales memory encoding. Each is configurable and observable.
An agent gets the forge_tool meta-tool on the full runtime with emergent tooling on, or through a ToolOrchestrator you configure with emergent support; the lightweight agent() accepts emergent: true and does not activate it. When no tool covers a sub-task, the agent calls forge_tool with a chain of existing tools or a JavaScript function, JSON Schemas for input and output, and test cases. A separate LLM judge reviews the candidate with its test results, and an approved tool joins the session's tool list. A forged tool exports as a SKILL.md skill.
Code mode is off until the host sets emergentConfig.allowSandboxTools. Forged code runs in an in-process node:vm context by default, and node:vm is not a security boundary; with QuickJSExecutor, each call runs in a QuickJS WebAssembly instance of its own with its memory limited. Blocked APIs, resource limits and the typed forge trace each forge yields are in the guide.
HEXACO personality (optional). Off by default. agent() writes the trait values into the system prompt as directives, one for each trait above 0.65 or below 0.35. A cognitive memory manager given the same traits scales its encoding and seven of its eight mechanisms by them, and an AgentGraph branches on a trait with addPersonalityEdge(). HEXACO docs →
Soul files. An agent's identity, writing style, hard limits and HEXACO scores can live in a SOUL.md workspace. souledAgent() wires it end to end:
import { souledAgent } from '@framers/agentos';
const aria = await souledAgent({ provider: 'anthropic', soul: '~/.agentos/agents/aria' });With systemBlocks, the soul's prose and style are left out and its hard limits still close the prompt. The soul's memory/ directory holds the operator's markdown wiki, shared by everyone the agent talks with; conversation memory is kept per user (the session's userId, else the session) and compiled into that user's own pages. souledAgent() keeps each person's memory under their own scope. For the memory AgentOS manages, agent.forgetUser(userId) deletes the person for good and returns a report: check its complete flag before you answer the request, and call it again while complete is false. The deletion holds through a restore of the memory store when the tombstone copy is kept outside what that restore replaces; what stays your duty. How the soul's identity, memory/ wiki and per-user store work is in the guide.
On the full runtime, every session is served by a GMI: a persistent agent with its own persona, mood, conversation history and reasoning trace; with agent({ runtime: 'gmi' }) an agent's sessions are GMIs too. agent() without runtime: 'gmi' is the lightweight helper; it calls the model with a prompt and keeps session history.
import { agent } from '@framers/agentos';
const tutor = agent({
runtime: 'gmi',
cognition: 'full',
provider: 'openai',
instructions: 'You are a patient CS tutor.',
memory: { embedding: { provider: 'openai' } }, // cognitive memory embeds with text-embedding-3-small
});
const session = tutor.session('student-1', { userId: 'student-7f3a' }); // memory is scoped to the user id
await session.send('Explain recursion with an analogy.');The self-reflection metaprompt, the self-modification tools, persona overlays and the runtime's guardrails, retrieval, voice and channels do not run on this path.
A GMI of the full runtime runs a turn loop around the same model, tools, guardrails and cognitive memory, with sentiment-triggered metaprompts, mood-weighted memory, self-modification tools (with selfImprovement.enabled) and a reasoning trace of the last 500 decisions by default:
Set OPENAI_API_KEY before running this example (or OPENROUTER_API_KEY, REQUESTY_API_KEY, MINIMAX_API_KEY or a local Ollama): the full runtime's default configuration builds its providers from those, and the quick start's ANTHROPIC_API_KEY is not among them.
import { AgentOS, AgentOSResponseChunkType, BUILT_IN_PERSONAS } from '@framers/agentos';
// AgentOS.create() reads persona files from ./personas by default. Personas can
// also be given inline, as parsed JSON or code-built objects; here, the five the
// package ships. A custom loader covers any other source.
const agentos = await AgentOS.create({ personas: BUILT_IN_PERSONAS });
for await (const chunk of agentos.processRequest({
userId: 'user-42', sessionId: 'research-q1', selectedPersonaId: 'v_researcher',
textInput: 'Summarize the open incidents from this week.',
})) {
if (chunk.type === AgentOSResponseChunkType.TEXT_DELTA) process.stdout.write(chunk.textDelta);
}What a GMI adds over a plain agent →
import { agency } from '@framers/agentos';
const team = agency({
strategy: 'graph',
agents: {
researcher: { provider: 'anthropic', instructions: 'Find relevant facts.' }, // -> claude-sonnet-5-5
writer: { provider: 'openai', instructions: 'Summarize clearly.', dependsOn: ['researcher'] }, // -> gpt-4o
reviewer: { provider: 'gemini', instructions: 'Check accuracy.', dependsOn: ['writer'] }, // -> gemini-3.8-flash
},
});
const result = await team.generate('Compare TCP vs UDP for game networking.');Strategies: sequential, parallel, debate, review-loop, hierarchical, graph, panel. With hierarchical + emergent: { enabled: true }, the manager forges new sub-agents at runtime.
Every roster agent can set its own provider, model, apiKey and effort; a parallel or panel agency can require a provider quorum (quorum: { minProviders: 2 }) before it synthesizes. Model pools are in the guide.
Three layers, highest priority first: inline apiKey on the call, a module-level setDefaultProvider() at boot, or environment-variable auto-detection (OPENAI_API_KEY, ANTHROPIC_API_KEY, and the rest, resolved in priority order and reorderable with setProviderPriority([...])).
A comma-separated list of keys gives a supported provider a key pool: round-robin by default, or AGENTOS_KEY_POOL_STRATEGY_<PROVIDER>=ordered (AGENTOS_KEY_POOL_STRATEGY_ANTHROPIC=ordered for Anthropic's keys alone; AGENTOS_KEY_POOL_STRATEGY=ordered for every provider's) to use the keys in order and fail over to the next when one is revoked, unpaid or throttled (Key rotation). probeProviderKey({ provider, apiKey }) takes one key of Anthropic, OpenAI, Gemini, OpenRouter or Requesty and says whether it is live, out of credit, rejected, throttled or unknown, by the same billing probe the pool sends.
Full credential resolution + default models per provider → · Key rotation →
| Surface | What it is |
|---|---|
agent() |
Lightweight stateful agent. Prompts, sessions, personality, hooks, tools, memory through memoryProvider hooks. With runtime: 'gmi' (or gmi()), every session is a GMI built from the same options, with cognitive memory, sentiment tracking and metaprompts per its cognition profile. |
agency() |
Multi-agent teams built from agent() members, with HITL approval gates, run limits, structured output, provenance and, on the hierarchical strategy, specialists spawned at runtime. |
generateText() / streamText() / generateObject() / generateImage() / removeBackground() / generateVideo() / generateMusic() / performOCR() / embedText() |
Low-level multi-modal helpers. generateText() and streamText() take tools; the other helpers take none. |
workflow() / AgentGraph / mission() |
Three orchestration authoring APIs over one graph runtime. |
agency()'s guardrails and rag options are reported or logged and not applied, and voice.enabled serves the agency as JSON text over a local WebSocket. It wires no channels; channel adapters run on the full runtime or with ChannelRouter.
Provider fallback is on by default for generateText(), streamText(), agent() and agency(): when a call fails with a retryable error, it is retried on the providers of the default fallback chain whose keys are in the environment (OpenAI, Anthropic, OpenRouter, Gemini, then Groq, Together, Mistral, xAI, Requesty and MiniMax, in that order), leaving out the provider that failed; a leg whose model lacks a capability the call needs is skipped. A call with policyTier: 'mature' or 'private-adult' and OPENROUTER_API_KEY set tries the tier's OpenRouter models first, which can retry OpenRouter with another model. A stream whose tools have run or whose output has reached the consumer ends with the error and does not fall back, and under the panel strategy a fixed seat uses only the fallbackProviders it names (fallback behavior). Pass fallbackProviders: [] to turn it off, or a list to set the chain yourself.
The GMIs of the full runtime (processRequest()) call their provider without a fallback chain. The GMIs of agent({ runtime: 'gmi' }) call it through a completion gateway built from the agent's fallbackProviders, which moves to the next provider when a call fails with a retryable error before its first output, and not after it.
Full API reference → · High-Level API guide →
| Package | Role |
|---|---|
@framers/agentos |
Core runtime: agents, cognitive memory, orchestration, guardrails, voice, 14 LLM providers. Apache-2.0. |
@framers/agentos-extensions |
100+ first-party extensions: channel adapters, tool packs, integrations, guardrail packs. |
@framers/agentos-extensions-registry |
Discovery + auto-loader for the extensions catalog. |
@framers/agentos-skills |
88 curated SKILL.md skills. |
@framers/agentos-skills-registry |
Discovery + auto-loader for skills; where promoted forged tools land. |
@framers/agentos-bench |
Open benchmark harness: bootstrap 95% CIs, judge-FPR probes, per-case run JSONs. MIT. |
@framers/sql-storage-adapter |
Cross-platform SQL persistence: SQLite, Postgres, IndexedDB, Capacitor SQLite. Also used on its own by SafeOS, a pet-finding camera app. |
| AgentOS Workbench | A local React + Vite dashboard for inspecting, debugging and orchestrating AgentOS agent sessions. |
Extensions load from the manifest a host passes to AgentOS.create({ extensionManifest }); createCuratedManifest() from @framers/agentos-extensions-registry builds one from the curated extensions that are installed, and a runtime without a manifest loads none. Extensions architecture →
| Project | What it is |
|---|---|
Paracosm (paracosm) |
AI agent swarm simulation on AgentOS. Live demo. |
Wunderland (wunderland) |
Batteries-included CLI + daemon over the AgentOS registries (preview). Apache-2.0. |
| Wilds.ai | AI game worlds powered by AgentOS. |
| Guide | What it covers |
|---|---|
| Benchmarks | Benchmark tables, 95% confidence intervals, methodology audit |
| Architecture | System design, layer breakdown |
| Cognitive Memory | 8 mechanisms with 30+ APA citations |
| RAG Configuration | Vector stores, embeddings, sources |
| Document Ingestion | PDF, Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, HTML and Markdown read to text, with bounds on what a Word or office archive inflates to |
| Library Index | Sources over any vector store, and a browser entry for a page's own search and records, transcript files from other notetakers (SubRip, WebVTT, Otter, Fireflies, Word) read to turns with the speakers kept apart, and the plan of an archive's entries |
| Text Processing & Search | Tokenizers and stemming, BM25, fuzzy and hybrid search, text statistics, chunking, reranking |
| Reranking | One RerankerService over a local Transformers.js cross-encoder (scoring stays on the host), Cohere's rerank API, an LLM judge on any model your function calls, or a provider of your own |
| Guardrails | Two-phase dispatcher, four verdicts, a hold on a BLOCK that keeps content back for a person's review, fail-open and fail-closed guards |
| Voice Pipeline | TTS, STT, telephony |
| Blog | Engineering posts, benchmark publications, transparency audits |
Questions and help: Discord · GitHub Issues
git clone https://github.com/framerslab/agentos.git && cd agentos
pnpm install && pnpm build && pnpm testpnpm run test:coverage runs the suite with coverage, as CI does: the run fails below the thresholds in vitest.config.ts, and CI sends master's figures to Codecov, which the coverage badge reads.
We use Conventional Commits. Project guides:
| Guide | What |
|---|---|
| Contributing | Development setup, commit and pull request rules, review threads, contribution licensing |
| Adding an LLM provider | Provider interface, acceptance checklist, sponsorship and disclosure |
| Release guide | How merged changes become the daily npm release |
| Agent instructions | Commands and conventions for coding agents |
| Maintainers | Who reviews and merges changes |
| Code of Conduct | Community standards |
| Security Policy | Reporting vulnerabilities privately |
| Support | Where to get help |
| Sponsors | Funding, sponsor placement and disclosure |
AgentOS is Apache-2.0 and free. We integrate any quality provider on technical merit, and partners and sponsors are featured in the README and docs, labeled as such. Companies engage through partner startup programs, sponsorship, or a provider integration. See SPONSORS.md.
| Partner | Type | Provides | Since |
|---|---|---|---|
| Startup Program | Speech-to-text + text-to-speech credits, go-to-market | 2026 |
| Track | What it is | Where |
|---|---|---|
| Sponsor | Fund development. Disclosed logo placement + release-notes credit. | SPONSORS.md |
| Provider integration | Ship your model or API as a supported provider. Free, on technical merit. | Provider guide |
Interested? Email team@frame.dev.
npm install @framers/agentosQuick start · Docs · Examples · Workbench · Discord · Star AgentOS on GitHub