Frun1na opened a new issue, #6815: URL: https://github.com/apache/rocketmq-dashboard/issues/6815
### Before Creating the Bug Report - [x] I have searched the [open issues](https://github.com/apache/rocketmq-dashboard/issues) of this repository and believe that this is not a duplicate. - [x] This is a defect in RocketMQ Studio, not a usage question and not a defect in another Apache RocketMQ repository. - [x] I can reproduce this on the current `rocketmq-studio` branch, or I have stated the exact version I am running below. ### Studio Version branch: rocketmq-studio git commit id: a92c2314 deployed as: reproduced by a unit test against that commit ### Runtime Environment OS: not applicable — the defect is in the agent provider's stream handling MySQL: not applicable — the defect is in the agent provider's stream handling browser (for UI issues): not required to observe it; the defect is in the server-side text channel ### Connected RocketMQ Cluster not applicable — the run under test spawns a local `sh -c` stand-in for the `claude` CLI, so no cluster is involved. The tool path is not reached: the enhancement rewrite is produced before the agent gets the prompt. ### Describe the Bug With the Claude Code engine and the composer's prompt-enhancement toggle on, a rewrite whose CLI goes away mid-turn — exit code 0, no terminal `result` frame — is accepted as a finished rewrite, so the agent is handed a truncated version of the operator's message instead of the message itself. `ClaudeCodeAgentProvider.stream` (`server/src/main/java/org/apache/rocketmq/studio/ops/ai/ClaudeCodeAgentProvider.java:243`) is the text-only channel `PromptEnhancer` uses. It already rejects a non-zero exit (`:269-273`) and a failure `result` subtype (`:274-279`), both added by #6681, and it only reads `parser.fallbackText()` when that frame exists (`:280-282`). A stream that ends **without** any result frame therefore passes every check: the deltas were forwarded to the token consumer as they arrived, and the method returns normally. The event channel does not call that stream a success. `AiRunExecutor.decide` fails it as `llm.provider.no_result` (`server/src/main/java/org/apache/rocketmq/studio/ops/ai/conversation/AiRunExecutor.java:513-514`, added by #6391 — "agent stream ended without a result frame"), so the same CLI output is a failed run on the hosted-agent path and an accepted completion on the enhancement path. That is exactly the outcome #6681 removed one layer up. `PromptEnhancer.enhance` only falls back to the operator's own text when the channel throws (`server/src/main/java/org/apache/rocketmq/studio/ops/ai/conversation/agent/PromptEnhancer.java:101-103`); when the channel returns, the accumulated rewrite is cleaned and used as the prompt (`:105-106`). Nothing in that path compares what was rewritten against the result frame, because there is none — so a partial rewrite reaches the agent as if it were the whole enhancement. ### Steps to Reproduce Run the provider against a CLI that streams one `text_delta` frame and exits 0 without a result frame: ```text sh -c 'printf <a stream_event/text_delta/partial rewrite frame> | base64 -d' ``` The regression test in the pull request does exactly this (`ClaudeCodeAgentProviderTest.streamRejectsARunThatNeverDeliveredAResultFrameTest`, the same `sh -c` standing in for the CLI that `ClaudeCodeAgentProviderTest.streamRejectsAFailedResultSubtypeDespiteExitZeroTest` uses). Against the current branch the call returns normally and the single delta — `partial rewrite` — has already been handed to the token consumer. Reproducing it end to end needs a provider that dies without printing its terminal frame, which is the input #6391 was reported with; the unit test pins the same input deterministically. ### What Did You Expect to See? The text channel rejects the run, the way the event channel does for the same stream: `stream` throws `LlmGatewayException(502, "llm.provider.no_result", …)`, `PromptEnhancer.enhance` catches it and returns the operator's original message (`PromptEnhancer.java:103`), and the run continues with the prompt the operator typed. ### What Did You See Instead? `stream` returned normally after streaming the partial rewrite, `PromptEnhancer` kept it as the enhanced prompt, and the agent answered a truncated rewrite of the operator's message instead of the message. The only trace is the enhancement block in the transcript ending mid-sentence. ### Additional Context A fix with a regression test follows in a pull request. ### Are You Willing to Submit a Pull Request? - [x] Yes, I am willing to submit a pull request. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
