Skip to content

Conversation

@williballenthin
Copy link
Contributor

@williballenthin williballenthin commented Jan 23, 2026

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.done events instead of streaming them via response.function_call_arguments.delta events. The final response.output_item.done event 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:
image

and models.json config:

{
    "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.

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.done` events instead of streaming them
via `response.function_call_arguments.delta` events. The final
`response.output_item.done` event 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 to provide prompts/transcripts, and acknowledge that I'm
not an expert in Pi internals at this time.
@github-actions
Copy link
Contributor

Hi @williballenthin, thanks for your interest in contributing!

We ask new contributors to open an issue first before submitting a PR. This helps us discuss the approach and avoid wasted effort.

Next steps:

  1. Open an issue describing what you want to change and why (keep it concise, write in your human voice, AI slop will be closed)
  2. Once a maintainer approves with lgtm, you'll be added to the approved contributors list
  3. Then you can submit your PR

This PR will be closed automatically. See https://github.com/badlogic/pi-mono/blob/main/CONTRIBUTING.md for more details.

@badlogic
Copy link
Owner

Cheers, Opus did well :)

@badlogic badlogic merged commit 72de8f2 into badlogic:main Jan 24, 2026
1 check passed
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