Repository navigation
fix(models): surface terminal ChatStream errors to callers and scan status - #702
Merged
Merged
Conversation
Collaborator
|
Verified locally on head
Review notes:
No change requests. All four |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #701. Implements option 1 from the discussion, on top of the now-merged #695.
ChatStreamreturns one channel ofChatStreamEvent{Text, Err}. Text deltas arrive as before. A failed stream emits one terminal error event with empty text, then closes; a successful stream closes without an error event. Retry exhaustion and context cancellation also produce a terminal error. Retries before text and the abort-after-text behavior from #695 are preserved.The four consumers now check errors:
ChatResponsereturns the text accumulated so far and the original error.runner.Analysispreserves the screenshot and partial response, returns the error, and does not parse the aborted response into a vulnerability.SummaryChatreturns partial text and a wrapped error.SummaryResultreturns an error before parsing any issues, while keeping the emitted text in logs.The task layer reports interrupted analysis through the existing websocket-visible failed status and preserves partial text in the failure detail. It no longer sends a deferred completed status over that failure. The related model-generated scan summaries also check errors instead of storing truncated output as a successful summary.
This keeps valid base scan findings available. A concurrency-safe set counts failed targets once even when several analysis stages fail for the same target. Both final completion messages and the completed-tool description explicitly report incomplete analysis/results when that count is nonzero, while the affected analysis substep remains failed. The scan can return its partial results; one model failure does not discard all scan findings. No REST or websocket schema changes are needed.
Type of change
How was this tested?
Using Go 1.25.1 on Linux:
go build ./...: passed.go vet ./...: passed.go test ./... -count=1 -timeout=120s: 16 packages passed; the existingcommon/fingerprints/parser.TestSingleRuleForParsefailed. This test makes a live request tohttps://security.tencent.com/index.phpand dereferences the response after an unsuccessful request. The same failure was reproduced on unmodified main at3eb7b466.go test ./... -skip '^TestSingleRuleForParse$' -count=1 -timeout=120s: all 17 test-bearing packages passed.-race.-race, they expose an existing shared-state race ininternal/gologger.getCaller(minimumCallerDepth). A separate two-logger reproduction on unmodified main reproduced that race; no unrelated logger fix is included here.git diff --check: passed.Regression coverage includes clean and empty completion, interrupted streams with partial text, no replay after emitted text, retry exhaustion, cancellation before/after output and during backoff, token accounting before terminal delivery, failed reports whose tags happen to look complete, exactly one terminal task status, and zero/one/concurrent target failures with deduplicated English/Chinese partial-completion warnings.
Related issue
Fixes #701
Compatibility and limits
stringtoChatStreamEvent; repository call sites are migrated together.Checklist
go build ./...succeeds locally