[GH-ISSUE #12244] tools are rendered to prompts in an unpredictable order #70205

Open
opened 2026-05-04 20:39:04 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @drifkin on GitHub (Sep 10, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12244

Originally assigned to: @drifkin on GitHub.

Because tools are stored as golang maps, which purposefully do not guarantee key order, they can be arbitrarily reordered inside of prompts. Besides removing potential user intent about order (e.g., the order of arguments can be helpful to the model), this will cause subsequent requests to break the kv cache. We should switch to using ordered map types and set our json decoding such that we can roundtrip json with a stable key order.

Originally created by @drifkin on GitHub (Sep 10, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12244 Originally assigned to: @drifkin on GitHub. Because tools are stored as golang maps, which purposefully do not guarantee key order, they can be arbitrarily reordered inside of prompts. Besides removing potential user intent about order (e.g., the order of arguments can be helpful to the model), this will cause subsequent requests to break the kv cache. We should switch to using ordered map types and set our json decoding such that we can roundtrip json with a stable key order.
GiteaMirror added the renderingtools labels 2026-05-04 20:39:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#70205