Skip to content

Conversation

i-m-sid
Copy link
Contributor

@i-m-sid i-m-sid commented Oct 17, 2025

In rare cases, the ordering of tool calls doesn't match the expected Anthropic API contract. Fixed this by manually ordering the tool calls in expected format.

#2214
#3230
#2720

@rekram1-node
Copy link
Collaborator

Is it possible to save them in correct format instead, seems weird that for every request we need to reorder all the messages

@i-m-sid
Copy link
Contributor Author

i-m-sid commented Oct 17, 2025

The API itself returns them out of order. It's pretty complicated to save them in correct format while streaming. This replaces .flat() method which I believe is also O(n), so there is no performance hit IMO.

@i-m-sid i-m-sid marked this pull request as draft October 19, 2025 17:49
@i-m-sid i-m-sid marked this pull request as ready for review October 19, 2025 19:34
@rekram1-node
Copy link
Collaborator

rekram1-node commented Oct 20, 2025

so the api returns them in an invalid order to send back to api? Hmm are you sure this isnt a bug with pruning tool calls on the opencode side?

I need to look into that api thing but i havent heard that before, Im not saying you are wrong but could you reference the documentation for that here? ill also look into it tho

@rekram1-node
Copy link
Collaborator

ahh i just found: anthropics/claude-code#473

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.

2 participants