Skip to content

fix: forward prompt attachments to Claude Code adapter - #29

Closed
SawyerHood wants to merge 1 commit into
mainfrom
bb/debug-file-uploads-not-reaching-claude-code-mana-thr_6ww2pwqsd7
Closed

SawyerHood wants to merge 1 commit into
mainfrom
bb/debug-file-uploads-not-reaching-claude-code-mana-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 before building the SDK user message.
  • Replace the text-only filter with a multimodal buildUserMessageContent that reads each staged attachment from disk and emits the right Claude Agent SDK content blocks (text, base64 image, base64 PDF, plain-text document, or a path-bearing text marker for unsupported binary types).
  • Text-only turns still produce a plain string content, so cache hits and existing flows are unchanged.

Root cause

packages/agent-runtime/src/claude-code/bridge/bridge.ts:1293-1305 (pre-fix). The upload, server intake, daemon staging, runtime dispatch, and adapter all forward attachments correctly — the bridge then throws away everything that is not { type: "text" } before calling SdkSession.pushInput. Codex and Pi at least preserve a text marker; Claude Code was the odd one out.

Full bug report (trace, comparison vs other providers, file:line): ~/.bb/thread-storage/thr_6ww2pwqsd7/reports/attachment-claude-code-bug.md.

Test plan

  • pnpm exec turbo run typecheck across all packages
  • pnpm exec turbo run test --filter=@bb/agent-runtime (511 tests pass — 14 new)
  • Full repo test run (pnpm exec turbo run test) — all 26 packages green
  • New unit tests for buildUserMessageContent cover text-only, missing input, base64 image (PNG/JPEG), URL image, plain-text document, PDF document, unsupported binary fallback, missing-file fallback, and the legacy string code path
  • New bridge integration tests assert the SDK receives content: string for text-only turns and the correct ContentBlockParam[] for localImage and localFile turns
  • Manual repro in dev (left to reviewer) — drag an image into a Claude Code manager chat and confirm the model sees it

🤖 Generated with Claude Code

The Claude Code bridge's `extractInputText` filter silently dropped any
`localImage`, `localFile`, or `image` entry from the `PromptInput[]`
array before constructing the SDK user message, so files attached in the
bb UI never reached Claude Code sessions even though they were uploaded,
staged on disk by the host-daemon, and forwarded intact to the bridge.

Replace the text-only filter with `buildUserMessageContent`, which reads
each staged attachment and emits the appropriate Claude Agent SDK
content blocks (text, base64 image, base64 PDF, plain-text document, or
a path-bearing text marker for unsupported binary types). Text-only
turns still produce a plain string content to preserve cache hits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator Author

Direction change — closing in favor of a simpler approach. Instead of inlining attachments as native Claude content blocks, Claude Code's adapter will pass attachments as text markers naming the path, matching Codex's behavior. Same worker (thr_6ww2pwqsd7) will produce the new PR; references-not-contents is the unifying principle across providers.

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