Repository navigation
fix(gmi): follow-ups from the review of the gmi() guide - #199
Conversation
…s and runs on a GMI
docs/orchestration/AGENCY_API.md and docs/GMI.md write a roster seat as
{ runtime: 'gmi', ... }. AgencyOptions.agents takes BaseAgentConfig | Agent,
and runtime and cognition exist only on AgentOptions, so the documented seat
is an excess-property error (TS2353). The case writes the seat with no cast:
the type check fails on it until a seat config carries both options.
The provider stub records whether a call asked for a stream, so a case can
tell a GMI's model call from the whole response agent() asks generate() for.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideAdds an end-to-end regression test proving that agency roster configurations can define a GMI-backed member and that the request follows the expected streaming GMI path, with provider stubs enhanced to expose call mode. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by Qodotest(gmi): cover GMI roster seats in agency()
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
AgencyOptions.agents took BaseAgentConfig | Agent, so a seat written as
{ runtime: 'gmi', ... }, as the agency and GMI guides write it, failed the
type check with TS2353. A seat config is now an AgencySeatConfig:
BaseAgentConfig plus the runtime and cognition options of agent(). The
strategies build a config seat with agent() and pass every field through, so
such a seat is served by a GMI; the type was the gap. AgencySeatConfig is
exported from the package root. A BaseAgentConfig is still a valid seat.
…er first With hitl.approvals.beforeTool set, agency() adds __approvalGate to the options of every call it makes to a seat, and gmi() rejects any per-call option outside its list, so a GMI seat fails every call of a gated agency. The cases drive that input with a tool the model calls: an approval runs the tool after the handler is asked, and a denial skips the tool and the model is told why, as on agent()'s own path. Both fail until gmi() takes the gate.
…e its tools gmi() takes the __approvalGate that agency() passes with each call to a member, and runs it as generateText does: after onBeforeToolExecution, on the arguments the hook left, for a tool the orchestrator has. Anything but the exact approval skips the tool and the model is told why; the call's record carries 'Skipped: <reason>'. The agency and GMI guides say so, in place of the sentence that a GMI member's calls throw in such an agency.
…n both runtimes agent().generate() checks its answer against the sources verifyCitations retrieves and attaches result.grounding. gmi() never reads the option: its generate() returns no grounding and logs nothing. The case runs the same input on both runtimes; the GMI one fails until gmi() runs the check.
gmi()'s generate() checks its answer against the sources verifyCitations retrieves for the prompt and sets result.grounding, as agent().generate() does, with the same retrieve and embed functions. The check moves from agent.ts into runtime/citationVerification.ts so both runtimes call one implementation. The GMI guide says so.
…top construction
agent() counts a config that sets only enabled: false as unset, so it neither
warns nor fails. gmi() counts any non-empty object as set and throws at
construction for voice: { enabled: false }. The case builds a GMI agent with
all three switched off and expects it to answer; it fails until gmi() counts
them as agent() does.
…false is unset gmi() checks voice, avatar and channels with the test agent() uses for its deferred options (isMeaningfullyConfigured, now exported from the diagnostics module), so a config switched off with enabled: false constructs, as it does without runtime: 'gmi'. The GMI guide says so.
… the closed session The GMI guide says the next agent.session(id) after close() starts empty. That holds for the history only: with cognitive memory on, the closed session's traces stay under the session id, and a session opened again with that id recalls them, so a host that reuses a session id across people leaks the first person's facts. The case closes a session that stored a fact and opens the same id again: its prompt must not carry the fact. Opened again with the same user id, the user's fact is recalled.
…y scope of its own A GMI session files the user's messages under its user id and the replies under its session id, and recalls both. A session opened again with the id of a closed one recalled the closed session's traces, though its history starts empty. Each opening of an id now runs under a scope id of its own: the session id the first time the agent opens it, a new id each later time. The GMI runs the session's turns under that scope id, and under it as the user id when the caller names no user, so a reopened id recalls nothing of the closed session; a user id the caller passes again is shared as before. session.id, usage, the ledger and error messages keep the session id. The GMI guide says which id scopes a session's memory.
… 'gmi' agent() without runtime: 'gmi' reads no part of the memory option, yet the capability contract rates memory partially enforced on the agent surface, so the deferred-capability warning never names it and nothing tells the caller. The case passes the review's memory config to a plain agent() and expects one warning that names memory and runtime: 'gmi'.
…n agent surface agent() without runtime: 'gmi' reads no part of memory, so the contract rates memory accepted_but_deferred on the agent surface instead of partially enforced. The deferred-capability warning now names it, in a sentence of its own that says agent() applies memory only with runtime: 'gmi', since agency() does not apply it either. The capability table in docs/API_PATHS.md follows the contract, and the page says that a voice, avatar or channels config that sets only enabled: false does not throw on the GMI path.
…elds each path reads
The case pinned types: ['episodic', 'semantic'] in the high-level guide and
working: { enabled: true } in the example, strings the pages keep only to say
that no path reads them: it stayed green if a plain agent() example passed
memory again, and went red if the explanation was cut. It now pins the
guide's runtime: 'gmi' memory example and the sentence that names the
MemoryConfig fields each path reads, and fails on any agent() call in the
README, the high-level guide and example, the GMI guide and the HEXACO
personality page that sets memory without runtime: 'gmi'. The HEXACO page's
quickstart does, so the case fails until that page is fixed.
…urface names its path
The quickstart is an agent({ runtime: 'gmi' }) with memory on, the agent()
path that reads both personality and memory. The paragraph after it names,
per surface, the paths it runs on: the prompt directives on agent() with or
without runtime: 'gmi'; encoding strength, working-memory capacity and
prompt formatting in a CognitiveMemoryManager built with the traits; the
observer and reflector only in a manager whose config gives them a model
invoker, which the GMI path's manager does not. The buildPersonalityDescription
source line follows the move of the citation check out of agent.ts.
…r the history The GMI guide said the prompt engine truncates the history to its budget for the model's context window. It now states the rule applyTokenBudget applies: the history gets 35 percent of the serving model's window (8,192 tokens when the window is unknown); over that budget, the turn being answered stays whole and the earlier messages are dropped oldest first, with no summary in their place; the store keeps them, and nothing tells the caller. A 60,000-token history on a 128,000-token model reaches the model as about its newest 45,000, where the legacy path sends all of it or throws ContextWindowExceededError.
The section listed what a GMI runs (guardrails, a self-reflection metaprompt,
the self-modification tools) right after saying that agent({ runtime: 'gmi' })
sessions are GMIs, and excluded only guardrails, retrieval and channels from
that path. A GMI built from agent options carries the five preset event
metaprompts and nothing else of the metaprompt set, and its tool orchestrator
registers no self-improvement tools. The list now reads as the full runtime's,
and the paragraph on agent({ runtime: 'gmi' }) names what its GMIs run (the
reasoning trace, mood-weighted memory, sentiment tracking with the five event
metaprompts) and what does not run there.
- A session id opened again after close() runs its turn, its tools and its user context under the id the caller opened; only cognitive memory uses the reopened session's own scope (metadata.memoryScope, read by the memory bridge alone).
- OpenRouter keeps the usage of the line it is reading when the signal aborts after a normal finish, so the request's bill is counted.
- schemaInPayload reflects the request that answered: after OpenRouter's json_object retry, a structured reply reports prompt_only.
- On a fallback hop, the schema instruction goes into the messages before onBeforeGeneration, as on hop 0, so a hook that drops it drops it on every hop.
- The background read after an abort is bounded: it stops at the provider's abort or error chunk or after 32 chunks, and closes the generator.
- A regression pin for the late-usage subtraction and the warning without an onLateUsage listener.
- A voice, avatar or channels config with enabled: true counts as configured, whatever its other fields, so gmi() throws at construction for it; { enabled: false } still constructs. agent() counts its deferred options with the same function, so its warning also names such a config.
- The set of opened session ids is bounded: an agent without cognitive memory keeps none, and agent.close() empties it when it starts a new memory. session.close() keeps its id, since that entry gives the id's next opening a memory scope of its own.
Follow-ups to #193 and #199.
## [0.13.23](v0.13.22...v0.13.23) (2026-10-10) ### fix * **gmi:** follow-ups from the reviews of #193 and #199 (#217) ([2bacb69](2bacb69)) * **gmi:** manager shutdown waits for creations in flight, bounds each GMI and runs once (#222) ([d99b126](d99b126)) * **images:** the untrusted fetch settles on a protocol upgrade, and four review follow-ups (#227) ([9efb4b5](9efb4b5)) * **vision:** the TrOCR and Florence-2 tiers get a Buffer image as a Blob (#229) ([7fe444a](7fe444a))
…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
Follow-ups from the review of #192, the guide to
gmi()andagent({ runtime: 'gmi' }). Each code fix landed after a regression test that CI ran red for the reason the test names; each docs change was read against the code on master.Code:
runtimeandcognition(AgencySeatConfig, exported), so the seat the guides write type-checks, andruntime: 'gmi'makes it a GMI. Test ad82a13, fix 277c7a9.hitl.approvals.beforeTool):gmi()takes the agency's approval gate as a per-call option and asks it before a tool runs, afteronBeforeToolExecution, asgenerateTextdoes; a call it does not approve is skipped and the model is told why. docs/GMI.md and docs/orchestration/AGENCY_API.md follow. Test 507bc66, fix b4c7ec5.verifyCitationsruns on the GMI path:generate()setsresult.groundingasagent().generate()does, through the same function, moved tosrc/api/runtime/citationVerification.ts. Test 3e8c811, fix 752dd2c.gmi()treats avoice,avatarorchannelsconfig that sets onlyenabled: falseas unset, asagent()'s deferred-option check does. Test ada1900, fix 5e74bcc.session.close()gets a memory scope of its own, so it recalls nothing the closed session filed; a session opened with an explicituserIdstill recalls that user's traces. The session'sid, its usage totals and its ledger records keep the id the caller passed. Test cc12749, fix 89d3a8e.memoryaccepted_but_deferredon the plainagent()surface, andagent({ memory })withoutruntime: 'gmi'warns that the option is not applied, namingruntime: 'gmi'; docs/API_PATHS.md follows the contract. Test 5393ba0, fix 14267d0.runtime: 'gmi'memory example and the sentence naming theMemoryConfigfields each path reads, and fails on anyagent({ ... })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 passesmemorywithoutruntime: 'gmi'(1003137). Its first run was green: docs: sixth round of audit follow-ups to the guides #195, merged to master during that run, had already takenmemoryout of the HEXACO quickstart, the one such call, and CI tests the merge ref.Docs:
docs/memory/HEXACO_PERSONALITY.md: the quickstart runs onruntime: 'gmi'with cognitive memory, and each of the five surfaces a personality reaches names the paths it runs on (ec0645c).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 (5e9e0b1).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) (cd77b52).Linked issues
Follow-ups to #192. The silent history truncation of item 9 is filed as #206 (no summary of the dropped turns, nothing on the result that reports them); this pull request documents it and leaves the fix to that issue.
Type of change
How this was verified
CI on this pull request. Each regression test was pushed first and its run read red for the reason the test names: 37957590600 (item 1, Type check TS2353 on the seat config), 37962463781 (item 2, the gate option rejected), 37963126313 (item 3, no grounding on the GMI case only), 37963711159 (item 4, the voice error), 37964288671 (item 5, the reopened session's prompt carried the closed session's fact), 37964833435 (item 6, no warning). Each fix was then pushed and read green: 37962098288, 37963010309, 37963669079, 37964264236, 37964808629, 37965357248. Item 7: 37965384672. Docs: 37966090730, 37967605780 and 37968006836, with the Links workflow green on each. After the merge of master at 31219f0: 37969173788.
Migration notes
None. Every change keeps the existing call signatures: a widened seat type, a new exported type, and options that keep their defaults.
agent({ memory })withoutruntime: 'gmi'logs one warning, where it logged none before.Checklist
Summary by Sourcery
Align GMI runtime behavior, types, tests, and documentation with the reviewed guide, including memory semantics, agency approvals, citation grounding, and session isolation.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores:
Summary by CodeRabbit
AgencySeatConfigis available through the package’s public exports.