fix(ai): handle call arguments done on OpenAI-compatible endpoints #917
+13
−2
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.
fix bug encountered when running GLM-4.7-Flash hosted by LM Studio, in which the provider sends tool call arguments via
response.function_call_arguments.doneevents instead of streaming them viaresponse.function_call_arguments.deltaevents. The finalresponse.output_item.doneevent then contains empty{}arguments. The code only handled delta events, so tool calls failed with validation errors like"must have required property 'command'".Full disclosure, Opus triaged the bug and provided the fix (by adding logging statements to the req/resp to the upstream provider (LM Studio)). I'm happy to provide prompts/transcripts if you'd like, and acknowledge that I'm not an expert in Pi internals at this time.
Example output before fix:

and
models.jsonconfig:{ "providers": { "lmstudio": { "baseUrl": "http://localhost:1234/v1", "apiKey": "unused", "api": "openai-responses", "models": [ ... { "id": "glm-4.7-flash", "name": "glm-4.7-flash", "reasoning": true, "input": ["text"], "compat": { "supportsDeveloperRole": false, "thinkingFormat": "zai" }, "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 128000, "maxTokens": 32000 } ] } } }Other models, like Devstral Small 2, didn't show this issue.