Default Agent Builder observational memory to OpenAI gpt-5.4-mini#18650
Default Agent Builder observational memory to OpenAI gpt-5.4-mini#18650YujohnNattrass wants to merge 1 commit into
Conversation
Agent Builder agents created with observational memory enabled previously
inherited the framework-wide default model (google/gemini-2.5-flash). The
Builder is an Enterprise feature whose default should be OpenAI-based, so
these agents now resolve their observer/reflector to openai/gpt-5.4-mini.
The model is resolved at instantiation time in resolveStoredMemory rather
than baked into stored records: agents continue to persist
{ observationalMemory: true }, and the model resolves from a single
constant on every instantiation. This lets the default change later
without any data migration. Core (non-builder) agents are unaffected, and
an explicit observationalMemory.model (user or admin) still wins.
Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
🦋 Changeset detectedLatest commit: ddd200e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
WalkthroughThe Builder agent default observational memory model is changed from ChangesBuilder Observational Memory Default Model
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
PR triageLinked issue check skipped for core contributor @YujohnNattrass. PR complexity score
Applied label: Changed test gateChanged Test Gate is pending. The |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/shaky-dingos-prove.md:
- Around line 5-17: The changeset entry uses docs-only model tokens that will be
published verbatim in release notes, so rewrite the wording in the changeset
content to use plain, developer-facing model names instead of
__GATEWAY_OPENAI_MODEL_MINI__ and __GATEWAY_GOOGLE_MODEL__. Update the affected
text in the changeset so it still mentions the Builder agent default change and
OPENAI_API_KEY requirement, but avoids any __TOKEN__ placeholders.
In `@packages/editor/src/editor.test.ts`:
- Around line 1726-1762: These observational-memory assertions belong with the
source they validate, not in the broad editor test file. Move the new cases from
editor.test.ts to the test suite colocated with the agent namespace
implementation in packages/editor/src/namespaces/agent.ts, and keep the coverage
focused on resolveStoredMemory() and the agent memory config behavior there.
Ensure the moved tests still verify both the builder default merge and the
explicit observationalMemory model passthrough.
In `@packages/editor/src/namespaces/agent.ts`:
- Around line 1461-1466: The Builder default coercion for observationalMemory is
being applied inside resolveStoredMemory(), which affects all stored agents with
observationalMemory: true instead of only Builder-created ones. Move this
mapping to the Builder-specific defaulting path, or gate it on explicit Builder
provenance metadata before hydration, so resolveStoredMemory() continues to
preserve stored non-Builder agent config untouched.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6955780d-ed11-4b3a-8344-9123b97a4874
📒 Files selected for processing (4)
.changeset/shaky-dingos-prove.mddocs/src/content/en/docs/agent-builder/memory.mdxpackages/editor/src/editor.test.tspackages/editor/src/namespaces/agent.ts
| Agent Builder agents now default observational memory to `__GATEWAY_OPENAI_MODEL_MINI__` instead of `__GATEWAY_GOOGLE_MODEL__`. Set `OPENAI_API_KEY` in any environment where Builder agents run. Core (non-builder) agents are unaffected and keep the framework default. Admins can still override the model: | ||
|
|
||
| ```typescript | ||
| new MastraEditor({ | ||
| builder: { | ||
| enabled: true, | ||
| configuration: { | ||
| agent: { | ||
| memory: { observationalMemory: { model: '__GATEWAY_OPENAI_MODEL_MINI__' } }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Don’t use docs-only model tokens in a changeset.
.changeset entries are published as raw markdown, so __GATEWAY_OPENAI_MODEL_MINI__ and __GATEWAY_GOOGLE_MODEL__ will show up verbatim in release notes instead of expanding. Replace them with plain model names when you rewrite this entry. As per path instructions, changesets should stay clear and developer-facing, and based on learnings, __TOKEN__ placeholders are not processed in .changeset files.
potential_issue
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.changeset/shaky-dingos-prove.md around lines 5 - 17, The changeset entry
uses docs-only model tokens that will be published verbatim in release notes, so
rewrite the wording in the changeset content to use plain, developer-facing
model names instead of __GATEWAY_OPENAI_MODEL_MINI__ and
__GATEWAY_GOOGLE_MODEL__. Update the affected text in the changeset so it still
mentions the Builder agent default change and OPENAI_API_KEY requirement, but
avoids any __TOKEN__ placeholders.
Sources: Path instructions, Learnings
|
|
||
| const memory = await agent.getMemory(); | ||
| const om = memory?.getConfig().observationalMemory; | ||
| expect(typeof om).not.toBe('boolean'); | ||
| if (typeof om !== 'boolean' && om) { | ||
| expect(om.model).toBe('openai/gpt-5.4-mini'); | ||
| } | ||
| }); | ||
|
|
||
| it('passes an explicit observational memory model through unchanged (builder default does not override)', async () => { | ||
| const storage = new InMemoryStore(); | ||
| const editor = new MastraEditor({ | ||
| builder: { | ||
| enabled: true, | ||
| configuration: { | ||
| agent: { memory: { observationalMemory: { model: 'openai/gpt-4o-mini' } } }, | ||
| }, | ||
| }, | ||
| }); | ||
| new Mastra({ storage, editor }); | ||
|
|
||
| const agent = await editor.agent.create({ | ||
| id: 'test-agent-explicit-om-model', | ||
| name: 'Test Agent', | ||
| instructions: 'Test', | ||
| model: { provider: 'openai', name: 'gpt-4' }, | ||
| }); | ||
|
|
||
| const rawConfig = agent.toRawConfig?.(); | ||
| expect(rawConfig?.memory).toEqual({ observationalMemory: { model: 'openai/gpt-4o-mini' } }); | ||
|
|
||
| const memory = await agent.getMemory(); | ||
| const om = memory?.getConfig().observationalMemory; | ||
| expect(typeof om).not.toBe('boolean'); | ||
| if (typeof om !== 'boolean' && om) { | ||
| expect(om.model).toBe('openai/gpt-4o-mini'); | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Move these observational-memory cases next to packages/editor/src/namespaces/agent.ts.
These assertions target resolveStoredMemory() behavior in the namespace implementation, but the repo rule for Vitest is to colocate tests with their source instead of extending the catch-all packages/editor/src/editor.test.ts. As per coding guidelines, "**/*.{test,spec}.{ts,tsx,js,jsx}: Vitest tests should be colocated with their source."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/editor/src/editor.test.ts` around lines 1726 - 1762, These
observational-memory assertions belong with the source they validate, not in the
broad editor test file. Move the new cases from editor.test.ts to the test suite
colocated with the agent namespace implementation in
packages/editor/src/namespaces/agent.ts, and keep the coverage focused on
resolveStoredMemory() and the agent memory config behavior there. Ensure the
moved tests still verify both the builder default merge and the explicit
observationalMemory model passthrough.
Source: Coding guidelines
| // A literal `true` means "use the builder default OM model"; an explicit | ||
| // object (user/admin choice) passes through untouched. | ||
| observationalMemory: | ||
| memoryConfig.observationalMemory === true | ||
| ? { model: BUILDER_DEFAULT_OM_MODEL } | ||
| : memoryConfig.observationalMemory, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
This changes the default for every stored observationalMemory: true agent, not just Builder-created ones.
resolveStoredMemory() is the shared hydration path for stored agents, and there’s no builder provenance in memoryConfig here. Any stored or cloned agent that serialized observationalMemory: true will now rehydrate with openai/gpt-5.4-mini, which contradicts the PR’s “Builder-only” scope and silently changes existing non-Builder agents on their next instantiation. Apply this coercion at the Builder-defaulting layer, or gate it on explicit Builder metadata before calling resolveStoredMemory().
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/editor/src/namespaces/agent.ts` around lines 1461 - 1466, The
Builder default coercion for observationalMemory is being applied inside
resolveStoredMemory(), which affects all stored agents with observationalMemory:
true instead of only Builder-created ones. Move this mapping to the
Builder-specific defaulting path, or gate it on explicit Builder provenance
metadata before hydration, so resolveStoredMemory() continues to preserve stored
non-Builder agent config untouched.
Summary
Agents created through the Agent Builder now default their observational memory (the Observer and Reflector models) to `openai/gpt-5.4-mini` instead of inheriting the framework-wide default `google/gemini-2.5-flash`.
The Agent Builder is an Enterprise feature, and its observational-memory default should be OpenAI-based. This change makes Builder-created agents use an OpenAI model by default while leaving every other agent in the framework untouched.
How it works
Resolution order
Operational note
Builder observational memory now requires `OPENAI_API_KEY` at runtime (previously `GOOGLE_API_KEY`). This is documented and called out in the changeset.
Test plan
Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) noreply@mastra.ai
ELI5: This change makes Builder-created agents use a new default “memory brain” model, so they can remember things with OpenAI instead of Google. If someone already picked a specific model, that choice still wins.
Summary
openai/gpt-5.4-mini.observationalMemory.modelsettings from users or admins.{ observationalMemory: true }records compatible by resolving the model at runtime.OPENAI_API_KEY.