[PR #4756] [Engine] chat completions: allow response_format with tools, as /v1/responses does #5163

Open
opened 2026-11-07 16:33:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4756
Author: @Tsury
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: fix-format-with-tools


📝 Commits (1)

  • 49c57f8 [Engine] chat completions: allow response_format with tools, as /v1/responses does

📊 Changes

2 files changed (+49 additions, -5 deletions)

View changed files

📝 serve/server.py (+16 -4)
📝 serve/test_structured.py (+33 -1)

📄 Description

Problem and result

/v1/chat/completions answers 400 structured response_format with tools/MCP is not supported when a request has both. /v1/responses accepts the same pair: it calls prepare_format(..., with_tools=bool(tools)), and the format applies to the final answer.

After this change, the chat route does the same. A turn that calls a tool passes through unchecked; a final answer must match the schema, or it fails with the existing error. strata_mcp with a format stays a 400.

#2397 (@Xantier) and #763 (@cipgysmo) asked for this on older bases; #2397 closed in the 0.2.0-beta tracker reset. This uses the with_tools path that main now has.

Approach

Pass with_tools on the chat route. structured_chunks stops buffering at the first tool_calls delta, sends what it held, and streams the rest, as /v1/responses does.

Validation

Passed:

  • New tests against unchanged main (870aedd9): 4 failures and 1 error. With the change: all pass.
  • python -m unittest serve.test_server serve.test_structured: 375 tests pass (Linux, Python 3.14).

Not run:

  • python -m unittest discover -s serve and any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch.

Limits

A turn that calls a tool is not validated, because it is not the final answer. Text sent before the call in that turn goes out unchecked.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4756 **Author:** [@Tsury](https://github.com/Tsury) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-format-with-tools` --- ### 📝 Commits (1) - [`49c57f8`](https://github.com/Niko1221/Strata/commit/49c57f8008021f09ebf3227abd4468b5b5e7c869) [Engine] chat completions: allow response_format with tools, as /v1/responses does ### 📊 Changes **2 files changed** (+49 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+16 -4) 📝 `serve/test_structured.py` (+33 -1) </details> ### 📄 Description ## Problem and result `/v1/chat/completions` answers 400 `structured response_format with tools/MCP is not supported` when a request has both. `/v1/responses` accepts the same pair: it calls `prepare_format(..., with_tools=bool(tools))`, and the format applies to the final answer. After this change, the chat route does the same. A turn that calls a tool passes through unchecked; a final answer must match the schema, or it fails with the existing error. `strata_mcp` with a format stays a 400. ## Related discussion #2397 (@Xantier) and #763 (@cipgysmo) asked for this on older bases; #2397 closed in the 0.2.0-beta tracker reset. This uses the `with_tools` path that main now has. ## Approach Pass `with_tools` on the chat route. `structured_chunks` stops buffering at the first `tool_calls` delta, sends what it held, and streams the rest, as `/v1/responses` does. ## Validation **Passed:** - New tests against unchanged `main` (870aedd9): 4 failures and 1 error. With the change: all pass. - `python -m unittest serve.test_server serve.test_structured`: 375 tests pass (Linux, Python 3.14). **Not run:** - `python -m unittest discover -s serve` and any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch. ## Limits A turn that calls a tool is not validated, because it is not the final answer. Text sent before the call in that turn goes out unchecked. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5163
No description provided.