Skip to main content
Open WebUI is a chat interface, not an agent framework. Keep it as the UI your people already use, and run the agent itself on AgentOS. A small Open WebUI Pipe function makes the AgentOS agent show up as a model in Open WebUI’s model list. Each message becomes an AgentOS run, so every conversation is logged, checked by guardrails, versioned and counted like any other run, and each Open WebUI user is the run’s end user.
Tested against the Pipe interface of Open WebUI v0.12.4. The agent passed the conformance kit, 12 checks including the streamed answer. The Pipe was tested by calling it the way Open WebUI does, against a stand-in for the AgentOS endpoints it uses: streaming, waiting, a held run, an error, and no run for Open WebUI’s background tasks. It hasn’t been run inside a live Open WebUI yet.

How it fits together

  • Open WebUI keeps the chat history, the users and the interface.
  • The Pipe sends the conversation to an AgentOS capability with a service account’s API key. It opens one AgentOS session per Open WebUI chat, with the Open WebUI user as the session’s end user.
  • The agent runs on AgentOS and streams its answer as plain text. Open WebUI shows it as it is written.

1. Deploy the agent

The agent answers the conversation it is given and streams the text through the gateway. Any agent works, as long as its capability takes {"messages": [...]}. To stream, it answers with plain text; otherwise it returns {"answer": "..."}.
The SDK wheel goes into vendor/ (see SDKs). Deploy it as webui-chat (see Deploying). For the streaming side of the agent, see Streaming answers.

2. Create an API key for Open WebUI

On the Users page, add a service account for Open WebUI, give it the member role in the agent’s environment, and create an API key. The key is shown once. See Users and API keys. The key stays on the Open WebUI server, in the Pipe’s settings. It never reaches the browser.

3. Add the Pipe to Open WebUI

In Open WebUI, open Admin Panel → Functions, create a new function, paste the code below and save it. Then open the function’s Valves (the gear icon) and set your AgentOS address, the API key, the environment, the agent and the capability. Enable the function: it appears in the model list under the function’s name.
agentos_pipe.py

What each message does

1

A session for the chat

The first message of an Open WebUI chat creates an AgentOS session with {"user": "<Open WebUI user id>"}. Later messages of the chat reuse it. Runs, memory and erasure are then per end user (see Sessions API).
2

A run per message

The Pipe sends the chat’s user and assistant messages as the input. Open WebUI’s own system prompt is left out: the agent’s prompt is part of its version on AgentOS.
3

The answer

With STREAM on, the run starts with ?passthrough=true and the agent’s text reaches the chat as it is written. Otherwise the run starts with ?wait=true and the Pipe shows output.answer. A run that waits for a person shows a short note with the run id, and an error shows AgentOS’s message.

Things to know

  • Background tasks don’t start runs. Open WebUI also calls the selected model to write chat titles, tags and follow-up suggestions. The Pipe returns nothing for those (__task__), so they don’t cost an agent run. To keep the generated titles, choose another model for them in Open WebUI’s admin settings.
  • The session map lives in memory. The Pipe remembers which AgentOS session belongs to which chat while Open WebUI runs. After a restart, a chat’s next message opens a new session. Nothing is lost, because Open WebUI sends the whole conversation every time.
  • One message at a time per chat. A session runs one turn at a time. A second message while the first is still running gets 409 session_busy from AgentOS, which the Pipe shows.
  • Approvals happen in AgentOS. When the agent asks a person, the run is held and the chat shows a note. The reviewer decides in the AgentOS Review queue.

Next steps

Runs API

Waiting, passthrough streaming and idempotency in detail.

Framework examples

Agents built with CrewAI, MCP and other frameworks.