fix(agentic-server): speak ollama's dialect, and name an upstream refusal - #1772
Merged
Conversation
…usal Ollama's chat api takes `content` as a string; every harness sends it as parts, so a pi turn through the gateway died on `json: cannot unmarshal array into Go struct field ChatRequest.messages.content of type string`. The gateway is where the dialects meet, so it flattens text parts and moves image parts to ollama's own `images` field, failing loudly on a part it cannot express. That failure also reached the run as a bare `LLM provider error: 400` with the reason unread in `error.upstream` — harnesses surface `error.message` and nothing else, so the message now names the provider and its reason.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
A real pi run through the gateway against a local ollama died on its first turn. Ollama's chat api takes
contentas a string, and every harness sends parts:The gateway is where the dialects meet, so
transformChatRequestnow flattens for the ollama provider only: text parts joined with\n,image_urlparts (base64 data urls) moved to ollama's ownimagesfield, and any part it cannot express throws rather than being dropped into a prompt the model never sees. Providers on the OpenAI wire keep passing parts through untouched.The same failure was also unreadable from the harness side: the reason sat in
error.upstream, which nothing reads, whileerror.messagewas a bareLLM provider error: 400.upstreamErrorMessageunwraps{error}/{error:{message}}when the body is JSON, falls back to the raw body when it isn't, collapses whitespace and truncates at 300 chars;error.upstreamstill carries the untruncated body.Link to Devin session: https://app.devin.ai/sessions/2d292e43fd2e4f34bb84605b5aa2a250
Requested by: @pyramation