A tool call can say it failed, and what it is for, without a renderer
P1b's pure half (docs/RUST.md). Three pieces, all testable with no widget in sight: - `event_model::Event::ToolEnd` gains `is_error`, read from the CLI's own `tool_result` field by both the live translator and the import replay (`import::tool_result_is_error`, one reader so the two cannot disagree about the same conversation). Without it a result is all a card has, and a broken call draws exactly as confidently as one that worked -- the missing state, not a wrong one. `#[serde(default)]`, so an older transcript reads back as "not reported to have failed". - `client_core::transcript_fold::ToolState`: Running, Deciding, Succeeded, Failed, NoResult. The pair it exists for is the last two against Succeeded-with-empty-output -- a call that printed nothing and a call whose result never arrived leave the same empty string, and only the session's status separates "still going" from "nobody found out". - `client_core::tool_summary::parse_tool_input` and `client_core::durations`: `ToolInput.kt`'s subject/description/timeout split and `Durations.kt`'s span formatting, ported with their tests. The echo driver's three-call run now has a failing middle call, so the failed appearance is reachable from `ui-sandbox.sh` at all. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
69525bd131
commit
9079276ec8
9 files changed
+679
-4
No files matched your search
@@ -363,6 +363,22 @@ fn is_hidden(record: &Value) -> bool {
|
||||
|| record.get("isMeta").and_then(Value::as_bool) == Some(true)
|
||||
}
|
||||
|
||||
/// Whether a `tool_result` block says the call itself failed.
|
||||
///
|
||||
/// One reader for the field rather than one per caller: the live
|
||||
/// translator (`translate.rs`) and this replay of the CLI's own file look
|
||||
/// at the same block shape, and a call drawn as failed in one and as
|
||||
/// succeeded in the other would be the same conversation disagreeing with
|
||||
/// itself. Absent means "not reported to have failed" -- which is what the
|
||||
/// CLI writes for a call that went fine, and also what every transcript
|
||||
/// written before this field was read says.
|
||||
pub(crate) fn tool_result_is_error(block: &Value) -> bool {
|
||||
block
|
||||
.get("is_error")
|
||||
.and_then(Value::as_bool)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn text_of(content: &Value) -> String {
|
||||
match content {
|
||||
Value::String(text) => text.clone(),
|
||||
@@ -549,6 +565,7 @@ fn push_user(events: &mut Vec<Event>, content: &Value, session_dir: &std::path::
|
||||
events.push(Event::ToolEnd {
|
||||
id: id.to_string(),
|
||||
output: text_of(block.get("content").unwrap_or(&Value::Null)),
|
||||
is_error: tool_result_is_error(block),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user