Repository navigation
Description
Description
The Bedrock S3 upload path cannot be reached. _get_resolver_config() turns on prefer_upload for Bedrock when CREWAI_BEDROCK_S3_BUCKET is set:
lib/crewai-files/src/crewai_files/formatting/api.py:293-302
if "bedrock" in provider_lower:
s3_bucket = os.environ.get("CREWAI_BEDROCK_S3_BUCKET")
prefer_upload = (
prefer_upload_override
if prefer_upload_override is not None
else bool(s3_bucket)
)
return FileResolverConfig(
prefer_upload=prefer_upload, use_bytes_for_bedrock=True
)But FileResolver._should_upload() returns early whenever the provider constraints do not set supports_file_upload:
lib/crewai-files/src/crewai_files/resolution/resolver.py:252-256
if constraints is None or not constraints.supports_file_upload:
return False
if self.config.prefer_upload:
return TrueBEDROCK_CONSTRAINTS deliberately leaves supports_file_upload=False (its comment documents S3/URL support instead):
lib/crewai-files/src/crewai_files/processing/constraints.py:280-292
BEDROCK_CONSTRAINTS = ProviderConstraints(
...
supports_url_references=True, # S3 URIs supported
)So with a bucket configured, prefer_upload is True but _should_upload() returns False before reading it. Files are always resolved inline (InlineBytes), and the FileReference -> s3Location branch in BedrockFormatter plus BedrockFileUploader are dead code. This also affects format_multimodal_content(..., provider="bedrock", prefer_upload=True).
Reproduction
import os
from crewai_files import FileBytes, ImageFile
from crewai_files.formatting.api import _get_resolver_config
from crewai_files.processing.constraints import BEDROCK_CONSTRAINTS
from crewai_files.resolution.resolver import FileResolver
os.environ["CREWAI_BEDROCK_S3_BUCKET"] = "my-bucket"
image = ImageFile(source=FileBytes(data=b"x" * 1024, filename="chart.png"))
config = _get_resolver_config("bedrock")
resolver = FileResolver(config=config)
print(config.prefer_upload) # True
print(resolver._should_upload(image, "bedrock", BEDROCK_CONSTRAINTS, 1024)) # FalseExpected behaviour
An explicit upload preference should win over the provider's default capability flag, so a configured Bedrock bucket produces a FileReference (S3 upload) instead of inline bytes. Providers that leave supports_file_upload=False and do not set prefer_upload must stay inline.
Tests
lib/crewai-files/tests/test_resolver.py adds TestBedrockUploadPreference:
test_s3_bucket_enables_uploadfails onmainwithAssertionError: assert Falsefor_should_upload(...)and passes with the fix.test_no_bucket_stays_inlineguards the default path.
AI assistance
I used an AI coding agent to investigate, implement, and test this change, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
Activity
abhi478jeetur-rgb commentedon Nov 22, 2026
Confirmed — the S3 path really is unreachable. I reproduced it against the current code:
_get_resolver_config("bedrock")withCREWAI_BEDROCK_S3_BUCKETset returnsFileResolverConfig(prefer_upload=True, use_bytes_for_bedrock=True), butFileResolver._should_upload()then returnsFalsefor that same file, becauseBEDROCK_CONSTRAINTSnever setssupports_file_upload(it'sFalse) and the early return atresolver.py:252fires beforeprefer_uploadis ever looked at. The constraints only setsupports_url_references=Truewith the S3 comment, so the config the formatter builds can never take effect.The mismatch is that "upload" means different things here: for most providers it's a direct file upload, for Bedrock it's an S3 URI, which the constraints describe via
supports_url_referencesinstead. Two ways to reconcile it:_should_upload, checkself.config.prefer_uploadbefore thesupports_file_uploadgate when the provider supports URL references, orsupports_file_upload=TrueonBEDROCK_CONSTRAINTSwith the understanding that the upload mechanism is S3.The first option is the smaller change and keeps the existing meaning of
supports_file_uploadfor providers that do direct uploads. Either way, as it stands, setting the bucket env var changes nothing at runtime.