[GH-ISSUE #16413] feat: OpenAPI tool server should be able to return plain text #56562

Closed
opened 2026-05-05 19:42:40 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @stoerr on GitHub (Aug 9, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/16413

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

I'd like to add an OpenAI tool server that can return plain text for some actions. That makes perfect sense e.g. for retrieving text content - why would the tool server need to pack text content into JSON? But currently open-webui tries to parse the response as JSON and fails. OpenAI GPTs themselves do not have any problems with that - a GPT cooperates with my https://github.com/stoerr/CoDeveloperGPTengine which does just return plain text when you access a file with it.

(BTW: why does it parse the tool response at all? Isn't that just returned to the model?)

Desired Solution you'd like

OpenAI tool servers should be supported with other return types than JSON, especially plain text, but possibly more than that.

Alternatives Considered

I could rewrite my tool server to return JSON instead of plaintext, but that does not fit the problem and I'd also expect the LLM to perform worse if I encode retrieved texts, documents and so forth as JSON. Especially if it's JSON - then the JSON is encoded as a string within JSON? Ouch. :-)

Additional Context

The stacktrace.txt contains the stacktrace in open-webui when it accesses a tool server that returns plaintext. I did this with the following node.js example that both offers a json tool (which works) and a plain text returning tool (which does currently not work but should.)

plaintextserver.js.txt

Originally created by @stoerr on GitHub (Aug 9, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/16413 ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description I'd like to add an OpenAI tool server that can return plain text for some actions. That makes perfect sense e.g. for retrieving text content - why would the tool server need to pack text content into JSON? But currently open-webui tries to parse the response as JSON and fails. OpenAI GPTs themselves do not have any problems with that - a GPT cooperates with my https://github.com/stoerr/CoDeveloperGPTengine which does just return plain text when you access a file with it. (BTW: why does it parse the tool response at all? Isn't that just returned to the model?) ### Desired Solution you'd like OpenAI tool servers should be supported with other return types than JSON, especially plain text, but possibly more than that. ### Alternatives Considered I could rewrite my tool server to return JSON instead of plaintext, but that does not fit the problem and I'd also expect the LLM to perform worse if I encode retrieved texts, documents and so forth as JSON. Especially if it's JSON - then the JSON is encoded as a string within JSON? Ouch. :-) ### Additional Context The [stacktrace.txt](https://github.com/user-attachments/files/21698733/stacktrace.txt) contains the stacktrace in open-webui when it accesses a tool server that returns plaintext. I did this with the following node.js example that both offers a json tool (which works) and a plain text returning tool (which does currently not work but should.) [plaintextserver.js.txt](https://github.com/user-attachments/files/21698734/plaintextserver.js.txt)
Author
Owner

@tjbck commented on GitHub (Aug 9, 2025):

It definitely should today, could you provide a screen recording of the issue?

<!-- gh-comment-id:3171899555 --> @tjbck commented on GitHub (Aug 9, 2025): It definitely should today, could you provide a screen recording of the issue?
Author
Owner

@rgaricano commented on GitHub (Aug 9, 2025):

Those are MCP protocol specifications: https://modelcontextprotocol.io/docs/learn/architecture#data-layer-protocol
also openai tool/funcion calls have those kind of protocol specifications:
https://openai.github.io/openai-agents-js/guides/mcp/
https://platform.openai.com/docs/guides/function-calling#handling-function-calls

<!-- gh-comment-id:3171901132 --> @rgaricano commented on GitHub (Aug 9, 2025): Those are MCP protocol specifications: https://modelcontextprotocol.io/docs/learn/architecture#data-layer-protocol also openai tool/funcion calls have those kind of protocol specifications: https://openai.github.io/openai-agents-js/guides/mcp/ https://platform.openai.com/docs/guides/function-calling#handling-function-calls
Author
Owner

@stoerr commented on GitHub (Aug 10, 2025):

This is not about MCP - this is about using OpenAPI Tool Servers.

I ran the sample server plaintextserver.js and added it to the global tool servers (if I entered into the users tool servers I somehow never could see the tool in the model):

Image

I created a model:

Image

Using the jsontestrequest that returns a JSON works fine, but not so the plaintexttestrequest that returns text/plain , and that's the problem I'm describing.

Image
<!-- gh-comment-id:3172852298 --> @stoerr commented on GitHub (Aug 10, 2025): This is not about MCP - this is about using [OpenAPI Tool Servers](https://docs.openwebui.com/openapi-servers/open-webui/). I ran the sample server [plaintextserver.js](https://github.com/user-attachments/files/21707105/plaintextserver.js.txt) and added it to the global tool servers (if I entered into the users tool servers I somehow never could see the tool in the model): <img width="1087" height="730" alt="Image" src="https://github.com/user-attachments/assets/50d858c6-23d3-4951-bf0a-9d7e982f9209" /> I created a model: <img width="1909" height="828" alt="Image" src="https://github.com/user-attachments/assets/c0a2ac59-cb4d-4382-974f-d8c2f9ad1d67" /> Using the jsontestrequest that returns a JSON works fine, but not so the plaintexttestrequest that returns text/plain , and that's the problem I'm describing. <img width="1605" height="942" alt="Image" src="https://github.com/user-attachments/assets/714412ae-9337-4960-bee2-3ad6a0e58b14" />
Author
Owner

@rgaricano commented on GitHub (Aug 10, 2025):

Sure that @tjbck can explain better, but I think that it's because for tools servers always is expected a json response:

30d0f8b1f6/backend/open_webui/utils/tools.py (L629)
30d0f8b1f6/backend/open_webui/utils/tools.py (L639)

and request headers:
30d0f8b1f6/backend/open_webui/utils/tools.py (L611)

<!-- gh-comment-id:3172944579 --> @rgaricano commented on GitHub (Aug 10, 2025): Sure that @tjbck can explain better, but I think that it's because for tools servers always is expected a json response: https://github.com/open-webui/open-webui/blob/30d0f8b1f6cc45ac3ee7e05ccb5c849366680231/backend/open_webui/utils/tools.py#L629 https://github.com/open-webui/open-webui/blob/30d0f8b1f6cc45ac3ee7e05ccb5c849366680231/backend/open_webui/utils/tools.py#L639 and request headers: https://github.com/open-webui/open-webui/blob/30d0f8b1f6cc45ac3ee7e05ccb5c849366680231/backend/open_webui/utils/tools.py#L611
Author
Owner

@stoerr commented on GitHub (Aug 11, 2025):

Right, Open WebUI expects the response to be JSON - that's the problem I'm complaining about. 😄

I don't see a reason for that, and as I explained in quite a couple of cases this is troublesome, even harmful. And with OpenAI GPTs returning plaintext works fine - I happily used that when developing the CoDeveloper GPT Engine. If you look at the OpenAI function call spec which @rgaricano cited above: that says

A result must be a string, but the format is up to you (JSON, error codes, plain text, etc.). The model will interpret that string as needed.

So could you pretty please relax that restriction?

BTW: Why is the response even parsed and not just returned as is to the model? Is that processed somehow?

<!-- gh-comment-id:3173297432 --> @stoerr commented on GitHub (Aug 11, 2025): Right, Open WebUI expects the response to be JSON - that's the problem I'm complaining about. 😄 I don't see a reason for that, and as I explained in quite a couple of cases this is troublesome, even harmful. And with OpenAI GPTs returning plaintext works fine - I happily used that when developing the [CoDeveloper GPT Engine](https://github.com/stoerr/CoDeveloperGPTengine). If you look at the [OpenAI function call spec](https://platform.openai.com/docs/guides/function-calling#handling-function-calls) which @rgaricano cited above: that says > A result must be a string, but the format is up to you (JSON, error codes, plain text, etc.). The model will interpret that string as needed. So could you pretty please relax that restriction? BTW: Why is the response even parsed and not just returned as is to the model? Is that processed somehow?
Author
Owner

@tjbck commented on GitHub (Aug 11, 2025):

@stoerr should be addressed with f890fe6901 in dev, testing wanted here!

<!-- gh-comment-id:3174890609 --> @tjbck commented on GitHub (Aug 11, 2025): @stoerr should be addressed with f890fe6901563d92e4aae649088f29b7ee33056c in dev, testing wanted here!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#56562