Skip to content

fix(core): honor model supportedUrls in durable agent execution#18649

Open
rodrigo-rodrigues-pc wants to merge 1 commit into
mastra-ai:mainfrom
rodrigo-rodrigues-pc:fix/durable-agent-supported-urls
Open

fix(core): honor model supportedUrls in durable agent execution#18649
rodrigo-rodrigues-pc wants to merge 1 commit into
mastra-ai:mainfrom
rodrigo-rodrigues-pc:fix/durable-agent-supported-urls

Conversation

@rodrigo-rodrigues-pc

@rodrigo-rodrigues-pc rodrigo-rodrigues-pc commented Jun 29, 2026

Copy link
Copy Markdown

Description

Durable agent execution built the LLM prompt by calling llmPrompt() without the
model's supportedUrls. As a result, file/image URLs that a provider can fetch
natively (e.g. Vertex gs://, Bedrock s3://) were treated as assets to download and
inline. They either failed with Failed to download asset or were corrupted into a
malformed data:<mime>;base64,<url> data URI before reaching the model.

This fix resolves currentModel.supportedUrls (awaiting it when it's a PromiseLike,
as with ModelRouterLanguageModel) and forwards it to llmPromptForModel(...) in the
durable LLM-execution step — bringing it in line with the standard agentic-execution
path (loop/workflows/agentic-execution/llm-execution-step.ts), which already does
this. With the model's supported schemes known, those URLs pass through to the provider
as references instead of being downloaded or base64-wrapped.

Files

  • packages/core/src/agent/durable/workflows/steps/llm-execution.ts — resolve and pass
    supportedUrls to the prompt builder.
  • packages/core/src/agent/durable/__tests__/durable-agent-images.test.ts — regression
    test: streams a gs:// image through a durable agent whose model declares gs://
    support and asserts the reference reaches the model intact (not downloaded /
    base64-wrapped). Verified the test fails on the pre-fix code.

Related issue(s)

Fixes #18648

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test update

Checklist

  • I have linked the related issue(s) in the description above
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • I have addressed all Coderabbit comments on this PR

ELI5

Durable agents were treating some “native” cloud links (like gs:// and s3://) as if they had to download the image themselves. Now, if the model says it supports those URL schemes, the durable step forwards the original reference to the model—so it can fetch the asset in the provider-native way.

Summary

  • Fixed durable LLM prompt construction to respect the model’s supportedUrls by resolving currentModel.supportedUrls (including Promise-like values) and passing the resolved result into llmPromptForModel(...).
  • Added a regression test that streams a durable agent run containing a gs:// image and asserts the prompt preserves the original gs:// reference (not converted to a downloaded asset or data: URI).

Impact

  • Prevents durable runs from incorrectly downloading and corrupting gs:///s3:// references into data: URIs.
  • Aligns durable agent execution with the standard (non-durable) agentic path regarding supportedUrls handling.

@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 260897f

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

This PR includes changesets to release 22 packages
Name Type
@mastra/core Patch
mastracode Patch
@mastra/mcp-docs-server Patch
@internal/playground Patch
@mastra/client-js Patch
@mastra/opencode Patch
@mastra/longmemeval Patch
mastra Patch
@mastra/deployer-cloud Patch
@mastra/react Patch
@mastra/playground-ui Patch
@mastra/server Patch
@mastra/deployer Patch
create-mastra Patch
@mastra/express Patch
@mastra/fastify Patch
@mastra/hono Patch
@mastra/koa Patch
@mastra/nestjs Patch
@mastra/next Patch
@mastra/tanstack-start Patch
@mastra/temporal 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

@rodrigo-rodrigues-pc is attempting to deploy a commit to the Mastra Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The durable LLM execution step now resolves and forwards currentModel.supportedUrls into prompt building. A regression test verifies gs:// image references remain unchanged, and a changeset records the patch.

Changes

Durable agent supportedUrls fix

Layer / File(s) Summary
Forward supportedUrls in durable LLM step
packages/core/src/agent/durable/workflows/steps/llm-execution.ts
Resolves currentModel.supportedUrls, including Promise-like values, and passes the result to llmPromptForModel.
Regression test and changeset
packages/core/src/agent/durable/__tests__/durable-agent-images.test.ts, .changeset/plenty-loops-create.md
Adds a durable streaming regression test that captures the prompt and checks gs:// stays intact, and records the patch release note.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • TylerBarnes
  • epinzur
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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
Title check ✅ Passed The title clearly describes the durable-agent supportedUrls fix and matches the main change.
Linked Issues check ✅ Passed The code forwards supportedUrls in durable LLM execution and adds regression coverage for gs://, matching issue #18648.
Out of Scope Changes check ✅ Passed The changes are limited to the durable execution fix, its regression test, and a release note.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dane-ai-mastra dane-ai-mastra Bot added the complexity: low Low-complexity PR label Jun 29, 2026
@dane-ai-mastra

dane-ai-mastra Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

PR triage

Linked issue check passed (#18648).

Mastra uses CodeRabbit for automated code reviews. Please address all feedback from CodeRabbit by either making changes to your PR or leaving a comment explaining why you disagree with the feedback. Since CodeRabbit is an AI, it may occasionally provide incorrect feedback.


PR complexity score

Factor Value Score impact
Files changed 3 +6
Lines changed 97 +3
Author merged PRs 0 -0
Test files changed Yes -10
Final score -1

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

🤖 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 `@packages/core/src/agent/durable/__tests__/durable-agent-images.test.ts`:
- Around line 346-348: The captured-prompt assertion in
durable-agent-images.test.ts is assuming every returned part from findFilePart()
is a file and reads .data, but findFilePart() can also return an image part
whose preserved gs:// value is stored on .image. Update the assertions that use
findFilePart() to handle both part types by checking the returned part’s type
and reading the matching property (.data for file, .image for image) in the
durable-agent prompt checks.
🪄 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: d20bebcd-a461-4d8e-84ce-22a3bf21ebaa

📥 Commits

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

📒 Files selected for processing (3)
  • .changeset/plenty-loops-create.md
  • packages/core/src/agent/durable/__tests__/durable-agent-images.test.ts
  • packages/core/src/agent/durable/workflows/steps/llm-execution.ts

Durable agent execution built the LLM prompt by calling `llmPrompt()`
without the model's `supportedUrls`, so file/image URLs a provider can
fetch natively (e.g. Vertex `gs://`, Bedrock `s3://`) were treated as
downloadable assets. They either failed with "Failed to download asset"
or were corrupted into a malformed `data:<mime>;base64,<url>` data URI.

Resolve `currentModel.supportedUrls` (awaiting it when it's a Promise,
as with ModelRouterLanguageModel) and pass it to `llmPromptForModel()`,
matching the standard agentic-execution path
(`loop/workflows/agentic-execution/llm-execution-step.ts`).

Add a regression test that streams a `gs://` image through a durable
agent whose model declares `gs://` support and asserts the reference is
passed through to the model rather than downloaded or base64-wrapped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rodrigo-rodrigues-pc rodrigo-rodrigues-pc force-pushed the fix/durable-agent-supported-urls branch from 9a92f4f to 260897f Compare June 29, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: low Low-complexity PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Durable agent execution ignores model supportedUrls — gs:// and s3:// file URLs downloaded or corrupted into data: URIs

1 participant