Skip to content

Conversation

@Amnah199
Copy link
Contributor

@Amnah199 Amnah199 commented Sep 22, 2025

Related Issues

Proposed Changes:

  • Add a chat generator that uses openai's responses endpoint.
  • The tools param in init and run methods allows openai and MCP tools besides haystack Tools.
  • Structured outputs can be enabled by passing text_format in generation_kwargs.
  • Reasoning can be enabled by setting reasoning params in generation_kwargs.
  • There are other features in Responses API like background requests etc, which are not supported in this iteration.

How did you test it?

  • Add new unit tests to test features.
  • Add new integration tests.

Notes for the reviewer

Using OpenAI tools and MCP tools doesn’t behave like standard function calls.

  • Tool calls are usually identified by type="function_call". However, for OpenAI/MCP tools, the type value varies depending on the tool being used — for example, type="web_search_call".
  • Currently, we only return standard ResponseFunctionToolCall objects. As a result, tool calls from OpenAI/MCP tools won’t appear in the ChatMessage, so the user won’t see them.
  • This is fine, since these tool calls are handled internally by OpenAI to generate the final response. The user already receives the output.

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@github-actions github-actions bot added the type:documentation Improvements on the docs label Sep 22, 2025
@coveralls
Copy link
Collaborator

coveralls commented Sep 22, 2025

Pull Request Test Coverage Report for Build 18779147146

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 91.313%

Files with Coverage Reduction New Missed Lines %
components/builders/answer_builder.py 1 98.57%
Totals Coverage Status
Change from base Build 18690275685: -0.9%
Covered Lines: 13581
Relevant Lines: 14873

💛 - Coveralls

@Amnah199 Amnah199 requested a review from vblagoje October 13, 2025 07:57
@Amnah199 Amnah199 marked this pull request as ready for review October 13, 2025 10:15
@Amnah199 Amnah199 requested a review from a team as a code owner October 13, 2025 10:15
@Amnah199 Amnah199 marked this pull request as draft October 14, 2025 16:15
Comment on lines +147 to +150
:param tools_strict:
Whether to enable strict schema adherence for tool calls. If set to `False`, the model may not exactly
follow the schema provided in the `parameters` field of the tool definition. In Response API, tool calls
are strict by default.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vercel
Copy link

vercel bot commented Oct 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
haystack-docs Ignored Ignored Preview Oct 24, 2025 0:03am

@Amnah199 Amnah199 marked this pull request as ready for review October 24, 2025 09:10
Copy link
Member

@vblagoje vblagoje left a comment

Choose a reason for hiding this comment

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

@Amnah199 left some initial comments; didn't go into details yet

Added the OpenAIResponsesChatGenerator, a new component that integrates OpenAI's Responses API into Haystack.
This unlocks several advanced capabilities from the Responses API:
- Allowing retrieval of concise summaries of the model's reasoning process.
- Allowing the use of native OpenAI or MCP tool formats, along with Haystack Tool objects and Toolset instances.
Copy link
Member

Choose a reason for hiding this comment

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

What else do we support and integrate well from our ecosystem into Responses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Structured outputs could be one.

Completes chats using OpenAI's Responses API.
It works with the gpt-4 and o-series models and supports streaming responses
from OpenAI API. It uses [ChatMessage](https://docs.haystack.deepset.ai/docs/chatmessage)
Copy link
Member

Choose a reason for hiding this comment

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

I'd mention here, including the o3-deep-research,
o4-mini-deep-research, and gpt-5-codex among others. People don't know this in general that you can use these specialized model/agents with this CG. Or do we don't want to mention that at this time, because they need to run usually in background etc

OpenAI API. Use the `**generation_kwargs` argument when you initialize
the component or when you run it. Any parameter that works with
`openai.Responses.create` will work here too.
Copy link
Member

Choose a reason for hiding this comment

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

Should we mention somewhere here what we don't support i.e background tasks etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for OpenAI's Responses API

5 participants