False "Failed to do the job" when AI agent output contains the literal run-prompt marker: markers should be per-run nonces, not constant strings #3308
skudr opened 8 hours ago

Summary

In Task Automation for AI users, DefaultWorkspaceService.openPromptShell decides whether a workspace task succeeded or failed by searching for two constant strings - the constants RUN_PROMPT_SUCCESS_MARKER and RUN_PROMPT_FAILURE_MARKER, with literal values __ONEDEV_RUN_PROMPT_ + SUCCESS__ and __ONEDEV_RUN_PROMPT_ + FAILURE__ - in a rolling 1024-character buffer of the workspace terminal output. The markers are shared constants: the same strings for every workspace, every spec and every run.

If the agent's own output printed to that terminal happens to contain the literal marker text - for example, an agent reading an issue body that contains it as a test-fixture string - OneDev posts a failure ("Failed to do the job, please open workspace #N for details") while the agent is still working. The symmetrical case is worse: a literal SUCCESS marker printed by the agent causes the workspace to be silently deleted as a success (when "Delete Workspace If Succeeded" is enabled).

PosixShell.printMarker deliberately splits the marker into two printf arguments, so echoing the generated task script does not trigger a match - but the agent's own output is not protected, and detection never consults the exit code: any matching text from any source in the stream decides the outcome.

Real-world impact (measured)

On our OneDev 17.2.4 instance (an AI-assisted development pipeline, three AI users, ~234 workspaces in one week):

  • 15 executor workspaces received the failure comment within 10-56 s of workspace activation; in 9 of 15 the agent demonstrably kept working afterwards - in two cases we captured live processes running for minutes after the marker.
  • Two tasks failed deterministically, 4/4 and 3/3 attempts, each within 10-17 s of activation. Both task bodies contain the literal FAILURE marker (one as a test-fixture string); no other task body in the window contains it, and those tasks never failed before it appeared in their bodies.
  • Failed workspaces are destroyed by our supervision, so the terminal buffer is lost; the cause was confirmed by reading the source plus the minimal repro below.

Minimal repro

  1. Provision a workspace with a Task Automation spec (POSIX shell).
  2. Make the agent print the literal FAILURE marker to the terminal (a stub agent binary echoing it is enough).
  3. The server posts the failure comment although the task command never failed; with the SUCCESS marker instead, the workspace is deleted as successful.

Expected behavior

The marker OneDev watches for should be unique per run, not a constant string shared across all workspaces. Alternatives, in decreasing preference:

  1. Per-run nonce marker: generate a random nonce when the task starts, pass it to the generated wrapper, expect exactly that nonce back in the output.
  2. Detection via a structured channel (exit-code file, dedicated IPC) instead of terminal-output scraping.
  3. At minimum: document that the marker must never appear in agent-visible output, and detect/warn on collisions.

Our current workaround is a stream filter on the agent's stdout that breaks up marker-like lines before they reach the panel; it is fragile, spec-local, and cannot protect the SUCCESS case in third-party setups.

Environment

  • OneDev 17.2.4 (server-docker workspace provisioner, POSIX shell spec); re-verified unchanged on main commit 52616e9 (2026-12-05, includes release 17.2.8).
  • Third-party agent CLI image; Task Automation and "Delete Workspace If Succeeded" enabled.

Happy to provide full timelines and the repro script.

  • Robin Shen commented 20 minutes ago

    Checking the output directly from terminal provides the most simple and consistent implementation across various workspace provisioning implementations. In practice, an agent is not likely to output __ONEDEV_RUN_PROMPT_SUCCESS__ if not doing it intentionally. . Please share a case without deliberately outputing the full marker (SUCCESS or FAILURE alone will not match the full marker).

1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
17.2.4
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-3308
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover