You tell your agent a fact. Eight turns later it contradicts you. A bigger context window makes this worse, not better, because now there's more text for the model to lose the thread in. The model has no place to keep what's settled, what's contested, and how sure it is.
thinkⁿ is world model infrastructure for agents: a durable, auditable belief state that lives outside the model. An agent's world model is the frame it acts from. That frame has six parts: the environment it works on (a codebase, an account, a production line, a portfolio, a patient), the observations streaming in, the belief state of what's currently true and how sure it is, the intent the agent is after (its goals and what success looks like), the policy that governs the world, and the actions the agent can take in it. You declare the environment, intent, policy, and actions; the engine compiles observations into the belief state and projects the worldview. The belief state is the live core. It holds what's been observed (past), what's held true (present), and what move would bring the picture closer to reality (future).
Beliefs are how you build that state. A belief is a claim with an explicit posterior, its evidence, and a lifecycle, and it's the unit that keeps the world model honest as reality changes. See World for the full frame, or the FAQ for how it differs from memory, RAG, and a markdown file.
1npm i beliefs1import Beliefs from 'beliefs'
2
3const beliefs = new Beliefs({
4 apiKey: process.env.BELIEFS_KEY,
5 namespace: 'my-project',
6 writeScope: 'space',
7})
8
9// Before the agent acts: read the bounded worldview for this turn.
10// The argument is a relevance query (the task/turn/question at hand)
11// that biases which beliefs and moves surface.
12const context = await beliefs.before(userMessage)
13
14// Run your agent with belief context injected.
15// The top-ranked next move rides back as context.moves[0].
16const result = await myAgent.run({ system: context.prompt })
17
18// Feed the output back: beliefs extracted, conflicts detected, state updated.
19// delta.moves carries the re-ranked moves after the turn.
20const delta = await beliefs.after(result.text)That's the loop: two calls per turn, regardless of which framework you ship on.
The read surface, once. before() and after() are the turn loop. Each returns the worldview plus its ranked .moves (context.moves, delta.moves). read() is the full snapshot, out of band. moves.rank({ topN }) is the standalone ranked-move accessor when you want moves without running a turn. Inside the loop, prefer context.moves[0] over a redundant moves.rank().
Works with your stack
1import { beliefsHooks } from 'beliefs/claude-agent-sdk' // Anthropic Claude Agent SDK
2import { beliefsMiddleware } from 'beliefs/vercel-ai' // Vercel AI SDK
3// React hooks + browser DevTools (coming soon)Or call beliefs.before() / beliefs.after() manually around any LLM (OpenAI, plain fetch, your own agent loop). See the Hack Guide for working recipes across frameworks.
I want to...
| I want to... | Start here |
|---|---|
| Ship in 10 minutes. Hackathon, prototype, exploration. | Hack Guide: install + framework recipes + project ideas |
| See it run end-to-end before committing. | Quickstart: 30 lines that print clarity rising |
| Learn the model first, then build. | World model → Concepts → Tutorial |
| Build chat memory that's separate per conversation. | Install → use writeScope: 'thread' and bind thread: 'id' |
| Run multi-agent shared state (debate, supervisor/worker, swarm). | Patterns → Multi-Agent: same namespace, writeScope: 'space' |
| Audit why an agent believes something. | How it works → Ledger and beliefs.trace() |
| Evaluate fit before integrating. | FAQ: when beliefs help, when they don't |
| Add beliefs to a Claude Agent SDK app. | Adapter: Claude Agent SDK |
| Add beliefs to a Vercel AI SDK app. | Adapter: Vercel AI |
| See it across domains (the whole business, then engineering, research, investing, legal, support, operations, finance, and health). | Use cases |
Why coding agents first
A codebase is already a compact world. It has laws (types, invariants), assumptions (architecture decisions, dependencies), history (commits, PRs), ownership, and contradictions (stale docs, drifted assumptions). Coding agents are already operating inside this world, but with short-lived context and weak memory.
The first world model thinkⁿ targets is the one your coding agent already lives in. Concrete beliefs the engine can hold for a repo:
1belief: Authentication is enforced at the API middleware layer
2confidence: 0.82
3evidence: middleware.ts, auth.test.ts, architecture.md
4contradicts: /api/internal/export bypasses middleware
5next move: inspect route-level auth coverage before modifying export flowThe same machinery carries across the whole business and the functions inside it: engineering, research, investing, legal, support, operations, finance, and health. Any system that has to hold a coherent picture of reality across many turns and many sources runs on the same belief state. See it worked end-to-end in Use cases.
As agents take on real work, a company needs a shared operating state for what its agents understand and decide: what's true, what changed, what's uncertain, and what action is safe. That state is the world model, owned by the company, shared across every agent it runs, and auditable when a decision has to be explained. With it, a company can scale work without scaling management.
Using a coding agent?
Point your agent at the SDK reference: llms.txt. It gives the agent enough to wire up the loop correctly without guessing at the surface.
