fix(core): expose local attachment paths - #41789
Merged
Merged
Conversation
# ------------------------ >8 ------------------------ # Do not modify or remove the line above. # Everything below it will be ignored. # # Conflicts: # packages/core/src/session/runner/to-llm-message.ts
Contributor
|
Complementary: my open PR #41723 covers the other half of the attachment lowering gap — image mimes outside the provider-supported set ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Expose the resolved filesystem location of explicitly attached local images and directories to the model. This restores V2 agents' ability to operate on selected image files and reference checkouts.
Closes #41443
Closes #41454
Before / After
Before: V2 admission materialized local attachments and durably retained their
file:source URI, but message lowering only sent a directory alias or binary media filename. Provider-visible content omitted the resolved path, so an agent could see an image or reference root listing without knowing where to read it.After: canonical message lowering decodes local
file:source URIs. Directory context identifies the resolved directory, and local image media is preceded by oneAttached file: <path>text part. The binary media payload and filename are unchanged.How
packages/core/src/session/runner/to-llm-message.tsshares a local attachment-location formatter across directory and image lowering. It only emits locations forfile:URIs and decodes the host-native URI produced when the attachment was admitted. Tests generate those URIs withpathToFileURL, matching production on POSIX and Windows.packages/core/test/session-runner-message.test.tscovers a reference-like directory alias, a local image with durable source metadata, unchanged media bytes/filename, and the absence of added text for non-local media.Scope
This is V2-only and does not modify legacy
packages/opencode.Inline attachments and non-local URI sources keep their existing provider content. Text attachment formatting and unsupported binary MIME handling are unchanged.
Testing
bun run test test/session-prompt.test.ts test/session-runner-message.test.tsfrompackages/core: 61 passbun run test test/session-runner-message.test.ts: 20 passbun typecheckfrompackages/core: passbun turbo typecheck --concurrency=3: 33 tasks passbun run lint -- packages/core/src/session/runner/to-llm-message.ts packages/core/test/session-runner-message.test.ts: 0 errors; 3 pre-existing warningsbunx prettier --check src/session/runner/to-llm-message.ts test/session-runner-message.test.ts: passgit diff --check: pass4e0438edb2makes the fixtures host-native and keeps production decoding aligned with attachment admission.Demo
The focused provider-boundary tests are the exact evidence for this non-visual change: they verify admitted
source.urimetadata becomes model-visible local paths while binary media remains intact. OpenCode Drive was not used because a provider-backed run would be less deterministic than asserting canonical messages directly.