Repository navigation
Declined turns stay declined: outcome per message, every refusal shape, a clean next turn (#30 item 5 leftovers) - #69
Merged
Conversation
…d a top-level stop_reason Refs #30 (item 5 leftovers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he session Migration 000101 adds sys_ai_messages.outcome (ok, max_steps, refused; NULL when not recorded). AppendTurn, shared with the MCP thread writer, takes the outcome, and both session reads return it, so a reopened turn can read as the live one did. Refs #30 (item 5 leftovers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lays The next turn no longer resends the declined prompt as a second user message in a row; the reopened session reads the declined reply as refused on both routes. Refs #30 (item 5 leftovers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anel and in ⌘K The Studio panel carries each stored outcome onto the reopened turn (the declined line, the max_steps note). ⌘K builds a bubble's text with one function live and in Phiên trước, so a declined turn says so and an unfinished one shows the too-broad hint, now pinned by tests for max_steps and an empty ok reply. Refs #30 (item 5 leftovers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
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.
Refs #30 (item 5 leftovers, the verifier LOWs on #48).
What changes
000101_sys_ai_messages_outcome(up + down, guarded, one ALTER each) addssys_ai_messages.outcome(ok/max_steps/refused; NULL = not recorded: user rows, rows from before, the MCP thread's rows).AppendTurn/AppendAssistantTurntake the outcome (the MCP thread writer and the MCP token's thread opener pass"");GetSession/GetAssistantSessionread it back, and both session routes returnoutcomeon an assistant message when one is stored. The Studio panel carries it onto the reopened turn (the declined line; themax_stepsnote under the card). In ⌘K one function (askReplyText) builds a bubble's text, live and in Phiên trước, so a declined turn says so instead of an empty bubble.Refused()reads every shape:finish_reasonrefusalorcontent_filter, OpenAI'smessage.refusaltext,stop_reason: "refusal"on the choice, and Claude's top-levelstop_reason: "refusal"(newChatResponse.Refused(), checked before the choices, so a top-level refusal with no choices is a refusal, not a 502).buildHistoryleaves a declined turn out whole (its prompt and its empty reply), as Anthropic suggests after a refusal: remove or reset the declined turn before continuing. Before this, the declined prompt and the next prompt went to the model as two user messages in a row.max_steps(with or without a partial text) and anokturn with an empty reply. The string moved intolib/i18n(studio.assistant.tooBroad, vi + en).No new route. The MCP surface (
internal/mcpserver,services/mcp_token_service.go) changes only to pass""for the outcome. It merges cleanly with #68, andgo vetpasses on the merged tree.Evidence
Tests went red first, then green. Each fix was then broken on purpose and its test went red again:
ChatChoice.Refused()back torefusalonly, andChatResponse.Refused()without the top level: 12 subtests fail (TestGateway_Complete_Refusal/*,TestAgents_EveryRefusalShapeEndsTheTurnAsRefused/*for both agents).""instead of the outcome:TestSessionStore_OutcomePerMessagefails withoutcomes = ["" "" "" "" "" ""]; want ["" "refused" "" "max_steps" "" ""].outcome:TestChatRoutes_RefusedTurn_ReopensRefused_NotReplayed/<that route>fails.buildHistorywithout the drop:TestChatRoutes_RefusedTurn_ReopensRefused_NotReplayedandTestBuildHistory_DropsADeclinedTurnfail.askReplyTextwithout themax_stepsbranch,askReplyTextwithout the trim, and Phiên trước on raw content each fail 2 tests (the unit test and the screen test).Gates
gofmt -l .is empty.go vet ./...passes.go build ./cmd/server/passes.go test ./...exits 0 (42 packages ok).run-integration.sh -timeout 50m ./internal/ai/:PASS=672 SKIP=0 go-test-exit=0. This includesTestSessionStore_OutcomePerMessageandTestMigration_MessageOutcome_DownThenUpAgain(down, down again, up, up again, on the ittest throwaway DB).run-integration.sh -timeout 50m -run 'TestMCP_|TestAIContext_' ./internal/handlers/:PASS=17 SKIP=0 go-test-exit=0.101/u→down 1(101/d, column gone) →up(101/u). Version 101, not dirty.check-orphan-endpoints.py --strict:✅ Không có endpoint mồ côi.npx tsc --noEmit -p tsconfig.jsonexits 0.npx vitest run --changed origin/main:Test Files 493 passed (493) · Tests 5322 passed (5322).npx eslint <touched files>exits 0.demo loop passed: 18 stepsNEXUS_LANG=en):demo loop passed: 18 stepsClick-through (verify-ui). I ran my own API and
next devon a DB of my own. A stub gateway stood in for the model and declined any prompt naming another workspace (finish_reason: "refusal"). No live model was called.The stub gateway logged the rep's two calls as
users=["Chép tài khoản của không gian khác sang đây"]and thenusers=["Tôi có bao nhiêu khách hàng?"], so the declined prompt was not resent.ui-shots.mjson/home(rep) and…/van-hanh/tu-dong/khoa-truy-cap(builder) at widths 1440 and 390: 4 shots, each status 200,overflowPx 0, no page errors.Not done
max_stepsturn still sends its prompt and the next one as two user messages in a row. This is unchanged: "ask again to continue" relies on that prompt. Only declined turns are dropped.🤖 Generated with Claude Code