Skip to content

Flexible handling of dspy.ToolCalls parsing #8563

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chenmoneygithub
Copy link
Collaborator

We have observed that LMs can mess up the deeply nested type, especially when it understands the semantics behind the scene, specifically dspy.ToolCalls here. We are expecting the format {"tool_calls": [{"name": "foo", "args": {...}}, {"name": "bar", "args": {...}}]}, but in reality there are a few cases seen from the same LM:

  • {"name": foo, "args": {...}}, which is just a dict of information of one function calling. This behavior is pretty common, it exists not just in those small models on ollama, but also gpt-4o-mini, gpt-4o, even gemini-2.5.
  • [{"name": "foo", "args": {...}}, {"name": "bar", "args": {...}}]. The outer tool_calls key is lost.

Since this is a stable pattern, it makes sense to have the default type handle this parsing.

@chenmoneygithub chenmoneygithub requested a review from okhat July 22, 2025 00:27
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.

1 participant