Skip to content

docs: the gmi() guide and agent({ runtime: 'gmi' }) - #192

Merged
jddunn merged 7 commits into
masterfrom
docs/gmi-guide
Oct 9, 2026
Merged

jddunn merged 7 commits into
masterfrom
docs/gmi-guide

Conversation

@jddunn

@jddunn jddunn commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

The guide and the release notes for agent({ runtime: 'gmi' }) and gmi(). Their code is on master (#135, #159, #165, #161, #175); gmi() was released in 0.12.14 without notes. This pull request changes docs, examples and doc comments only.

  • docs/GMI.md: which sessions are GMIs (the full runtime's, and an agent's with runtime: 'gmi'), a third column in the comparison table, and a section GMIs from agent(): construction checks, the cognition profiles, the persona built from the agent's options, tools and the completion gateway, the session store as the source of the history, send() / stream() / generate(), cognitive memory (per-session scope, memory.embedding, what consolidation does on this path), memoryProvider, the hooks, usage metering and close(). The passages on cognitive memory, the mechanisms, personality, the gateway, the output stream and multi-agent work name the path they hold for.
  • README.md: GMIs from agent({ runtime: 'gmi' }) with an example, the agent() line of API Surfaces, and the fallback paragraph (the GMI path falls back through a completion gateway). The install example drops a memory option that neither agent() runtime reads in that shape.
  • docs/API_PATHS.md: a section on the GMI path and the capability contract as a table with its gmi column.
  • docs/features/LLM_PROVIDERS.md, docs/ADAPTIVE_PROMPT_INTELLIGENCE.md (with a cognition example), docs/orchestration/AGENCY_API.md, docs/MEMORY_MODEL.md, docs/getting-started/GETTING_STARTED.md, docs/getting-started/HIGH_LEVEL_API.md (a runtime: 'gmi' example, a gmi() row, which MemoryConfig fields each path reads), examples/high-level-api.mjs and examples/single-agent-briefing.mjs.
  • src/api/types.ts, comments only: memory (read by agent() only with runtime: 'gmi'), MemoryConfig.embedding (the default pick as the code makes it), MemoryConfig.consolidation and cognitiveMechanisms.

Release notes

New, opt-in

  • gmi() (0.12.14, feat(api): agent() sessions served by a GMI with runtime: 'gmi' #135; alias createGmi()): an agent whose sessions are Generalized Mind Instances built in process from agent() options, with no AgentOS runtime. It returns the Agent surface.
  • agent({ runtime: 'gmi' }) (0.12.21, feat(api): agent({ runtime: 'gmi' }) routing, the remaining gmi() surface and its guide #159) returns gmi(opts). agent() without runtime, or with runtime: 'legacy', keeps the generateText() path; of the fixes below, only those that name both runtimes or every caller change it.
  • Exports (0.12.21, feat(api): agent({ runtime: 'gmi' }) routing, the remaining gmi() surface and its guide #159), from @framers/agentos and @framers/agentos/api: gmi, createGmi, resolveCognition, personaFromAgentOptions, createAgentCognitiveMemory, and the types GmiOptions, GmiHandle, CognitionProfile, CognitionConfig, CognitionInputs, MetapromptPreset, ResolvedCognition, AgentCognitiveMemory, AgentCognitiveMemoryOptions.
  • cognition: 'light' (the default: the reasoning trace, and cognitive memory only when memory is set), 'full' (cognitive memory unless memory: false, every memory mechanism, sentiment tracking and the five sentiment metaprompt presets), or a CognitionConfig (memory, mechanisms, sentiment, metaprompts).
  • MemoryConfig.embedding { provider, model?, dimension? }: the embedding model of the agent's cognitive memory. Unset, the global default provider when agentos has an embedding model for it, else the first of OpenAI, Gemini and Ollama with a key or base URL set.
  • agent.session(id, { userId }) (AgentSessionOptions): on the GMI path, scopes cognitive memory to that user and is sent as the provider's end-user id; a session opened without one has a memory scope of its own and sends no user id. The legacy runtime ignores it.
  • AgentSession.close() (0.12.14) on both runtimes. On the GMI path it stops a running turn: the model call is aborted, the caller gets the abort error, and the finished steps stay in the history, marked partial.
  • CapabilitySurface gains 'gmi', and the capability contract a gmi column.
  • SessionTranscriptMessage.partial: true on the last message of a GMI turn that failed after some of its steps finished; never sent to a provider.
  • For hosts that build GMIs (0.12.14): GMIBaseConfig.beforeModelCall, called before every model attempt with a copy of its prompt; STEP_FINISHED carries the step's thinkingBlocks; a turn's cacheDiagnostics reaches every step. CompletionGateway.stream() takes an optional sixth argument, schemaInPrompt (0.13.8, fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #175).

Behaviour change for hosts that drive GMIs directly

  • A GMI no longer sends temperature: 0.7 and maxTokens: 2048 when neither the persona's defaultModelCompletionOptions nor the turn's metadata.options sets them: the provider's defaults apply, as they do for agent() (0.13.2, fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #161). This holds for every GMI, the full runtime's (processRequest()) included. A host that relied on those values sets them on the persona or on the request.

Fixes since 0.12.14

On the gmi() path:

  • 0.13.0 (fix(api): five defects from a cold read of the gmi() session runner #165): the usage ledger row of each model call is written before the turn ends; each model call fires a usage observer event (setGlobalLlmObserver()), a billed failed attempt as an 'error' event; memoryProvider.observe is called on the provider; no user message carries a name (the GMI named it after the turn's user, on this path the session id unless the caller passed a userId); a turn's user message is kept with the first step the store keeps.
  • 0.13.2 (fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #161): each session has its own working memory, so one session's memory context never lists another session's traces; an abandoned textStream or fullStream stops the turn; the provider's user field is sent only for an explicit userId; finishReason, provider, model and providerMessageId are reported as agent() reports them; the default embedding provider starts at the global default provider, and Gemini defaults to gemini-embedding-2.
  • 0.13.8 (fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #175): a structured send() whose answer fails to parse or validate keeps nothing of the exchange (no history, no memoryProvider.observe); an onBeforeToolExecution hook that resolves with nothing is warned about and the tool runs with the model's arguments; agent.close() also closes a cognitive memory a first turn builds while it runs, and a build asked for after close() fails; a structured send carries no chain-of-thought instruction, and the other calls of an agent with tools carry it first in the system prompt; close() returns during a request stalled before its first byte.

In the GMI core, the completion gateway and the providers (every caller):

  • 0.13.2 (fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #161): a step that fails after output counts its billed usage; toolChoice is sent only on a turn with tools; the router's task hint is built from the user message's text parts; replaceHistory() and clearHistory() drop what the GMI recorded about the removed turns (reasoning-trace details, sentiment context, event previews); a primary with no credentials ends the turn with CONFIGURATION_ERROR; OpenAI o-series and GPT-5 models are sent no presence_penalty or frequency_penalty; ExtensionRegistry.register() keeps the newest registration of an id.
  • 0.13.8 (fix(api): gmi() follow-ups (session privacy, stream stop, usage on errors) and the guide #175): a structured send whose provider payload carries no schema gets the schema in its system prompt, in generateObject's words, on both agent() runtimes and for each fallback leg; the completion gateway checks the turn's abort signal while it waits for each chunk.

Linked issues

Follows #135, #159, #165, #161 and #175.

Type of change

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

Each sentence was read against the code on master: src/api/gmi.ts, src/api/agent.ts, src/api/runtime/gmiSession.ts, gmiCognition.ts, gmiPersona.ts, gmiResults.ts, gmiTranscript.ts, agentCognitiveMemory.ts, capabilityContract.ts, src/api/sessionHistory.ts, src/cognition/substrate/GMI.ts, CognitiveMemoryBridge.ts, MetapromptExecutor.ts and the consolidation pipeline; the release notes also against the squash commits of #135, #159, #165, #161 and #175 and CHANGELOG.md. CI on head 3db5f56, nothing run locally: CI run 37884821596 (Test & Lint, whose docs-alignment test pins strings in the README, the high-level API guide and its example; Batch-1 gated tests; Release dry run) and Links run 37884821557 are green, as is the Breaking change gate.

Migration notes

None for this pull request. The behaviour change above shipped in 0.13.2.

Checklist

  • Tests cover the changed behavior.
  • Docs are updated.
  • The title follows Conventional Commits, with ! before the colon for a change that breaks users (feat!: or feat(api)!:).
  • No secrets or private data are included.
  • Every automated review thread is settled (how).
  • I have read this change and can explain every line.

Summary by Sourcery

Document the in-process GMI agent path and distinguish its capabilities and behavior from legacy agents and the full runtime.

Enhancements:

  • Document the gmi() and agent({ runtime: 'gmi' }) APIs, including cognition profiles, sessions, memory, hooks, fallback behavior, usage, lifecycle, and capability boundaries.
  • Clarify the distinction between legacy agents, in-process GMIs, and the full AgentOS runtime across API guides, architecture documentation, examples, and release notes.

Documentation:

  • Add comprehensive user-facing guidance for configuring and using GMIs, including cognitive memory embeddings, session scoping, metaprompts, provider fallback, and unsupported runtime features.
  • Update API references, getting-started material, provider and memory documentation, orchestration guidance, README examples, and example programs to reflect GMI behavior and memory configuration.
  • Document the released GMI features, behavior changes, fixes, exports, and migration context in the release notes.

Chores:

  • Clarify TypeScript API comments for GMI-specific memory, embedding, consolidation, and cognitive mechanism options.

The guide says which sessions are GMIs: the full runtime's, and those of
an agent created with runtime: 'gmi' or gmi(). The new section covers the
construction checks, the cognition profiles, the persona built from the
agent's options, the tools and the completion gateway, the session store
as the source of the history, cognitive memory with its per-session scope
and embedding model, memoryProvider, the hooks, usage metering and
close(). The passages that said agent() never creates a GMI, and that
agent() and agency() never apply cognitiveMechanisms, now name the path
they hold for.
@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 9, 2026 04:31
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 12 billable files and costs up to $3.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 1 minute for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 686a4745-1329-4a6c-8b77-2ffe71d48b01
📥 Commits

Reviewing files that changed from the base of the PR and between c60f359 and eb3ee3d.

📒 Files selected for processing (12)
  • README.md
  • docs/ADAPTIVE_PROMPT_INTELLIGENCE.md
  • docs/API_PATHS.md
  • docs/GMI.md
  • docs/MEMORY_MODEL.md
  • docs/features/LLM_PROVIDERS.md
  • docs/getting-started/GETTING_STARTED.md
  • docs/getting-started/HIGH_LEVEL_API.md
  • docs/orchestration/AGENCY_API.md
  • examples/high-level-api.mjs
  • examples/single-agent-briefing.mjs
  • src/api/types.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Documentation-only update introducing a comprehensive guide to gmi() and agent({ runtime: 'gmi' }), including how options become cognition, persona, memory, sessions, model calls, hooks, usage, and lifecycle behavior, while updating existing GMI comparisons and related runtime guidance.

Sequence diagram for a GMI session turn

sequenceDiagram
    participant Caller
    participant Session as gmiSession
    participant History as SessionHistoryBuffer
    participant Memory as CognitiveMemoryManager
    participant Gateway as completion gateway
    participant Model as model provider
    participant Tools as tool orchestrator

    Caller->>Session: send(input)
    Session->>History: messages()
    Session->>Memory: retrieve context
    Session->>Gateway: model completion attempt
    Gateway->>Model: generate or stream
    Model-->>Gateway: text or tool call
    opt tool call
        Gateway->>Tools: execute tool
        Tools-->>Gateway: tool result
        Gateway->>Model: generate or stream
    end
    Gateway-->>Session: completed step
    Session->>History: write turn steps
    Session-->>Caller: GenerateTextResult
Loading

File-Level Changes

Change Details Files
Document the new GMI-backed agent path and distinguish it from the full AgentOS runtime and legacy lightweight helpers.
  • Update the GMI overview and comparison table for agent({ runtime: 'gmi' }) and gmi().
  • Clarify differences in session state, persona construction, cognition, memory, capabilities, output types, agencies, and streaming.
  • Add the new APIs and implementation modules to the documentation index.
docs/GMI.md
Add an implementation-oriented guide to constructing and operating GMIs from agent options.
  • Document construction-time validation, lazy initialization, cognition profiles, persona mapping, tools, completion gateways, and fallback behavior.
  • Describe session history semantics, structured and streaming results, per-call GMIs, usage accounting, hooks, and close behavior.
  • Explain cognitive-memory sharing and session/user scope, embedding selection, consolidation limitations, and memoryProvider precedence.
docs/GMI.md
Align existing GMI documentation with the new agent-backed runtime and release-note scope.
  • Update cognitive-memory, personality, mechanism, streaming, completion-gateway, and agency sections to cover the GMI agent path.
  • Add the gmi() and agent({ runtime: 'gmi' }) documentation and release-note content described by the PR.
docs/GMI.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Document the agent GMI runtime and gmi() API

📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Explain how agent({ runtime: 'gmi' }) and gmi() create session-backed GMIs.
• Document cognition profiles, personas, tools, memory, session behavior, hooks, usage, and cleanup.
• Clarify differences from the full runtime and legacy agent path.
Diagram

graph TD
  A["Agent options"] --> B["GMI handle"] --> C["Session GMI"] --> D["Completion gateway"]
  C --> E["Session history"]
  C --> F["Cognitive memory"]
Loading
High-Level Assessment

Extending the existing GMI guide is appropriate: it puts the new agent-backed path alongside the full-runtime and legacy paths readers need to compare. A separate guide would duplicate that context.

Files changed (1) +104 / -19

Documentation (1) +104 / -19
GMI.mdAdd a guide to agent-backed GMI sessions +104/-19

Add a guide to agent-backed GMI sessions

• Adds an example and reference material for 'agent({ runtime: 'gmi' })' and 'gmi()', including construction checks, cognition profiles, persona creation, model calls, session history, memory, hooks, usage, and closing. Revises comparisons and related sections to distinguish this path from the full AgentOS runtime and legacy helpers.

docs/GMI.md

jddunn added 6 commits October 8, 2026 21:33
The README says an agent created with runtime: 'gmi' serves its sessions
with GMIs, shows one, names the option on the agent() line of API
Surfaces, and says its GMIs fall back through a completion gateway built
from fallbackProviders. The install example drops a memory option that
neither agent() runtime reads in that shape. The API paths page gains a
section on the GMI path and the capability contract as a table with its
gmi column.
The adaptive prompt page says which sentiment and metaprompt switches
agent({ runtime: 'gmi' }) carries, with an example. The agency page says
which roster members are GMIs and that the strategies call them through
generate() and stream(). The memory, getting-started and provider pages
name the GMI path where they said agent() has no cognitive memory or
falls back only through generateText(). The high-level API guide drops a
memory option from its plain agent() example, adds a runtime: 'gmi'
example and a gmi() row, and says which MemoryConfig fields each path
reads; the examples follow.
The memory option's comment said true keeps conversation history and
false makes every call stateless; agent() reads it only with
runtime: 'gmi', where it turns cognitive memory on or off, and history
is set by the history option. MemoryConfig.embedding names the default
pick as the code makes it (the global default provider, then OpenAI,
Gemini and Ollama), consolidation says what it does on the GMI path, and
cognitiveMechanisms names the path that applies it.
@jddunn
jddunn merged commit e6c6305 into master Oct 9, 2026
8 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 9, 2026
## [0.13.10](v0.13.9...v0.13.10) (2026-10-09)

### fix

* **config:** honor provider model and timeout defaults (#194) ([c5860d4](c5860d4))

### docs

* fifth round of audit follow-ups to the guides (#171) ([e64d2d6](e64d2d6))
* **publication:** publish the structured reply guide (#191) ([a5f0d51](a5f0d51))
* the gmi() guide and agent({ runtime: 'gmi' }) (#192) ([e6c6305](e6c6305))
jddunn added a commit that referenced this pull request Oct 9, 2026
Follow-ups from the review of #192, the guide to gmi() and agent({ runtime: 'gmi' }), each code fix after a regression test that CI ran red:

- A roster seat written as a config accepts runtime and cognition (AgencySeatConfig, exported from the package root), so the seat the guides write type-checks, and runtime: 'gmi' makes it a GMI.
- A GMI member works in an agency that gates tool calls (hitl.approvals.beforeTool): gmi() takes the agency's approval gate as a per-call option and asks it before a tool runs, after onBeforeToolExecution, as generateText does; a call it does not approve is skipped and the model is told why. docs/GMI.md and docs/orchestration/AGENCY_API.md follow.
- verifyCitations runs on the GMI path: generate() sets result.grounding as agent().generate() does, through the same function, which moves to src/api/runtime/citationVerification.ts.
- gmi() treats a voice, avatar or channels config that sets only enabled: false as unset, as agent()'s deferred-option check does.
- A session id opened again after session.close() gets a memory scope of its own, so it recalls nothing the closed session filed; a session opened with an explicit userId still recalls that user's traces. The session's id, its usage totals and its ledger records keep the id the caller passed.
- The capability contract marks memory accepted_but_deferred on the plain agent() surface, and agent({ memory }) without runtime: 'gmi' warns that the option is not applied, naming runtime: 'gmi'. docs/API_PATHS.md follows the contract.
- The docs-alignment case for the memory examples pins the runtime: 'gmi' memory example and the sentence naming the MemoryConfig fields each path reads, and fails on any agent() call in README.md, docs/getting-started/HIGH_LEVEL_API.md, examples/high-level-api.mjs, docs/GMI.md or docs/memory/HEXACO_PERSONALITY.md that passes memory without runtime: 'gmi'.
- docs/memory/HEXACO_PERSONALITY.md: the quickstart runs on runtime: 'gmi' with cognitive memory, and each of the five surfaces a personality reaches names the paths it runs on.
- docs/GMI.md: the history paragraph states the prompt engine's rule: the history gets 35 percent of the serving model's context window, the oldest messages leave the request first while the store keeps them, and nothing tells the caller (filed as #206).
- README.md: the GMI section says which parts an agent's GMIs run (the reasoning trace, memory, sentiment tracking with the five preset event metaprompts) and which run only on the full runtime (the self-reflection metaprompt, the self-modification tools, persona overlays, guardrails, retrieval and channels).

Every change keeps the existing call signatures.
@jddunn
jddunn deleted the docs/gmi-guide branch October 10, 2026 18:57
jddunn added a commit that referenced this pull request Oct 10, 2026
…tools, hard limits)

The items the audit left for the gmi() guide were checked against master at
5c71e81. #192 and the gmi() follow-ups (#199, #217, #231) settled most of
them. These were still open:

- GMI.md and API_PATHS.md listed voice, avatar and channels as the options
  gmi() throws on. UNSUPPORTED_ON_GMI (src/api/gmi.ts) also holds budget,
  added with the spend budget (#185).
- GMI.md said a GMI carries its traits as persona state that
  adapt_personality can change. Only the full runtime passes the tool
  orchestrator the options that register the self-improvement tools
  (src/api/AgentOS.ts); gmi() initializes its orchestrator with the agent's
  tools alone and hands the caller no GMI to call setPersonalityTrait() on.
  The HEXACO page now says that agent() registers no such tool on either
  runtime.
- GUARDRAILS_USAGE.md described the "Hard limits" block as part of every
  GMI turn of a persona that sets hardLimits. personaFromAgentOptions() sets
  none and the gmi() path applies no SOUL front matter, so those GMIs have
  no such block.

The ToolOrchestrator line reference in GMI.md moves to 369-401, where the
registration is now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant