Skip to content

Show resolved agent authors in the agent-builder list and detail#17205

Merged
mfrachet merged 10 commits into
mainfrom
feat/agent-author-enrichment
Jun 8, 2026
Merged

Show resolved agent authors in the agent-builder list and detail#17205
mfrachet merged 10 commits into
mainfrom
feat/agent-author-enrichment

Conversation

@mfrachet

@mfrachet mfrachet commented May 28, 2026

Copy link
Copy Markdown
Contributor
CleanShot 2026-05-28 at 10 34 01@2x

What this ships

Today the agent-builder agent list shows each agent's avatar, name, description, and visibility — but not who authored it. The records carry an authorId (resolved at write time from the caller's auth context), but the API never resolved that ID into a human-readable author. This PR closes that gap end-to-end.

When an auth provider is configured, each row in the agent list (and the agent detail response) now includes a resolved author object with the user's id, name, email, and avatar — and the playground renders it under the agent name.

How it works

  1. Core authIUserProvider gains an optional getUsers(userIds) batch hook. CompositeAuthProvider and SimpleAuthProvider implement it. Providers that don't override it still work via per-id getUser fallback.
  2. Server enrichment — A new author-enrichment helper mirrors the existing favorites-enrichment pattern: it dedupes author IDs on the page, calls the provider's batch method when available (otherwise fans out getUser in parallel), and returns a Map<authorId, ResolvedAuthor>. The stored-agents list and get handlers attach author to each response record.
  3. Wire formatstoredAgentSchema exposes an optional author: { id, name?, email?, avatarUrl? }. The client SDK type StoredAgentResponse is extended to match. The field is fully additive and optional everywhere, so existing clients keep working unchanged.
  4. Playground UI — The agent-builder list row now renders a small author badge (avatar + name/email/id fallback chain) below the description. The agent avatar itself is bumped to lg so the row hierarchy reads cleanly with the new author block.

Backwards compatibility

  • author is optional at every layer (Zod, SDK type, UI). No existing test was modified.
  • If there's no auth provider, or the provider can't resolve an ID, the field is simply omitted — no 500s, no UI shift.
  • Lookups are bounded: deduped per request, batched when possible, and per-id failures don't fail the list.

Test plan

  • Core — new composite-auth.test.ts; extended simple-auth.test.ts. Covers batch lookup ordering, provider fallthrough, throwing providers, unknown IDs.
  • Server — new author-enrichment.test.ts (14 cases: batch vs per-id, dedup, null/empty/undefined IDs, provider throws, no auth provider, non-IUserProvider provider, attachAuthor field passthrough). New handler integration cases (list with enrichment, dedup verified via spy, favorited-only branch, no auth provider parity, get-by-id, per-id failure resilience).
  • Client SDK — new author roundtrip cases on details() and listStoredAgents().
  • Playground — new component tests (author with name, author with email-only, authorId fallback, no-author-omitted) and an MSW page test that drives the real @mastra/client-js + React Query stack against GET /api/stored/agents returning fixtures with author.

Local verification:

pnpm --filter ./packages/core check
pnpm --filter ./packages/server test           # 1666 pass
pnpm --filter @mastra/client-js test           # 485 pass
pnpm --filter ./packages/playground typecheck  # clean
pnpm --filter ./packages/playground build      # clean

Manual smoke checks

  • Project with a configured auth provider + ≥2 users: created stored agents under different users, then visited /agent-builder/agents and /agent-builder/library — author renders per row and on the detail page.
  • Project with no auth provider configured: list still loads, rows render without an author block, no console errors.

ELI5

The server now looks up the human who created each stored agent and attaches a small author object (id plus optional name/email/avatar) to agent records when available, and the UI shows that as an author badge—if author info is missing nothing breaks.


Overview

Adds optional, end-to-end author enrichment for stored agents: stored-agent records retain authorId, the server can resolve those IDs into a public-safe ResolvedAuthor (id, optional name, email, avatarUrl) and attach it to list and detail responses, and the playground displays the resolved author. Enrichment is deduped, prefers batched provider lookups, falls back to per-id lookups, and degrades gracefully when no auth provider or resolution fails.


Key Changes

Core (packages/core)

  • IUserProvider: optional getUsers?(userIds: string[]): Promise<Array<TUser | null>> added for batched lookups.
  • CompositeAuth:
    • Adds getUsers(userIds) when any inner provider supports batched lookups; otherwise disables the method.
    • Resolves each ID by preferring batched provider.getUsers or falling back to per-id getUser, skipping providers that error for a given id.
  • SimpleAuth: implements getUsers with positional/null semantics, preserves duplicates and empty-input behavior.

Server (packages/server)

  • New author-enrichment module:
    • Exports ResolvedAuthor type and functions prepareAuthorEnrichment(mastra, ctx, authorIds) and attachAuthor(record, authors).
    • Deduplicates author IDs per request, prefers provider.getUsers, falls back to parallel provider.getUser calls, projects provider User → ResolvedAuthor, and returns Map<id, ResolvedAuthor> or null when enrichment is unavailable.
    • Handles errors: per-id exceptions treated as unresolved; batch failures yield empty enrichment (not crash); absent or incompatible auth provider yields null.
    • Tightened provider guard to avoid runtime crash when falling back to per-id lookups.
  • Stored-agents handlers:
    • GET /stored/agents and GET /stored/agents/:storedAgentId call prepareAuthorEnrichment and attachAuthor so responses may include optional author fields across favorite/visibility branches.
  • Schema: added resolvedAuthorSchema and extended storedAgentSchema with optional author field.

Client SDK (client-sdks/client-js)

  • Added ResolvedAuthor interface and extended StoredAgentResponse with optional author?: ResolvedAuthor.
  • Generated route types updated to include optional author in stored-agent responses.
  • Tests: added Vitest cases for list and details round-trip behavior with optional author.

Playground UI (packages/playground)

  • Agent list/detail:
    • Added getAuthorLabel helper and AuthorBadge component (avatar + label) with responsive placement.
    • Agent avatar size increased to "lg" and layout adjusted to accommodate badge.
  • Tests:
    • Component tests for author rendering (name → email → id fallback; omission when absent).
    • Page-level test for agent list rendering resolved author fields.

Technical Details

  • Deduplication & batching: author IDs deduped per request; prefer provider.getUsers; fallback uses Promise.all over provider.getUser(id) with per-id error handling.
  • Mapping: provider User objects are projected to a public-safe ResolvedAuthor (id, optional name, email, avatarUrl).
  • Error handling & compatibility: per-id errors treated as unresolved; batched lookup failures degrade to empty enrichment; missing/non-compatible auth provider returns null (no authors attached). author is optional at all layers; authorId preserved.

Testing

Comprehensive tests added across layers:

  • Core: CompositeAuth and SimpleAuth getUsers behavior and edge cases.
  • Server: author-enrichment unit tests (dedupe, batch vs per-id, error resilience, mapping) and stored-agents handler tests (list/detail, dedupe, missing provider, partial failures).
  • Client SDK: tests for stored-agent list and detail preserving optional author field.
  • Playground: component and page tests validating author badge rendering across scenarios.

Stored agents already track an authorId, but the API never resolved it
back into a human-readable identity, so the playground could only show
the raw ID. This wires up server-side author enrichment from the auth
provider through to the agent-builder UI.

- core: add optional getUsers(userIds) batch hook to IUserProvider,
  with implementations on CompositeAuthProvider and SimpleAuthProvider
- server: new author-enrichment helper (dedupes IDs, prefers batch
  lookup, falls back to per-id getUser, soft-gated on auth provider)
  wired into the stored-agents list and get handlers
- schema/SDK: add optional author { id, name?, email?, avatarUrl? }
  on StoredAgentResponse, fully additive on the wire
- playground: render the author next to each agent row, and enlarge
  the agent avatar so the row hierarchy reads cleanly

No existing tests modified; new coverage at every layer (core auth,
server helper + handler integration, client-js roundtrip, playground
component + MSW page test).

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-7) <noreply@mastra.ai>
@mfrachet mfrachet requested a review from YujohnNattrass May 28, 2026 08:29
@vercel

vercel Bot commented May 28, 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 8, 2026 8:27am
mastra-playground-ui Ready Ready Preview, Comment Jun 8, 2026 8:27am

Request Review

@dane-ai-mastra

dane-ai-mastra Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

PR triage

Linked issue check skipped for core contributor @mfrachet.


PR complexity score

Factor Value Score impact
Files changed 20 +40
Lines changed 1025 +60
Author merged PRs 411 -20
Test files changed Yes -10
Final score 70

Applied label: complexity: critical


Changed test gate

Changed tests failed against the base branch as expected.

Label: tests: green ✅

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds optional batch user lookup to auth providers and a server-side author enrichment flow (prepareAuthorEnrichment, attachAuthor) that resolves authors for stored-agent list/get handlers; updates schemas, client types/tests, and UI components to accept and render resolved author data.

Changes

Author Enrichment for Stored Agents

Layer / File(s) Summary
Release documentation
.changeset/*.md
Changesets declare version bumps and note the new optional IUserProvider.getUsers and author enrichment for stored-agent responses.
Client SDK Author Field Tests & Types
client-sdks/client-js/src/resources/stored-agent.test.ts, client-sdks/client-js/src/types.ts, client-sdks/client-js/src/route-types.generated.ts
Client tests verify listStoredAgents and getStoredAgent(...).details() round-trip optional author objects; types/generator output add ResolvedAuthor and optional author on responses.
Auth Provider Interface Enhancement
packages/core/src/auth/interfaces/user.ts
IUserProvider adds optional getUsers(userIds) returning positionally-aligned `User
Auth Provider Implementations & Tests
packages/core/src/server/simple-auth.ts, packages/core/src/server/composite-auth.ts, packages/core/src/server/*.test.ts
SimpleAuth.getUsers implemented; CompositeAuth exposes getUsers or disables it when unsupported by inner providers. Tests cover ordering, nulls, errors, feature-detect behavior, and empty-input.
Server Author Enrichment Module
packages/server/src/server/handlers/author-enrichment.ts, packages/server/src/server/handlers/author-enrichment.test.ts
Exports ResolvedAuthor, prepareAuthorEnrichment (dedupe, batch getUsers or per-id fallback, projection, error handling) and attachAuthor for conditional enrichment of records; tests validate batching, dedupe, and error handling.
Stored Agents Schema Update
packages/server/src/server/schemas/stored-agents.ts
Adds resolvedAuthorSchema and an optional author field to storedAgentSchema response objects.
Stored Agents Handler Integration
packages/server/src/server/handlers/stored-agents.ts, packages/server/src/server/handlers/stored-agents.test.ts
List and GET handlers collect authorIds, call prepareAuthorEnrichment, and apply attachAuthor to responses; tests validate deduping, omission when unresolved or no provider, and correct attachment.
UI Author Badge Component and Integration
packages/playground/src/domains/agent-builder/components/agent-list/agent-builder-list.tsx, tests
Adds AuthorBadge, getAuthorLabel fallback (name→email→id), responsive badge rendering, larger avatar sizing, and tests for render cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • YujohnNattrass
  • CalebBarnes
  • damien-schneider
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enriching and displaying resolved agent authors in the agent-builder list and detail views, which aligns with the comprehensive set of changes across core, server, client SDK, and playground.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-author-enrichment

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

Move the resolved author from a sub-block under the description to a
sibling column between the description and the favorite button on
desktop, so the row reads avatar | name+description | author | favorite
in one horizontal sweep. On mobile we still stack the author under the
description (above the favorite button) where vertical layout is
expected.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-7) <noreply@mastra.ai>
@changeset-bot

changeset-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6f601c7

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

This PR includes changesets to release 20 packages
Name Type
@mastra/server Minor
@mastra/client-js Minor
@mastra/core Minor
@mastra/deployer Minor
@mastra/express Patch
@mastra/fastify Patch
@mastra/hono Patch
@mastra/koa Patch
@mastra/nestjs Patch
@mastra/playground-ui Major
@internal/playground Patch
@mastra/react Patch
mastracode Patch
@mastra/mcp-docs-server Patch
@mastra/opencode Patch
@mastra/longmemeval Patch
@mastra/temporal Patch
mastra Patch
@mastra/deployer-cloud Minor
create-mastra 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 temporarily deployed to Preview – mastra-docs-1.x May 28, 2026 08:31 Inactive
@dane-ai-mastra dane-ai-mastra Bot added the tests: failing ❌ Changed tests passed against base label May 28, 2026
@dane-ai-mastra dane-ai-mastra Bot added tests: green ✅ Changed tests failed against base as expected and removed tests: failing ❌ Changed tests passed against base labels May 28, 2026

@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: 7

🤖 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/bright-steaks-count.md:
- Around line 2-5: The changeset frontmatter lists '`@mastra/server`',
'`@mastra/client-js`', and '`@mastra/core`' but the body only documents server
behavior; either limit the frontmatter to '`@mastra/server`' or expand the body to
include explicit end-user outcomes for '`@mastra/client-js`' and '`@mastra/core`',
or split into separate changeset files (one per package) so each file's
description applies only to the packages named; update the frontmatter and/or
file body accordingly and ensure each changeset follows the guideline that
description content matches the listed package(s).

In @.changeset/hungry-falcons-go.md:
- Around line 2-4: The changeset frontmatter lists three packages but the
description only documents a core interface addition; update the entry so it is
consistent by either removing '`@mastra/client-js`' and '`@mastra/server`' from the
frontmatter (leaving only '`@mastra/core`') or by expanding the description to
clearly state the user-facing changes introduced to '`@mastra/client-js`' and
'`@mastra/server`' (e.g., API surface, bugfixes, or internal dependency bumps) and
how they affect users; ensure the frontmatter package list and the prose
describe the same set of package changes and follow the changeset formatting
conventions.

In @.changeset/sweet-wasps-relax.md:
- Around line 2-4: The changeset frontmatter lists three packages
('`@mastra/client-js`', '`@mastra/server`', '`@mastra/core`') but the description only
documents a client-side API change; update the frontmatter to match the
documented scope by removing '`@mastra/server`' and '`@mastra/core`' (or
alternatively, expand the file description to include their corresponding
updates if they truly changed), ensuring the frontmatter exactly reflects the
packages described in the body.

In `@client-sdks/client-js/src/resources/stored-agent.test.ts`:
- Line 72: Tests in stored-agent.test.ts use the literal model name "gpt-4" in
model objects; replace those literal names with the repository's approved
placeholder token(s) from docs/src/plugins/remark-model-tokens/models.ts (e.g.,
the token constant used for example model names) wherever model: { provider:
'openai', name: 'gpt-4' } appears (including the instances in the test data
around the create/store agent tests and any other occurrences), ensuring you
import or reference the same placeholder token used across the repo so the test
data follows the placeholder convention.

In
`@packages/playground/src/domains/agent-builder/components/agent-list/__tests__/agent-builder-list.test.tsx`:
- Around line 188-276: The test fixtures in agent-builder-list.test.tsx use
hard-coded model objects (e.g., model: { provider: 'openai', name: 'gpt-4' })
inside the StoredAgentResponse fixtures passed to renderList; replace those
literal model provider/name strings with the corresponding placeholder tokens
exported from the repo's model tokens module (import the token constants and use
them for model.name and provider if available) so all test fixtures reference
the official placeholder tokens rather than hard-coded model names.

In `@packages/playground/src/pages/agent-builder/agents/__tests__/index.test.tsx`:
- Around line 223-224: The current assertions use screen.getByText('Alice Doe')
and screen.getByText('bob@example.com') which can throw when the same text
appears in multiple badge variants; change these to multi-match-safe assertions
by using screen.getAllByText('Alice Doe') and
screen.getAllByText('bob@example.com') and assert that the returned arrays have
length > 0 (or alternatively scope with a container and use
within(container).getByText) so the tests tolerate multiple matching elements.

In `@packages/server/src/server/handlers/author-enrichment.ts`:
- Around line 33-36: The type-guard isUserProvider currently only checks for
getCurrentUser but the code later calls provider.getUser (e.g., in the author
enrichment logic), so update the guard to require getUser as well; change
isUserProvider to check that (p as { getUser?: unknown }).getUser is a
'function' (in addition to any existing checks), and then ensure usage sites
like provider.getUser(...) are safe under this strengthened guard so TypeScript
and runtime won't crash.
🪄 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: 7054af19-7223-4a95-8ca1-54178313cd08

📥 Commits

Reviewing files that changed from the base of the PR and between 71a0550 and 888e2a7.

📒 Files selected for processing (19)
  • .changeset/bright-steaks-count.md
  • .changeset/hungry-falcons-go.md
  • .changeset/sweet-wasps-relax.md
  • client-sdks/client-js/src/resources/stored-agent.test.ts
  • client-sdks/client-js/src/route-types.generated.ts
  • client-sdks/client-js/src/types.ts
  • packages/core/src/auth/interfaces/user.ts
  • packages/core/src/server/composite-auth.test.ts
  • packages/core/src/server/composite-auth.ts
  • packages/core/src/server/simple-auth.test.ts
  • packages/core/src/server/simple-auth.ts
  • packages/playground/src/domains/agent-builder/components/agent-list/__tests__/agent-builder-list.test.tsx
  • packages/playground/src/domains/agent-builder/components/agent-list/agent-builder-list.tsx
  • packages/playground/src/pages/agent-builder/agents/__tests__/index.test.tsx
  • packages/server/src/server/handlers/author-enrichment.test.ts
  • packages/server/src/server/handlers/author-enrichment.ts
  • packages/server/src/server/handlers/stored-agents.test.ts
  • packages/server/src/server/handlers/stored-agents.ts
  • packages/server/src/server/schemas/stored-agents.ts

Comment on lines +2 to +5
'@mastra/server': minor
'@mastra/client-js': patch
'@mastra/core': patch
---

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Scope the frontmatter to the package(s) actually described in this entry.

This file’s body documents server behavior, but the frontmatter also bumps @mastra/client-js and @mastra/core, which are described in other changesets. Please keep this entry scoped to the package(s) it explains, or add explicit end-user outcomes for every listed package.

potential_issue

As per coding guidelines: “Check that the description inside the changeset file only applies to the packages listed in the frontmatter.” and “If the changes span multiple packages and each change is different from another, you MUST create multiple changeset files.”

🤖 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/bright-steaks-count.md around lines 2 - 5, The changeset
frontmatter lists '`@mastra/server`', '`@mastra/client-js`', and '`@mastra/core`' but
the body only documents server behavior; either limit the frontmatter to
'`@mastra/server`' or expand the body to include explicit end-user outcomes for
'`@mastra/client-js`' and '`@mastra/core`', or split into separate changeset files
(one per package) so each file's description applies only to the packages named;
update the frontmatter and/or file body accordingly and ensure each changeset
follows the guideline that description content matches the listed package(s).

Comment on lines +2 to +4
'@mastra/core': minor
'@mastra/client-js': patch
'@mastra/server': patch

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Frontmatter includes packages not covered by the description.

This entry describes a core interface addition, but it also bumps @mastra/client-js and @mastra/server without describing user-facing changes for those packages in this file. Narrow the frontmatter or expand the description so every listed package is represented.

potential_issue

As per coding guidelines: “Check that the description inside the changeset file only applies to the packages listed in the frontmatter.”

🤖 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/hungry-falcons-go.md around lines 2 - 4, The changeset
frontmatter lists three packages but the description only documents a core
interface addition; update the entry so it is consistent by either removing
'`@mastra/client-js`' and '`@mastra/server`' from the frontmatter (leaving only
'`@mastra/core`') or by expanding the description to clearly state the user-facing
changes introduced to '`@mastra/client-js`' and '`@mastra/server`' (e.g., API
surface, bugfixes, or internal dependency bumps) and how they affect users;
ensure the frontmatter package list and the prose describe the same set of
package changes and follow the changeset formatting conventions.

Comment on lines +2 to +4
'@mastra/client-js': minor
'@mastra/server': patch
'@mastra/core': patch

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align package bumps with the actual client-focused description.

This changeset describes a @mastra/client-js API addition, but the frontmatter also includes @mastra/server and @mastra/core without corresponding outcomes here. Please keep this file package-scoped to what it documents.

potential_issue

As per coding guidelines: “Do not modify this frontmatter. Check that the description inside the changeset file only applies to the packages listed in the frontmatter.”

🤖 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/sweet-wasps-relax.md around lines 2 - 4, The changeset
frontmatter lists three packages ('`@mastra/client-js`', '`@mastra/server`',
'`@mastra/core`') but the description only documents a client-side API change;
update the frontmatter to match the documented scope by removing
'`@mastra/server`' and '`@mastra/core`' (or alternatively, expand the file
description to include their corresponding updates if they truly changed),
ensuring the frontmatter exactly reflects the packages described in the body.

id: 'agent-1',
name: 'Test Agent',
instructions: 'You are a helpful assistant',
model: { provider: 'openai', name: 'gpt-4' },

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Potential issue: replace newly added literal model names with repository placeholder tokens.

At Line 72, Line 82, and Line 250, the new test data adds name: 'gpt-4'. Please swap these to the approved placeholder token(s) from docs/src/plugins/remark-model-tokens/models.ts to stay aligned with repo standards.

As per coding guidelines, "**/*.{ts,tsx,md,mdx,json}: When adding model names or IDs to examples, changesets, tests, or comments, use placeholder tokens from docs/src/plugins/remark-model-tokens/models.ts".

Also applies to: 82-82, 250-250

🤖 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 `@client-sdks/client-js/src/resources/stored-agent.test.ts` at line 72, Tests
in stored-agent.test.ts use the literal model name "gpt-4" in model objects;
replace those literal names with the repository's approved placeholder token(s)
from docs/src/plugins/remark-model-tokens/models.ts (e.g., the token constant
used for example model names) wherever model: { provider: 'openai', name:
'gpt-4' } appears (including the instances in the test data around the
create/store agent tests and any other occurrences), ensuring you import or
reference the same placeholder token used across the repo so the test data
follows the placeholder convention.

Comment on lines +188 to +276
it('renders the resolved author name when the server returned `author`', () => {
const agents: StoredAgentResponse[] = [
{
id: 'a1',
status: 'active',
createdAt: now,
updatedAt: now,
name: 'Alpha Agent',
description: 'desc',
instructions: '',
model: { provider: 'openai', name: 'gpt-4' },
visibility: 'public',
authorId: 'user-1',
author: { id: 'user-1', name: 'Alice', avatarUrl: 'https://x/y.png' },
},
];
renderList({ agents });

const authors = screen.getAllByTestId('agent-builder-row-author');
expect(authors.length).toBeGreaterThan(0);
expect(authors.some(node => node.textContent?.includes('Alice'))).toBe(true);
});

it('falls back to email when the resolved author has no name', () => {
const agents: StoredAgentResponse[] = [
{
id: 'a1',
status: 'active',
createdAt: now,
updatedAt: now,
name: 'Alpha Agent',
description: 'desc',
instructions: '',
model: { provider: 'openai', name: 'gpt-4' },
visibility: 'public',
authorId: 'user-1',
author: { id: 'user-1', email: 'alice@example.com' },
},
];
renderList({ agents });

const authors = screen.getAllByTestId('agent-builder-row-author');
expect(authors.length).toBeGreaterThan(0);
expect(authors.some(node => node.textContent?.includes('alice@example.com'))).toBe(true);
});

it('falls back to authorId when no resolved author is present', () => {
const agents: StoredAgentResponse[] = [
{
id: 'a1',
status: 'active',
createdAt: now,
updatedAt: now,
name: 'Alpha Agent',
description: 'desc',
instructions: '',
model: { provider: 'openai', name: 'gpt-4' },
visibility: 'public',
authorId: 'user-99',
},
];
renderList({ agents });

const authors = screen.getAllByTestId('agent-builder-row-author');
expect(authors.length).toBeGreaterThan(0);
expect(authors.some(node => node.textContent?.includes('user-99'))).toBe(true);
});

it('omits the author block when neither `author` nor `authorId` is present', () => {
const agents: StoredAgentResponse[] = [
{
id: 'a1',
status: 'active',
createdAt: now,
updatedAt: now,
name: 'Alpha Agent',
description: 'desc',
instructions: '',
model: { provider: 'openai', name: 'gpt-4' },
visibility: 'public',
},
];
renderList({ agents });

expect(screen.queryByTestId('agent-builder-row-author')).toBeNull();
// Row still renders all other fields.
expect(screen.getByText('Alpha Agent')).toBeTruthy();
expect(screen.getByText('desc')).toBeTruthy();
});

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace hard-coded model names with repo model placeholder tokens.

The new test fixtures still use literal model names. Please switch these to the placeholder tokens defined in docs/src/plugins/remark-model-tokens/models.ts to match repo policy.

As per coding guidelines: “**/*.{ts,tsx,md,mdx,json}: When adding model names or IDs to examples, changesets, tests, or comments, use placeholder tokens from docs/src/plugins/remark-model-tokens/models.ts.”

🤖 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/playground/src/domains/agent-builder/components/agent-list/__tests__/agent-builder-list.test.tsx`
around lines 188 - 276, The test fixtures in agent-builder-list.test.tsx use
hard-coded model objects (e.g., model: { provider: 'openai', name: 'gpt-4' })
inside the StoredAgentResponse fixtures passed to renderList; replace those
literal model provider/name strings with the corresponding placeholder tokens
exported from the repo's model tokens module (import the token constants and use
them for model.name and provider if available) so all test fixtures reference
the official placeholder tokens rather than hard-coded model names.

Comment thread packages/playground/src/pages/agent-builder/agents/__tests__/index.test.tsx Outdated
Comment thread packages/server/src/server/handlers/author-enrichment.ts
…ichment

# Conflicts:
#	packages/server/src/server/handlers/stored-agents.ts
## What

Unblocks CI for #17205 with two minimal, behavior-preserving fixes.

### 1. Lint — drop orphaned `resolveBuilderModelPolicy` import

`packages/server/src/server/handlers/stored-agents.ts` imported
`resolveBuilderModelPolicy` but had zero call sites. Save-path
model-policy enforcement was intentionally removed on `main` (commit
`a45fd541d1`); the merge from `main` into this branch left the import
dangling. Comments at lines ~500 and ~664 already document the
intentional removal of the check itself.

### 2. Test — use `getAllByText` for duplicated DOM nodes


`packages/playground/src/pages/agent-builder/agents/__tests__/index.test.tsx`
used `screen.getByText('Alice Doe')` and `getByText('bob@example.com')`.
`AgentBuilderList` renders the `AuthorBadge` twice per row (once for
mobile `md:hidden`, once for desktop `hidden md:flex`); jsdom doesn't
apply CSS, so both nodes are queryable and `getByText` throws "multiple
elements found".

Switched to `getAllByText(...).length > 0`, matching the pattern already
used in the colocated `agent-builder-list.test.tsx`. This is also what
CodeRabbit flagged in its review.

## Verification

- `pnpm --filter ./packages/server lint` — exit 0
- `pnpm --filter ./packages/server tsc --noEmit` — no errors
- `pnpm --filter ./packages/server vitest run
src/server/handlers/stored-agents.test.ts
src/server/handlers/author-enrichment.test.ts` — 73 passed, 1 skipped
(pre-existing)
- `pnpm --filter ./packages/playground vitest run
src/pages/agent-builder/agents/__tests__/index.test.tsx
src/domains/agent-builder/components/agent-list/__tests__/agent-builder-list.test.tsx`
— 18/18 pass (was 17/18)

## No changeset

These are CI-fix-only edits with no user-visible behavior change.

Co-authored-by: YJ <yj@example.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-7) <noreply@mastra.ai>
)

## Summary

Fixes a latent runtime crash in author enrichment for stored agents.

`isUserProvider` (in `author-enrichment.ts`) only checked for
`getCurrentUser`, but `prepareAuthorEnrichment` always calls
`provider.getUser(...)` on the per-id fallback path. A provider that
implements `getCurrentUser` but not `getUser` would pass the guard and
then throw at runtime. This tightens the guard to also require
`getUser`.

Flagged by CodeRabbit during review of #17205. Targeting the feature
branch so it lands inside #17205 before that merges to `main`.

## Changes

- `author-enrichment.ts` — `isUserProvider` now also requires `getUser`
to be a function
- `author-enrichment.test.ts` — add case: provider with `getCurrentUser`
but no `getUser` returns `null`

## Test plan

- `pnpm --filter ./packages/server lint` — clean
- `pnpm --filter ./packages/server tsc --noEmit` — no errors
- `pnpm --filter ./packages/server vitest run
src/server/handlers/author-enrichment.test.ts` — 15 passed
- `pnpm --filter ./packages/server vitest run
src/server/handlers/stored-agents.test.ts` — 59 passed, 1 skipped

No changeset: behavior-preserving guard fix, no user-visible API change.

Co-authored-by: YJ <yj@example.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-7) <noreply@mastra.ai>
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 3, 2026 17:58 Inactive
@vercel vercel Bot temporarily deployed to Preview – mastra-docs-1.x June 3, 2026 17:58 Inactive
mfrachet and others added 2 commits June 8, 2026 09:10
…ichment

# Conflicts:
#	packages/playground/src/pages/agent-builder/agents/__tests__/index.test.tsx
…act rename

The merge of main renamed @mastra/react's export from MastraDBMessage to
MastraUIMessage, which broke the playground-ui build. The type is still
exported by @mastra/core/agent/message-list, so import it from there to keep
the existing Message types intact without depending on the removed re-export.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
The MastraDBMessage import from @mastra/core/agent/message-list must be
ordered before @mastra/core/memory to satisfy the import/order lint rule,
which was failing CI lint.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
@mfrachet mfrachet merged commit 34839c1 into main Jun 8, 2026
91 of 93 checks passed
@mfrachet mfrachet deleted the feat/agent-author-enrichment branch June 8, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: critical Critical-complexity PR tests: green ✅ Changed tests failed against base as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants