Repository navigation
fix: forward prompt attachments to Claude Code adapter - #29
Closed
SawyerHood wants to merge 1 commit into
Closed
SawyerHood wants to merge 1 commit into
SawyerHood wants to merge 1 commit into
Conversation
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]>
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. |
3 of 4 tasks
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.
Summary
extractInputTextfilter silently dropped everylocalImage,localFile, andimageentry before building the SDK user message.buildUserMessageContentthat reads each staged attachment from disk and emits the right Claude Agent SDK content blocks (text, base64image, base64 PDF, plain-textdocument, or a path-bearing text marker for unsupported binary types).stringcontent, 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 callingSdkSession.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 typecheckacross all packagespnpm exec turbo run test --filter=@bb/agent-runtime(511 tests pass — 14 new)pnpm exec turbo run test) — all 26 packages greenbuildUserMessageContentcover 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 pathcontent: stringfor text-only turns and the correctContentBlockParam[]forlocalImageandlocalFileturns🤖 Generated with Claude Code