microsoft / microsoft/foundry-local

[Bug] Chat completions rejects custom tools with key 'function' not found

Open
#1,080 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
2.6k
Forks
369
Avg merge
2d 17h
Merged PRs (30d)
39

Description

### Describe the issue

The OpenAI-compatible `/v1/chat/completions` endpoint rejects a request containing a custom/freeform tool definition. The server assumes every tool contains a `function` property and returns HTTP 400 for a tool whose type is `custom`.

Observed response:

```text
Invalid request: [json.exception.out_of_range.403] key 'function' not found
```

A control request containing only a standard function tool passes tool parsing. The expected behavior is either to accept the custom tool schema or return a clear unsupported-tool-type error rather than attempting to read a missing `function` property.

### To reproduce

1. Use `Microsoft.AI.Foundry.Local` version `2.0.1`.
2. Load `qwen3.5-2b-text-cuda-gpu:1` and start the local web service.
3. POST to `/v1/chat/completions` with one standard function tool and this additional tool:

```json
{
"type": "custom",
"custom": {
"name": "freeform_tool",
"description": "Accepts freeform input.",
"format": {
"type": "grammar",
"grammar": {
"syntax": "lark",
"definition": "start: /(?s).+/"
}
}
}
}
```

The response is HTTP 400 with `key 'function' not found`. Sending the same request without the custom tool progresses past request parsing.

### Urgency

This prevents clients using OpenAI-compatible custom/freeform tool schemas from sending those requests to Foundry Local.

### System information

- Platform and architecture: Windows X64
- OS version: Windows 11
- Installation type: Released package/binary
- Foundry Local version: Microsoft.AI.Foundry.Local 2.0.1
- API or surface area: REST API
- Hardware acceleration/backend: WebGPU/CUDA
- Backend/runtime version: ONNX Runtime 1.28.0; ONNX Runtime GenAI 0.15.2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the POST to /v1/chat/completions with the standard function tool and the custom tool shown in the issue, then trace the request's tool-parsing path. Done means the custom schema is accepted or the endpoint returns a clear unsupported-tool-type error instead of a missing-key exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.