fix(claw): state why a turn failed
android / debug (push) Successful in 2m39s
ci / docker (push) Canceled after 0s
android / release (push) Canceled after 1m54s
ci / checks (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / chart (push) Canceled after 0s
ci / web (push) Canceled after 0s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Canceled after 0s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Canceled after 0s
ci / publish-edge-chart (push) Canceled after 0s
android / debug (push) Successful in 2m39s
ci / docker (push) Canceled after 0s
android / release (push) Canceled after 1m54s
ci / checks (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / chart (push) Canceled after 0s
ci / web (push) Canceled after 0s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Canceled after 0s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Canceled after 0s
ci / publish-edge-chart (push) Canceled after 0s
A failed turn reached the client as the bare word "failed": turn_done
carried only the outcome, so the provider's own error — the status line
and the body that name what went wrong — was dropped on the floor. The
session inventory did keep it, as {"Failed": reason}, but the web client
printed that object, and a read-only snapshot (a coding job's key, a
forge thread) hardcoded the label and lost the text entirely.
TurnDone gains a reason, set only on failure and omitted when absent, so
handled and steered frames stay byte-identical and rows recorded before
the field still replay. The stashed transcript carries it too, which is
the path job keys take. The web client renders it under the outcome word
in mono and full-wrap, and the session-info modal reads the inventory's
{"Failed": reason} into a last-failure row instead of showing JSON.
cargo test -p rhema-claw and nuxt typecheck pass; a failed turn renders
its complete reason in the transcript.
This commit is contained in:
1 parent
ec52ae90b2
commit
597c2a98d2
10 files changed
+158
-40
No files matched your search
@@ -430,13 +430,29 @@ const userInitial = computed(() => (userLabel.value === 'you' ? 'Y' : 'D'))
|
||||
// The dispatch internals live behind the info modal, not in the header.
|
||||
const infoOpen = ref(false)
|
||||
|
||||
const infoRows = computed(() => [
|
||||
{ label: 'state', value: props.session?.state ?? 'unknown' },
|
||||
{ label: 'revision', value: props.session ? String(props.session.revision) : 'unknown' },
|
||||
{ label: 'inbox depth', value: props.session ? String(props.session.inbox_depth) : 'unknown' },
|
||||
{ label: 'last outcome', value: props.session?.last_outcome ?? 'unknown' },
|
||||
{ label: 'key', value: props.activeKey },
|
||||
])
|
||||
/** The inventory's `last_outcome`, read out of the dispatcher's own
|
||||
* serialization: a bare variant name, or `{"Failed": "reason"}`. The
|
||||
* failure's reason gets its own row so the modal does not show JSON. */
|
||||
const lastOutcome = computed(() => {
|
||||
const value = props.session?.last_outcome
|
||||
if (value === null || value === undefined) return { outcome: 'unknown', reason: null }
|
||||
if (typeof value === 'string') return { outcome: value.toLowerCase(), reason: null }
|
||||
return { outcome: 'failed', reason: value.Failed }
|
||||
})
|
||||
|
||||
const infoRows = computed(() => {
|
||||
const rows = [
|
||||
{ label: 'state', value: props.session?.state ?? 'unknown' },
|
||||
{ label: 'revision', value: props.session ? String(props.session.revision) : 'unknown' },
|
||||
{ label: 'inbox depth', value: props.session ? String(props.session.inbox_depth) : 'unknown' },
|
||||
{ label: 'last outcome', value: lastOutcome.value.outcome },
|
||||
]
|
||||
if (lastOutcome.value.reason !== null) {
|
||||
rows.push({ label: 'last failure', value: lastOutcome.value.reason })
|
||||
}
|
||||
rows.push({ label: 'key', value: props.activeKey })
|
||||
return rows
|
||||
})
|
||||
|
||||
const streamLabel = computed(() =>
|
||||
props.streamStatus === 'open' ? 'live' : props.streamStatus,
|
||||
@@ -544,7 +560,8 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
||||
aborted: item.turn.outcome === 'aborted',
|
||||
}"
|
||||
>
|
||||
{{ item.turn.outcome }}
|
||||
<span class="outcome-word">{{ item.turn.outcome }}</span>
|
||||
<p v-if="item.turn.reason" class="outcome-reason">{{ item.turn.reason }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -863,23 +880,46 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
||||
}
|
||||
|
||||
.outcome {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-1);
|
||||
margin-top: var(--sp-1);
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.outcome.failed {
|
||||
.outcome-word {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.outcome.failed .outcome-word {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.outcome.steered {
|
||||
.outcome.steered .outcome-word {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.outcome.aborted {
|
||||
.outcome.aborted .outcome-word {
|
||||
color: var(--warn);
|
||||
}
|
||||
|
||||
/* The failure's own words, kept whole: a provider error names the
|
||||
* endpoint, the status, and the body, and wrapping is what makes all of
|
||||
* it readable. */
|
||||
.outcome-reason {
|
||||
margin: 0;
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border-left: 2px solid var(--border-strong);
|
||||
border-radius: 0 var(--r-control) var(--r-control) 0;
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
line-height: var(--lh-body);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.working {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -86,7 +86,19 @@ export type TurnEvent =
|
||||
| ({ type: 'consent_request' } & ConsentRequest)
|
||||
| { type: 'consent_resolved'; id: string; granted: boolean }
|
||||
| ({ type: 'attachment' } & ClawAttachment)
|
||||
| { type: 'turn_done'; reply: string | null; outcome: string }
|
||||
| {
|
||||
type: 'turn_done'
|
||||
reply: string | null
|
||||
outcome: string
|
||||
/** Why a `failed` turn failed: the handler's own words. null on
|
||||
* every other outcome, and on rows recorded before the field. */
|
||||
reason: string | null
|
||||
}
|
||||
|
||||
/** A recorded outcome as the dispatcher serializes it: a bare variant
|
||||
* name for `Handled` and `Superseded`, `{"Failed": "reason"}` for a
|
||||
* failure. null when the key never released. */
|
||||
export type WireOutcome = string | { Failed: string } | null
|
||||
|
||||
/** One entry of `GET /v1/sessions` (http.rs `sessions`). */
|
||||
export interface ClawSession {
|
||||
@@ -94,7 +106,7 @@ export interface ClawSession {
|
||||
state: string
|
||||
revision: number
|
||||
inbox_depth: number
|
||||
last_outcome: string | null
|
||||
last_outcome: WireOutcome
|
||||
/** Whether the pause gate holds the key: queued work waits, nothing
|
||||
* dispatches, until resume lifts the hold. */
|
||||
paused: boolean
|
||||
@@ -1250,6 +1262,7 @@ function parseTurnEvent(data: string): TurnEvent | null {
|
||||
type: 'turn_done',
|
||||
reply: typeof raw.reply === 'string' ? raw.reply : null,
|
||||
outcome: String(raw.outcome ?? ''),
|
||||
reason: typeof raw.reason === 'string' ? raw.reason : null,
|
||||
}
|
||||
default:
|
||||
return null
|
||||
|
||||
@@ -39,6 +39,9 @@ export interface TurnBlock {
|
||||
entries: TurnEntry[]
|
||||
/** Set by `turn_done`: `handled`, `failed`, or whatever the claw reports. */
|
||||
outcome: string | null
|
||||
/** Set by `turn_done` on a failure: the handler's own words on why
|
||||
* the turn broke. null for every other outcome. */
|
||||
reason: string | null
|
||||
}
|
||||
|
||||
/** One thing the agent asked its human, as the card renders it. */
|
||||
@@ -230,7 +233,7 @@ export function useTranscript() {
|
||||
const pendingSent: { text: string; images: number; itemId: number }[] = []
|
||||
|
||||
function ensureLive(): TurnBlock {
|
||||
if (!live.value) live.value = { reply: '', entries: [], outcome: null }
|
||||
if (!live.value) live.value = { reply: '', entries: [], outcome: null, reason: null }
|
||||
return live.value
|
||||
}
|
||||
|
||||
@@ -371,6 +374,7 @@ export function useTranscript() {
|
||||
case 'turn_done': {
|
||||
const turn = ensureLive()
|
||||
turn.outcome = event.outcome
|
||||
turn.reason = event.reason
|
||||
// The clean end marker wins for the reply: deltas may have been
|
||||
// dropped (best-effort stream), turn_done carries the final text.
|
||||
if (event.reply !== null) turn.reply = event.reply
|
||||
|
||||
Reference in new issue
Block a user