Skip to content

Conversation

@amberdixon
Copy link

Pull Request Description

Sometimes databricks comes back with this error message. We should parse out the message in the JSON body and handle it gracefully by treating it as context exceeded:

Error: Request failed: HTTP 400 Bad Request: {"error_code":"BAD_REQUEST","message":"{\"external_model_provider\":\"databricks-model-serving\",\"external_model_error\":{\"error_code\":\"BAD_REQUEST\",\"message\":\"{\\\"message\\\":\\\"Input is too long for requested model.\\\"}\"}}"}
The tool calling loop was interrupted. How would you like to proceed?
  error: The error above was an exception we were not able to handle.
These errors are often related to connection or authentication
We've removed the conversation up to the most recent user message
- depending on the error you may be able to continue

After my change, the following occurred when the input is too long error came back:

Let me examine the full results:
─── text_editor | developer ──────────────────────────
path: /v/f/l/b/T/goose_mcp_responses/mcp_response_20250909_001603.txt
command: view

Error: Context length exceeded: Input is too long for requested model.
The tool calling loop was interrupted. How would you like to proceed?
  error: Context length exceeded error.
The conversation is too long for the model's context window.
Consider using /summarize to condense the conversation history
or /clear to start fresh.
We've removed the conversation up to the most recent user message.

…acefully by treating it as context exceeded. The response is JSON, hanlde it well.
@michaelneale
Copy link
Collaborator

is this complimenting #4565 - by @katzdave ?

@michaelneale
Copy link
Collaborator

thanks @amberdixon - mind running cargo fmt and push again?

@alexhancock
Copy link
Collaborator

@amberdixon Yeah if you could do cargo fmt and push and then bonus/good if we can add some tests that would fail before the change, and pass after!

@katzdave
Copy link
Collaborator

katzdave commented Sep 9, 2025

Are these still falling through on main after #4506?

I'm fine with going this route if so, although not sure why the string matching isn't picking up since it has 'too long' inside the payload.

Yeah #4565 should handle these errors better as well.

@amberdixon
Copy link
Author

not sure why the string matching isn't picking up since it has 'too long' inside the payload.

I'm really curious to know why as well. I'm going to try to repro the problem again with some logging to help me understand why the existing string checks aren't working before i introduce new code!

@amberdixon
Copy link
Author

I think #4506 is probably the correct fix and it just got released in 1.8.0, so I'm going to report back here if I do happen to see this problem again after using 1.8.

@amberdixon amberdixon closed this Sep 11, 2025
@alexhancock
Copy link
Collaborator

awesome, thanks for engaging and making sure it's resolved some way @amberdixon!

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.

4 participants