This section explains how M31A works, rather than how to operate it. The user-facing guides cover commands and settings; these pages follow the data through the runtime and name the source files that implement each stage.
Start with the agent loop: it is the spine that connects prompt assembly, the NIM request, streamed events, tool execution, and session persistence.
Concept map
| Concept | Question it answers | Main implementation |
|---|---|---|
| Agent loop | How does a prompt become a response, and then another request? | packages/core/src/core/m31aChat.ts, packages/core/src/core/turn.ts |
| Context lifecycle | What context is loaded, compacted, distilled, masked, or narrated? | packages/core/src/context/, packages/core/src/utils/memoryDiscovery.ts |
| Tool execution | How is a tool call discovered, authorized, run, and reported back? | packages/core/src/scheduler/, packages/core/src/tools/ |
| Policy evaluation | Which rule wins when trust, modes, allowlists, and admin rules disagree? | packages/core/src/policy/ |
| Session storage | Where are conversations and checkpoints written, and how are they found? | packages/core/src/services/chatRecordingService.ts, packages/core/src/services/sessionSearchIndex.ts |
| Extension model | What is the difference between an extension, a skill, an MCP server, a hook, and a command? | packages/cli/src/config/extension-manager.ts, packages/core/src/utils/extensionLoader.ts |
| Model resolution | How does an alias become a concrete NIM model ID, with what config and fallback? | packages/core/src/services/modelConfigService.ts |
How the concepts fit together
user prompt
|
v
[Context lifecycle] ---- M31A.md, include dirs, compression, masking
|
v
[Agent loop] ---- [Model resolution] ---- NVIDIA NIM /chat/completions
| |
| v
| streamed text / tool calls
v
[Tool execution] ---- [Policy evaluation] ---- trust, modes, rules, admin
|
v
[Session storage] ---- JSONL records, checkpoints, FTS indexExtensions cut across every layer: they contribute skills, tools, hooks, policies, commands, themes, and context files. They are loaded before the agent loop starts so that the loop sees a fully assembled tool registry and policy engine.
Read in this order
- Agent loop — the end-to-end request cycle.
- Context lifecycle — what goes into the prompt.
- Tool execution and Policy evaluation — how calls are authorized.
- Session storage — what survives after the run.
- Extension model and Model resolution — how the runtime is customized.
When you need the guides instead
- To change behavior, see Configuration and the Settings reference.
- To authorize tools interactively, see Approval modes and policies.
- To add capabilities, see the guides for MCP, Skills, Hooks, and Extensions.
- To script the agent, see Headless mode.
- To learn the package layout, see Architecture.
Hands-on practice
The Tutorials index turns these concepts into exercises: reviewing a diff, building an MCP server, authoring a skill or hook, packaging an extension, running CI, using worktrees, adding a provider, and hardening a sandbox.
Next steps
- Follow the agent loop from prompt to persistence.
- Then choose a tutorial to apply the concepts.