fix(core): honor model supportedUrls in durable agent execution#18649
fix(core): honor model supportedUrls in durable agent execution#18649rodrigo-rodrigues-pc wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 260897f The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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 |
|
@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. |
WalkthroughThe durable LLM execution step now resolves and forwards ChangesDurable agent supportedUrls fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR triageLinked 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
Applied label: Changed test gateChanged Test Gate is pending. The |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
.changeset/plenty-loops-create.mdpackages/core/src/agent/durable/__tests__/durable-agent-images.test.tspackages/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>
9a92f4f to
260897f
Compare
Description
Durable agent execution built the LLM prompt by calling
llmPrompt()without themodel's
supportedUrls. As a result, file/image URLs that a provider can fetchnatively (e.g. Vertex
gs://, Bedrocks3://) were treated as assets to download andinline. They either failed with
Failed to download assetor were corrupted into amalformed
data:<mime>;base64,<url>data URI before reaching the model.This fix resolves
currentModel.supportedUrls(awaiting it when it's aPromiseLike,as with
ModelRouterLanguageModel) and forwards it tollmPromptForModel(...)in thedurable LLM-execution step — bringing it in line with the standard agentic-execution
path (
loop/workflows/agentic-execution/llm-execution-step.ts), which already doesthis. 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 passsupportedUrlsto the prompt builder.packages/core/src/agent/durable/__tests__/durable-agent-images.test.ts— regressiontest: streams a
gs://image through a durable agent whose model declaresgs://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
Checklist
ELI5
Durable agents were treating some “native” cloud links (like
gs://ands3://) 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
supportedUrlsby resolvingcurrentModel.supportedUrls(including Promise-like values) and passing the resolved result intollmPromptForModel(...).gs://image and asserts the prompt preserves the originalgs://reference (not converted to a downloaded asset ordata:URI).Impact
gs:///s3://references intodata:URIs.supportedUrlshandling.