Skip to content

claude-code: pass prompt attachments as text markers (parity with Codex's reference-not-content model) - #30

Merged
SawyerHood merged 1 commit into
mainfrom
bb/claude-code-attachment-text-markers_thr_6ww2pwqsd7
May 19, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/claude-code-attachment-text-markers_thr_6ww2pwqsd7

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

  • File attachments uploaded in the bb UI never reached Claude Code provider sessions: the bridge's extractInputText filter silently dropped every localImage, localFile, and image entry from PromptInput[] before building the SDK user message.
  • Replace the text-only filter with buildPromptText, which forwards text fragments as-is and converts each attachment to a path / URL-bearing text marker rather than reading and inlining bytes. The bridge stays synchronous, no new dependencies, and SdkSession.pushInput still takes a plain string.
  • This matches Codex's reference-not-content model (packages/agent-runtime/src/codex/adapter.ts:650-655) so attachment plumbing is provider-agnostic: the daemon stages files on disk and the adapter hands the model a path it can Read.

Marker shape

PromptInput variant Bridge output
text Plain text, joined with \n (unchanged from today)
image (URL) [Attached image: <url>]
localImage (path only — no name/mime/size in the contract) [Attached image. It is on disk at <staged abs path> — use the Read tool to view it.]
localFile (full metadata) [Attached file \"<name>\" (<mime>, <sizeBytes> bytes). It is on disk at <staged abs path> — use the Read tool to view it.]
localFile (any of name/mime/sizeBytes missing) Same shape, just that field's segment omitted

Supersedes

This PR replaces the now-closed multimodal-inlining PR (#29). The user has decided the simpler reference-passing approach is preferred — no base64 cache busts, uniform with Codex, and the agent uses its existing Read tool to inspect attachments.

Test plan

  • pnpm exec turbo run typecheck across all 27 packages
  • pnpm exec turbo run test --filter=@bb/agent-runtime (504 tests pass, +7 new)
  • 7 new bridge integration tests cover: text-only passthrough, multi-text join, localImage marker, localFile with full metadata, localFile with missing optional fields, image URL marker, attachment-only turn
  • Manual repro in dev (left to reviewer) — drag an image into a Claude Code manager and confirm the model sees the marker (and can Read the staged path if it chooses)

🤖 Generated with Claude Code

The Claude Code bridge's `extractInputText` filter dropped every
`localImage`, `localFile`, and `image` entry from `PromptInput[]` before
constructing the SDK user message, so files attached in the bb UI never
reached Claude Code sessions.

Replace the text-only filter with `buildPromptText`, which keeps text
fragments as-is and converts each attachment to a path-bearing text
marker — `[Attached image: <url>]` for remote URLs and
`[Attached <kind> "<name>" (<mime>, <sizeBytes> bytes). It is on disk
at <staged abs path> — use the Read tool to view it.]` for staged
files. Name / MIME / size are included only when present in the input.
The bridge stays synchronous and pushInput still takes a plain string.

This matches Codex's "pass references, not content" model so the
provider-agnostic attachment plumbing stays uniform: the daemon stages
files on disk and the adapter hands the model a path it can Read.

Supersedes the closed multimodal-inlining PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant