[GH-ISSUE #152] bug: Agent fabricates user turns and self-executes tools (runaway) — history flattened into in-band [role] transcript with no turn-boundary stop #78

Closed
opened 2026-10-18 14:02:42 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @penradioGables on GitHub (Jul 17, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/152

Version: cptr 0.9.8 (ghcr.io/open-webui/computer, digest sha256:9a2f8db19636a3426fab3e030a88d967bd2b742df622b0bdd5c00f83d5581f72)
Backend: Claude Code profile (claude-sonnet-4-6) via Open WebUI Chat Completions gateway

(Correction: originally reported as Codex — verified against the actual DB row for this chat; the model field shows agent:claude-code/claude-sonnet-4-6. The underlying flatten-to-string mechanism is identical in both adapters — see claude_code.py:_prompt_from_messages and codex.py:_messages_to_prompt below — so this affects both backends, but this specific incident ran on Claude Code.)

Summary

Conversation history is flattened into a single string of `[user]
…

[assistant]
… (claude_code.py:_prompt_from_messages~L22; same pattern incodex.py:_messages_to_prompt~L212) and sent as ONE turn input. Because prior turns are presented as an in-band transcript and no stop sequence is registered on the[user]delimiter, the model continues the transcript — emitting a fabricated[user]` message and then answering it, including real tool calls that execute.

Steps to reproduce

  1. Connect Open WebUI to cptr (Chat Completions), Claude Code profile.
  2. In one chat, send ~13 consecutive low-information messages: "1","2",…,"13".
  3. Observe an assistant turn that (a) emits literal [user]/[assistant] text and a fabricated multi-turn dialogue, and (b) executes tools for the invented request.

Expected

The assistant answers only the latest user message; it cannot author user turns.

Actual

One turn produced 26 output items over ~42s vs. ~2 items normally; wrote and ran a file (hello.py) for a request the user never made.

Evidence: task log:

[task 9f72e3a9] db save (agent done) begin: done=True content=5020 chars output=26 items … {'reasoning':5,'message':7,'function_call':7,'function_call_output':7}

DB row confirms model=agent:claude-code/claude-sonnet-4-6. Saved assistant content contains `

[user]
Hi

[assistant]…` matching the flatten template referenced above.

Suggested fix

Pass structured multi-turn messages to the backend (both the Claude Agent SDK and the Codex app-server protocol accept them) instead of flattening to a string; and/or register the role delimiter as a stop sequence; and/or use the backend's native session continuity instead of replaying a transcript each turn.

Originally created by @penradioGables on GitHub (Jul 17, 2026). Original GitHub issue: https://github.com/open-webui/computer/issues/152 **Version:** cptr 0.9.8 (ghcr.io/open-webui/computer, digest sha256:9a2f8db19636a3426fab3e030a88d967bd2b742df622b0bdd5c00f83d5581f72) **Backend:** Claude Code profile (claude-sonnet-4-6) via Open WebUI Chat Completions gateway *(Correction: originally reported as Codex — verified against the actual DB row for this chat; the model field shows `agent:claude-code/claude-sonnet-4-6`. The underlying flatten-to-string mechanism is identical in both adapters — see `claude_code.py:_prompt_from_messages` and `codex.py:_messages_to_prompt` below — so this affects both backends, but this specific incident ran on Claude Code.)* ## Summary Conversation history is flattened into a single string of `[user] … [assistant] …` (`claude_code.py:_prompt_from_messages` ~L22; same pattern in `codex.py:_messages_to_prompt` ~L212) and sent as ONE turn input. Because prior turns are presented as an in-band transcript and no stop sequence is registered on the `[user]` delimiter, the model continues the transcript — emitting a fabricated `[user]` message and then answering it, including real tool calls that execute. ## Steps to reproduce 1. Connect Open WebUI to cptr (Chat Completions), Claude Code profile. 2. In one chat, send ~13 consecutive low-information messages: "1","2",…,"13". 3. Observe an assistant turn that (a) emits literal `[user]`/`[assistant]` text and a fabricated multi-turn dialogue, and (b) executes tools for the invented request. ## Expected The assistant answers only the latest user message; it cannot author user turns. ## Actual One turn produced 26 output items over ~42s vs. ~2 items normally; wrote and ran a file (`hello.py`) for a request the user never made. **Evidence:** task log: ``` [task 9f72e3a9] db save (agent done) begin: done=True content=5020 chars output=26 items … {'reasoning':5,'message':7,'function_call':7,'function_call_output':7} ``` DB row confirms `model=agent:claude-code/claude-sonnet-4-6`. Saved assistant content contains ` [user] Hi [assistant]…` matching the flatten template referenced above. ## Suggested fix Pass structured multi-turn messages to the backend (both the Claude Agent SDK and the Codex app-server protocol accept them) instead of flattening to a string; and/or register the role delimiter as a stop sequence; and/or use the backend's native session continuity instead of replaying a transcript each turn.
Author
Owner

@owui-terminator[bot] commented on GitHub (Jul 17, 2026):

⚠️ Missing Issue Title Prefix

@penradioGables, your issue title is missing a categorising prefix (e.g. bug:, feat:, docs:).

Please update the title to lead with one of:

  • bug: bug report or error
  • feat: feature request or enhancement
  • docs: documentation issue
  • question: usage question
  • help: support request

Example: bug: Login fails when the password contains special characters

<!-- gh-comment-id:4998147523 --> @owui-terminator[bot] commented on GitHub (Jul 17, 2026): # ⚠️ Missing Issue Title Prefix @penradioGables, your issue title is missing a categorising prefix (e.g. `bug:`, `feat:`, `docs:`). Please update the title to lead with one of: - **bug**: bug report or error - **feat**: feature request or enhancement - **docs**: documentation issue - **question**: usage question - **help**: support request Example: `bug: Login fails when the password contains special characters`
Author
Owner

@owui-terminator[bot] commented on GitHub (Jul 17, 2026):

🔍 Related Issues Found

I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:

  1. 🟣 #50 Gateway connection hangs in OpenWebUI
    This issue also reports broken behavior when cptr is used through OpenWebUI, including repeated chat-completion calls and the assistant hanging or producing nonsense. It suggests the OpenWebUI integration/prompting path is problematic, which is close to the runaway transcript/tool-use symptom in #152.
    by naqerl

  2. 🟣 #77 Openweb UI implementation not working properly
    This issue is about the OpenWebUI integration not behaving correctly and the assistant returning clearly wrong persona/context, while cptr itself works. It is related as a prior report that the OpenWebUI-backed chat flow is mishandling conversation context.
    by thgilciffart


💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.

This comment was generated automatically. React with 👍 if helpful, 👎 if not.

<!-- gh-comment-id:4998148577 --> @owui-terminator[bot] commented on GitHub (Jul 17, 2026): <!-- terminator-bot:related-issues-reply --> 🔍 **Related Issues Found** I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions: 1. 🟣 [#50](https://github.com/open-webui/computer/issues/50) **Gateway connection hangs in OpenWebUI** *This issue also reports broken behavior when cptr is used through OpenWebUI, including repeated chat-completion calls and the assistant hanging or producing nonsense. It suggests the OpenWebUI integration/prompting path is problematic, which is close to the runaway transcript/tool-use symptom in #152.* *by naqerl* 2. 🟣 [#77](https://github.com/open-webui/computer/issues/77) **Openweb UI implementation not working properly** *This issue is about the OpenWebUI integration not behaving correctly and the assistant returning clearly wrong persona/context, while cptr itself works. It is related as a prior report that the OpenWebUI-backed chat flow is mishandling conversation context.* *by thgilciffart* --- 💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead. *This comment was generated automatically.* React with 👍 if helpful, 👎 if not.
Author
Owner

@tjbck commented on GitHub (Jul 18, 2026):

Should be addressed!

<!-- gh-comment-id:5010223011 --> @tjbck commented on GitHub (Jul 18, 2026): Should be addressed!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/computer#78
No description provided.