Skip to content

Add OpenAI-compatible tool call interop helpers#701

Open
Dominic789654 wants to merge 1 commit into
thinking-machines-lab:mainfrom
Dominic789654:add-openai-tool-compat
Open

Add OpenAI-compatible tool call interop helpers#701
Dominic789654 wants to merge 1 commit into
thinking-machines-lab:mainfrom
Dominic789654:add-openai-tool-compat

Conversation

@Dominic789654

Copy link
Copy Markdown

Summary

  • add tool-use helpers to parse XML-style Qwen/Tinker tool calls from assistant content into structured ToolCall objects
  • add a helper to linearize assistant.tool_calls and role=tool history into plain assistant text for providers that reject OpenAI tool history
  • document the interop use case and add unit tests

Context

This came from integrating Tinker-hosted Qwen-style models with OpenAI-compatible agent/eval frameworks. Some routes emit model-native XML tool calls in message.content instead of filling message.tool_calls, while subsequent chat calls may reject standard OpenAI tool-history messages. These helpers keep that adapter logic small and reusable.

A standalone extraction of the same idea is here for reference: https://github.com/Dominic789654/tinker2openai-tool

Tests

  • python -m pytest tinker_cookbook/tool_use/openai_compat_test.py
  • python -m ruff check tinker_cookbook/tool_use/openai_compat.py tinker_cookbook/tool_use/openai_compat_test.py tinker_cookbook/tool_use/init.py
  • pyright tinker_cookbook/tool_use/openai_compat.py tinker_cookbook/tool_use/openai_compat_test.py

Note: uv run appeared to hang while initializing the fresh local environment, so I ran the checks through the existing Python/pyright executables instead.

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.

1 participant