Skip to content

Default Agent Builder observational memory to OpenAI gpt-5.4-mini#18650

Open
YujohnNattrass wants to merge 1 commit into
mainfrom
builder-om-default-update
Open

Default Agent Builder observational memory to OpenAI gpt-5.4-mini#18650
YujohnNattrass wants to merge 1 commit into
mainfrom
builder-om-default-update

Conversation

@YujohnNattrass

@YujohnNattrass YujohnNattrass commented Jun 29, 2026

Copy link
Copy Markdown
Member

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

  • Builder agents continue to store `{ observationalMemory: true }` in their record. Nothing about the stored shape changes, so there is no data migration.
  • The concrete model is resolved at instantiation time, from a single constant. Changing the default later automatically applies to all existing Builder agents the next time they are instantiated.
  • An explicit `observationalMemory.model` (set by a user on create, or by an admin via `configuration.agent.memory`) always wins over the Builder default.
  • Core (non-builder) agents are unaffected and keep `google/gemini-2.5-flash`.

Resolution order

  1. User-provided `observationalMemory` object on create → persisted, wins.
  2. Admin `configuration.agent.memory.observationalMemory.model` → persisted, wins.
  3. Neither → stored `true` → resolves to `openai/gpt-5.4-mini`.

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

  • `pnpm --filter ./packages/editor test` — full editor suite passes (502 passing). Added two focused cases:
    • stored `{ observationalMemory: true }` resolves to `openai/gpt-5.4-mini`.
    • an explicit `observationalMemory.model` passes through unchanged.
  • `pnpm --filter ./packages/editor typecheck` — clean.
  • Prettier check on changed files — clean.

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

  • Switched the default observational memory model for Agent Builder agents to openai/gpt-5.4-mini.
  • Kept non-Builder/core agents unchanged.
  • Preserved explicit observationalMemory.model settings from users or admins.
  • Kept stored { observationalMemory: true } records compatible by resolving the model at runtime.
  • Documented that Builder observational memory now requires OPENAI_API_KEY.
  • Updated tests to cover the new default resolution and explicit model passthrough.

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-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ddd200e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@mastra/editor Patch

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

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mastra-docs-1.x Ready Ready Preview, Comment Jun 29, 2026 11:08pm
mastra-playground-ui Ready Ready Preview, Comment Jun 29, 2026 11:08pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
mastra-studio-preview Ignored Ignored Jun 29, 2026 11:08pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Builder agent default observational memory model is changed from __GATEWAY_GOOGLE_MODEL__ to __GATEWAY_OPENAI_MODEL_MINI__ (openai/gpt-5.4-mini). In resolveStoredMemory, a boolean true value for observationalMemory is now expanded into { model: BUILDER_DEFAULT_OM_MODEL }. Tests and documentation are updated accordingly.

Changes

Builder Observational Memory Default Model

Layer / File(s) Summary
resolveStoredMemory coercion with new default
packages/editor/src/namespaces/agent.ts
Adds BUILDER_DEFAULT_OM_MODEL = 'openai/gpt-5.4-mini' constant and changes resolveStoredMemory to convert observationalMemory === true into { model: BUILDER_DEFAULT_OM_MODEL } instead of forwarding the boolean.
Updated and new observational memory tests
packages/editor/src/editor.test.ts
Reworks the existing default test to assert agent.getMemory() returns observationalMemory.model === 'openai/gpt-5.4-mini'; adds a new test verifying explicit model values are preserved unchanged.
Docs and changeset
docs/src/content/en/docs/agent-builder/memory.mdx, .changeset/shaky-dingos-prove.md
Updates observational memory docs to reflect the new OpenAI default model and OPENAI_API_KEY requirement, adds a note that core agents are unaffected, and adds the patch changeset entry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

complexity: low, tests: green ✅

Suggested reviewers

  • wardpeet
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: switching Agent Builder observational memory to OpenAI gpt-5.4-mini.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch builder-om-default-update

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Jun 29, 2026
@dane-ai-mastra dane-ai-mastra Bot added the complexity: low Low-complexity PR label Jun 29, 2026
@dane-ai-mastra

Copy link
Copy Markdown
Contributor

PR triage

Linked issue check skipped for core contributor @YujohnNattrass.


PR complexity score

Factor Value Score impact
Files changed 4 +8
Lines changed 73 +3
Author merged PRs 270 -20
Test files changed Yes -10
Final score -19

Applied label: complexity: low


Changed test gate

Changed Test Gate is pending. The Changed Test Gate / changed-tests check will update the test label when it completes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c607ece and ddd200e.

📒 Files selected for processing (4)
  • .changeset/shaky-dingos-prove.md
  • docs/src/content/en/docs/agent-builder/memory.mdx
  • packages/editor/src/editor.test.ts
  • packages/editor/src/namespaces/agent.ts

Comment on lines +5 to +17
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__' } },
},
},
},
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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

Comment on lines +1726 to +1762

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');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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

Comment on lines +1461 to +1466
// 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@dane-ai-mastra dane-ai-mastra Bot added the tests: green ✅ Changed tests failed against base as expected label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: low Low-complexity PR Documentation Improvements or additions to documentation tests: green ✅ Changed tests failed against base as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant