refactor(#2359): bare Deserialize derive + clarify error to_string scan
This commit is contained in:
parent
71c8b14633
commit
7964d45a27
1 changed files with 6 additions and 2 deletions
|
|
@ -54,7 +54,7 @@ const SESSION_NOT_FOUND_MARKERS: [&str; 2] = [
|
||||||
/// so a field-shape drift is a compile error / a clean fallback rather than a
|
/// so a field-shape drift is a compile error / a clean fallback rather than a
|
||||||
/// silent mis-detection. Unknown event types fall into [`StreamEvent::Other`]
|
/// silent mis-detection. Unknown event types fall into [`StreamEvent::Other`]
|
||||||
/// (scanned raw like any other control event).
|
/// (scanned raw like any other control event).
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(tag = "type", rename_all = "snake_case")]
|
#[serde(tag = "type", rename_all = "snake_case")]
|
||||||
enum StreamEvent {
|
enum StreamEvent {
|
||||||
/// Model-authored turn output — never scanned (it can quote any marker).
|
/// Model-authored turn output — never scanned (it can quote any marker).
|
||||||
|
|
@ -77,7 +77,7 @@ enum StreamEvent {
|
||||||
/// error signal — `is_error` is the discriminator (the CLI sets it from the
|
/// error signal — `is_error` is the discriminator (the CLI sets it from the
|
||||||
/// real outcome; the model can't forge it). On `is_error` the `result` /
|
/// real outcome; the model can't forge it). On `is_error` the `result` /
|
||||||
/// `error` fields carry claude-code's own failure text.
|
/// `error` fields carry claude-code's own failure text.
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct ResultEvent {
|
struct ResultEvent {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
is_error: bool,
|
is_error: bool,
|
||||||
|
|
@ -152,6 +152,10 @@ impl Sentinels {
|
||||||
self.scan_failure_markers(text);
|
self.scan_failure_markers(text);
|
||||||
}
|
}
|
||||||
if let Some(err) = &r.error {
|
if let Some(err) = &r.error {
|
||||||
|
// `to_string()` re-serializes the JSON value (a string
|
||||||
|
// value round-trips to `"...quoted..."`), but the marker
|
||||||
|
// substring still appears inside the quoted form, so the
|
||||||
|
// scan finds it either way.
|
||||||
self.scan_failure_markers(&err.to_string());
|
self.scan_failure_markers(&err.to_string());
|
||||||
}
|
}
|
||||||
// Typed 401: an auth failure that set the status code but
|
// Typed 401: an auth failure that set the status code but
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue