Skip to content

server: support OpenAI tool calling (non-streaming, Qwen-style)#556

Open
KonstantinSKY wants to merge 1 commit into
trymirai:mainfrom
KonstantinSKY:chat-completions-tool-calling
Open

server: support OpenAI tool calling (non-streaming, Qwen-style)#556
KonstantinSKY wants to merge 1 commit into
trymirai:mainfrom
KonstantinSKY:chat-completions-tool-calling

Conversation

@KonstantinSKY

Copy link
Copy Markdown
Contributor

Adds OpenAI tool calling to the local chat-completions server (non-streaming) — first of a small series.

Why: OpenAI-compatible agentic clients need tools in the request and tool_calls in the response to drive a local uzu server; today the server silently ignores both.

What:

  • server (chat_completions.rs): parse tools, build a ToolNamespace, attach it to the conversation; emit tool_calls and finish_reason: "tool_calls" (content is null when only tool calls are present).
  • backend (backend-uzu): feed tools into the model's prompt template (the stock Qwen3 template already has the {% if tools %} branch) and parse the model's <tool_call>…</tool_call> output into Output.tool_calls.

Scope / follow-ups: non-streaming only; output parsing targets the ChatML <tool_call> format for now. The role:"tool" round-trip, streaming deltas, tool_choice, and more model formats are separate PRs.

Tested: unit tests for request→namespace, <tool_call> parsing, and response serialization; verified end-to-end with a local model (Qwen3-0.6B) returning a get_weather tool call.

@KonstantinSKY KonstantinSKY force-pushed the chat-completions-tool-calling branch from 43a878d to 2935bff Compare June 18, 2026 23:36
@KonstantinSKY KonstantinSKY marked this pull request as ready for review June 18, 2026 23:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2935bffe19

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/cli/src/server/chat_completions.rs
Comment thread crates/cli/src/server/chat_completions.rs
Comment thread crates/backend-uzu/src/session/helpers/output_parser.rs
Comment thread crates/cli/src/server/chat_completions.rs
@KonstantinSKY KonstantinSKY marked this pull request as draft June 19, 2026 00:28
Wire OpenAI tool calling through the local chat-completions server and the
backend-uzu runtime: parse `tools` into a ToolNamespace and inject them into
the prompt template; parse <tool_call> output into Output.tool_calls; emit
tool_calls and finish_reason "tool_calls" in the response. Non-streaming only;
streaming, the role:"tool" round-trip and tool_choice are follow-ups.

Unsupported combinations are rejected with HTTP 400 instead of being silently
mishandled: tools with stream:true, and tool_choice other than "auto".
@KonstantinSKY KonstantinSKY force-pushed the chat-completions-tool-calling branch from 2935bff to 5044de6 Compare June 19, 2026 03:24
@KonstantinSKY KonstantinSKY marked this pull request as ready for review June 19, 2026 05:52
@alexxale

Copy link
Copy Markdown
Contributor

Hi @KonstantinSKY! We appreciate your contribution. We’ll be migrating to the new message-processing mechanism with tool-call parsing by the end of next week, and after that we’ll be able to upstream your PR.

@KonstantinSKY

Copy link
Copy Markdown
Contributor Author

Sure, sounds good — thank you!

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