feat: support native tools in OpenAI Responses provider - #9554
Open
Star-Moon10 wants to merge 2 commits into
Open
feat: support native tools in OpenAI Responses provider#9554Star-Moon10 wants to merge 2 commits into
Star-Moon10 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
tool_choicenormalization logic is duplicated in both_queryand_query_stream; consider extracting this into a small helper to keep the behavior consistent and make future changes less error-prone. - When combining dashboard-configured native tools with
custom_extra_body.toolsin_build_response_tools, you may want to deduplicate tools (e.g., duplicateweb_searchorfile_searchentries) to avoid sending conflicting or redundant tools to the Responses API.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `tool_choice` normalization logic is duplicated in both `_query` and `_query_stream`; consider extracting this into a small helper to keep the behavior consistent and make future changes less error-prone.
- When combining dashboard-configured native tools with `custom_extra_body.tools` in `_build_response_tools`, you may want to deduplicate tools (e.g., duplicate `web_search` or `file_search` entries) to avoid sending conflicting or redundant tools to the Responses API.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for OpenAI Responses API native tools in AstrBot’s openai_responses provider, exposing configuration via the dashboard and parsing native tool outputs (citations and generated images) into AstrBot’s message chain.
Changes:
- Add provider + dashboard configuration defaults for Responses native tools (
web_search,file_search,code_interpreter,image_generation) andtool_choice. - Combine configured native tools with AstrBot function tools while preserving raw
custom_extra_bodytool entries. - Parse URL/file citations and image-generation results into the final
MessageChain, with unit tests covering tool payload composition and response parsing.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
astrbot/core/provider/sources/openai_responses_source.py |
Builds mixed tool payloads and parses citations + image generation output into MessageChain. |
astrbot/core/config/default.py |
Adds default config/template entries and dashboard metadata schema for Responses native tool settings. |
dashboard/src/composables/useProviderSources.ts |
Backfills defaults for existing openai_responses provider sources in the dashboard editor. |
dashboard/src/i18n/locales/en-US/features/config-metadata.json |
Adds English dashboard metadata labels/hints for the new Responses tool settings. |
dashboard/src/i18n/locales/zh-CN/features/config-metadata.json |
Adds Chinese dashboard metadata labels/hints for the new Responses tool settings. |
tests/test_openai_responses_source.py |
Adds coverage for tool merging/tool_choice behavior and parsing citations + generated images. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9530
Modifications / 改动点
Add dashboard configuration and defaults for native Responses API tools:
web_search(context size and allowed domains),file_search(vector store IDs),code_interpreter,image_generation, andtool_choice.Combine configured native tools with AstrBot function schemas while preserving raw tools from
custom_extra_body.Parse URL/file citations and image-generation results into response messages.
Backfill defaults for existing
openai_responsesprovider sources.Add unit coverage for native tool payloads and response parsing.
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
uv run ruff checkuv run pytest tests/test_openai_responses_source.py -q— 10 passedcorepack pnpm@10.28.2 run buildindashboard/Checklist / 检查清单
Summary by Sourcery
Add configurable support for OpenAI Responses native tools and surface their outputs in parsed responses.
New Features:
Enhancements:
Tests: