Repository navigation
docs: the gmi() guide and agent({ runtime: 'gmi' }) - #192
Conversation
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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
This review includes 12 billable files and costs up to $3.00.
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. View limit detailsLimit details: You’ve used all 4 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (12)
Comment |
Reviewer's GuideDocumentation-only update introducing a comprehensive guide to Sequence diagram for a GMI session turnsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all |
PR Summary by QodoDocument the agent GMI runtime and gmi() API
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
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.
## [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))
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.
…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.
Summary
The guide and the release notes for
agent({ runtime: 'gmi' })andgmi(). 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 withruntime: '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 andclose(). 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 fromagent({ runtime: 'gmi' })with an example, theagent()line of API Surfaces, and the fallback paragraph (the GMI path falls back through a completion gateway). The install example drops amemoryoption that neitheragent()runtime reads in that shape.docs/API_PATHS.md: a section on the GMI path and the capability contract as a table with itsgmicolumn.docs/features/LLM_PROVIDERS.md,docs/ADAPTIVE_PROMPT_INTELLIGENCE.md(with acognitionexample),docs/orchestration/AGENCY_API.md,docs/MEMORY_MODEL.md,docs/getting-started/GETTING_STARTED.md,docs/getting-started/HIGH_LEVEL_API.md(aruntime: 'gmi'example, agmi()row, whichMemoryConfigfields each path reads),examples/high-level-api.mjsandexamples/single-agent-briefing.mjs.src/api/types.ts, comments only:memory(read byagent()only withruntime: 'gmi'),MemoryConfig.embedding(the default pick as the code makes it),MemoryConfig.consolidationandcognitiveMechanisms.Release notes
New, opt-in
gmi()(0.12.14, feat(api): agent() sessions served by a GMI with runtime: 'gmi' #135; aliascreateGmi()): an agent whose sessions are Generalized Mind Instances built in process fromagent()options, with noAgentOSruntime. It returns theAgentsurface.agent({ runtime: 'gmi' })(0.12.21, feat(api): agent({ runtime: 'gmi' }) routing, the remaining gmi() surface and its guide #159) returnsgmi(opts).agent()withoutruntime, or withruntime: 'legacy', keeps thegenerateText()path; of the fixes below, only those that name both runtimes or every caller change it.@framers/agentosand@framers/agentos/api:gmi,createGmi,resolveCognition,personaFromAgentOptions,createAgentCognitiveMemory, and the typesGmiOptions,GmiHandle,CognitionProfile,CognitionConfig,CognitionInputs,MetapromptPreset,ResolvedCognition,AgentCognitiveMemory,AgentCognitiveMemoryOptions.cognition:'light'(the default: the reasoning trace, and cognitive memory only whenmemoryis set),'full'(cognitive memory unlessmemory: false, every memory mechanism, sentiment tracking and the five sentiment metaprompt presets), or aCognitionConfig(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, markedpartial.CapabilitySurfacegains'gmi', and the capability contract agmicolumn.SessionTranscriptMessage.partial:trueon the last message of a GMI turn that failed after some of its steps finished; never sent to a provider.GMIBaseConfig.beforeModelCall, called before every model attempt with a copy of its prompt;STEP_FINISHEDcarries the step'sthinkingBlocks; a turn'scacheDiagnosticsreaches 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
temperature: 0.7andmaxTokens: 2048when neither the persona'sdefaultModelCompletionOptionsnor the turn'smetadata.optionssets them: the provider's defaults apply, as they do foragent()(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:setGlobalLlmObserver()), a billed failed attempt as an'error'event;memoryProvider.observeis called on the provider; no user message carries aname(the GMI named it after the turn's user, on this path the session id unless the caller passed auserId); a turn's user message is kept with the first step the store keeps.textStreamorfullStreamstops the turn; the provider's user field is sent only for an explicituserId;finishReason,provider,modelandproviderMessageIdare reported asagent()reports them; the default embedding provider starts at the global default provider, and Gemini defaults togemini-embedding-2.send()whose answer fails to parse or validate keeps nothing of the exchange (no history, nomemoryProvider.observe); anonBeforeToolExecutionhook 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 afterclose()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):
toolChoiceis sent only on a turn with tools; the router's task hint is built from the user message's text parts;replaceHistory()andclearHistory()drop what the GMI recorded about the removed turns (reasoning-trace details, sentiment context, event previews); a primary with no credentials ends the turn withCONFIGURATION_ERROR; OpenAI o-series and GPT-5 models are sent nopresence_penaltyorfrequency_penalty;ExtensionRegistry.register()keeps the newest registration of an id.generateObject's words, on bothagent()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
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.tsand the consolidation pipeline; the release notes also against the squash commits of #135, #159, #165, #161 and #175 andCHANGELOG.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
!before the colon for a change that breaks users (feat!:orfeat(api)!:).Summary by Sourcery
Document the in-process GMI agent path and distinguish its capabilities and behavior from legacy agents and the full runtime.
Enhancements:
gmi()andagent({ runtime: 'gmi' })APIs, including cognition profiles, sessions, memory, hooks, fallback behavior, usage, lifecycle, and capability boundaries.Documentation:
Chores: