Frun1na opened a new pull request, #6817:
URL: https://github.com/apache/rocketmq-dashboard/pull/6817
### Which Issue(s) This PR Fixes
- Fixes #6815
### Brief Description
`ClaudeCodeAgentProvider.stream` — the text-only channel `PromptEnhancer`
rewrites the operator's message through — rejected a non-zero exit (`:269-273`)
and a failure `result` subtype (`:274-279`, both #6681) but not a stream that
ended with **no** result frame at all. The deltas had already been forwarded to
the token consumer, and the method returned normally, so
`PromptEnhancer.enhance` kept the accumulated partial rewrite as the enhanced
prompt (`PromptEnhancer.java:105-106`) — it only falls back to the operator's
message when the channel throws (`:101-103`).
The event channel already treats that stream as a failure:
`AiRunExecutor.decide` reports it as `FAILED` / `llm.provider.no_result`
(`AiRunExecutor.java:513-514`, #6391). This adds the same rule to the text
channel: when `parser.resultFrameSeen()` is false, `stream` throws
`LlmGatewayException(502, "llm.provider.no_result", …)`, which makes the
enhancer return the untouched message.
User-visible behaviour: a prompt enhancement whose CLI dies before writing
its terminal frame now leaves the operator's own message in place instead of
replacing it with the truncated rewrite, matching what #6681 did for the
failure-subtype case.
### How Did You Test This Change?
```
$ ./wb test --filter ClaudeCodeAgentProviderTest
✓ 20.6s mvn -B -ntp test -DforkCount=1
-Dsurefire.failIfNoSpecifiedTests=false -Dtest=ClaudeCodeAgentProviderTest
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
The new case streams one `text_delta` frame from an `sh -c` stand-in for the
CLI and exits 0 without a result frame; it asserts the 502 /
`llm.provider.no_result` rejection and that the delta did reach the consumer
before the run was rejected, which is why the channel has to fail rather than
stay silent.
The new test fails without the fix:
```
Tests run: 20, Failures: 1, Errors: 0, Skipped: 0
... streamRejectsARunThatNeverDeliveredAResultFrameTest ... <<< FAILURE!
java.lang.AssertionError:
Expecting code to raise a throwable.
at
...ClaudeCodeAgentProviderTest.streamRejectsARunThatNeverDeliveredAResultFrameTest(ClaudeCodeAgentProviderTest.java:109)
```
That run is the branch with only the ten product lines reverted (`git stash
push` of `ClaudeCodeAgentProvider.java`) and the new test kept: `stream`
returns normally after streaming `partial rewrite`, so there is nothing left to
catch in `PromptEnhancer` and the operator's message is replaced by the partial
rewrite.
### Other consumers
- `PromptEnhancer.enhance` — the only production caller of this channel
(`PromptEnhancer.java:99`) — already handles a throwing channel by returning
`rawPrompt`; that is the path this change routes into.
- `AgentProvider.streamEvents` (the hosted-agent channel) is untouched: its
own no-result case is `AiRunExecutor.decide`'s `FAILED` /
`llm.provider.no_result` (#6391), and the exit-code-plus-no-frame check at
`ClaudeCodeAgentProvider.java:208` is unchanged.
- `AgentProvider.stream`'s default implementation (used by the Qoder engine)
is unchanged; it goes through `complete()` rather than parsing frames.
- The `llm.provider.no_result` spelling is the one the run row already
reports for the same condition (`AiRunExecutor.ERROR_CODE_NO_RESULT`), so the
two channels stay greppable by one code. The enhancement exception reaches no
REST surface — `PromptEnhancer` swallows it into a `log.warn` — and no frontend
code reads it.
- `OpenAiCompatibleLlmClient.stream` (the HTTP engine) is deliberately out
of scope: HTTP completion turns carry no result frame at all, which is the
exclusion `AiRunExecutor.decide` states for them.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
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]