Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sessions fail after viewing more than 5 files with Bedrock provider #1267

Open
cjohnhanson opened this issue Feb 18, 2025 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@cjohnhanson
Copy link

Describe the bug
Goose sessions using Bedrock fail after viewing more than 5 files. This happens because Bedrock's API has a hard limit of 5 document attachments per request.

To Reproduce

  1. Use Goose with Bedrock provider
  2. View files using the text_editor view command
  3. Try to view more than 5 files in the same session
  4. The session fails with:
{
  "message": "You can't include more than 5 documents in a request.
Reduce the number of documents and retry your request.",
  "code": "ValidationException",
  "aws_request_id": "XXXX-XXXX-XXXX-XXXX"
}

Expected behavior
Session should be able to maintain functionality and context while viewing multiple files, working within or around Bedrock's document limit.

Please provide following information:

  • OS & Arch: MacOS (affects all platforms)
  • Interface: CLI
  • Version: 1.0.5+
  • Extensions enabled: developer
  • Provider & Model: AWS Bedrock, anthropic.claude-3-5-sonnet-20241022-v2:0 (but would occur with any Bedrock model)

Additional context
Looking at the Bedrock API docs, this appears to bea core limitation of their API:

"You can include up to five documents. Each document's size must be no more than 4.5 MB."

The issue seems to be in:

  • crates/goose-mcp/src/developer/mod.rs - text_editor_view function
  • crates/goose/src/providers/formats/bedrock.rs - document handling

Currently I manage this in my goosehints by prompting to cat files via the shell tool when looking at more than 5 files. This isn't very robust. When I inevitably hit the issue again, I just open up the session file and manually clean up the history, then prompt to usecat moving forward.

I can think of a couple approaches but I'm not sure which would be best:

  1. Just use regular text content instead of documents for Bedrock
  2. Track document count and clean up old ones or switch to plain text content after 5 documents

Not sure how this works for other providers besides Bedrock and I'm also not totally sure yet what the token usage/cost implications would be of using regular text content vs. document blocks for this.

Happy to attempt a PR with one of the above approaches as well, but very new to this codebase so interested to hear alternative approaches or reasons why either of these proposed solutions are infeasible.

@yingjiehe-xyz yingjiehe-xyz added the enhancement New feature or request label Feb 18, 2025
@lily-de
Copy link
Collaborator

lily-de commented Feb 22, 2025

Is the session erroring out? What would be the downside of failing gracefully to avoid a session breaking error?

Actually perhaps I don't understand the mechanism of failure -- is it 5+ files all at once in a single request to Bedrock? Or 5+ files throughout the course of a session using Bedrock? We use AWS Bedrock ourselves at Block, so I am surprised haven't heard of this issue before from other users at the company

@VasilijP
Copy link

VasilijP commented Feb 26, 2025

Same issue with claude 3.7 and Bedrock, goose 1.0.9, running on Ubuntu.

2025-02-26T19:16:46.423927Z ERROR goose::agents::truncate: Error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("You can’t include more than 5 documents in a request. Reduce the number of documents and retry your request."), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("You can’t include more than 5 documents in a request. Reduce the number of documents and retry your request."), extras: Some({"aws_request_id": "..."}) } })
    at crates/goose/src/agents/truncate.rs:279

Ran into this error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("You can’t include more than 5 documents in a request. Reduce the number of do
cuments and retry your request."), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("You can’t include more than 5 documents in a request. Reduce the number of documents a
nd retry your request."), extras: Some({"aws_request_id": "..."}) } }).

This error appeared after another context related one (same setup):

 2025-02-26T19:15:19.378027Z ERROR goose::agents::truncate: Error: Execution error: content was missing: content was not specified but it is required when building ToolResultBlock
    at crates/goose/src/agents/truncate.rs:279

Ran into this error: Execution error: content was missing: content was not specified but it is required when building ToolResultBlock.

Another related problem: adding of unsupported file type (shell script in this case) is also causing the error at the same source location:

 2025-02-26T21:50:09.799646Z ERROR goose::agents::truncate: Error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"aws_request_id": "..."}) } })
    at crates/goose/src/agents/truncate.rs:279

Ran into this error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported
file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Unsupported MIME type: application/x-sh. Retry your request w
ith a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"aws_request_id": "..."}) } }).

This is not a transient problem, it reoccurs after resuming the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants