Skip to content

feat: support native tools in OpenAI Responses provider - #9554

Open
Star-Moon10 wants to merge 2 commits into
AstrBotDevs:masterfrom
Star-Moon10:feat/openai-responses-native-tools
Open

feat: support native tools in OpenAI Responses provider#9554
Star-Moon10 wants to merge 2 commits into
AstrBotDevs:masterfrom
Star-Moon10:feat/openai-responses-native-tools

Conversation

@Star-Moon10

@Star-Moon10 Star-Moon10 commented Aug 5, 2026

Copy link
Copy Markdown

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, and tool_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_responses provider sources.

  • Add unit coverage for native tool payloads and response parsing.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

  • uv run ruff check
  • uv run pytest tests/test_openai_responses_source.py -q — 10 passed
  • corepack pnpm@10.28.2 run build in dashboard/

Checklist / 检查清单

Summary by Sourcery

Add configurable support for OpenAI Responses native tools and surface their outputs in parsed responses.

New Features:

  • Allow configuring and enabling native OpenAI Responses tools (web_search, file_search, code_interpreter, image_generation) and tool_choice via provider and dashboard settings.
  • Combine native Responses tools with AstrBot function tools while preserving any custom tools configured in extra request bodies.
  • Parse URL/file citations and image-generation results from Responses API outputs into the final message chain, including inline source listings.

Enhancements:

  • Backfill default configuration values for Responses-native tool settings in existing openai_responses provider templates and dashboard sources.

Tests:

  • Add unit tests to verify tool combination behavior, default tool_choice handling, and parsing of citations and generated images from Responses API responses.

Copilot AI lite review requested due to automatic review settings August 5, 2026 04:42
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Aug 5, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) and tool_choice.
  • Combine configured native tools with AstrBot function tools while preserving raw custom_extra_body tool 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.

Comment thread astrbot/core/provider/sources/openai_responses_source.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. area:webui The bug / feature is about webui(dashboard) of astrbot. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support OpenAI Responses API built-in tools ( web_search , file_search , code_interpreter ) in openai_responses provider

2 participants