Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .repository-projection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"projection": "deixic-code",
"projectionSchemaVersion": 1,
"sourceRepository": "dx-corp/mono",
"sourceSha": "ac693f34cdb782d83afd46151bf3a25a2df324be",
"sourceSha": "4c3e830640c4066c99303b7582fa2bdb74095f0d",
"destinationRepository": "dx-corp/code",
"priorProjectedBase": "1f00b9e589e080257b8366fc0884453e2596ce90",
"priorProjectedBase": "ca90e530cac35a9d63eac51f920d58891a511b21",
"definitionDigest": "82936441c776e3e8edb5d215a75007ec9714a233f489d460075d79d5ef5ba32f",
"toolDigest": "c244d99199a7ae3eb8ff644a99462163c23b0bb6a83ef50af01efbdca0b81d04",
"contentDigest": "42d4d938700f91af78522c50de4f281b3d06804428a6744df1f37d0cd3ddc839",
"contentDigest": "f684b3dd9cbf2e4f672beaa7d0c536d87035881e1cdb7f5d28afeebe1e49b530",
"publicationEligible": true
}
59 changes: 57 additions & 2 deletions packages/dex-host-rs/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl ChunkTranslator {
Ok(value) => value,
Err(error) => {
return vec![Err(ModelError {
class: dex_loop::ErrorClass::Protocol,
message: format!(
"provider returned invalid tool-call JSON for {name}: {error}"
),
Expand All @@ -202,8 +203,25 @@ impl ChunkTranslator {
// Not attributed here; see the module doc comment.
cost_micros: 0,
}))],
StreamEvent::ProviderError { message, .. } | StreamEvent::Error { message } => {
vec![Err(ModelError { message })]
StreamEvent::ProviderError { kind, message } => {
use maestro_ai::ProviderStreamErrorKind;
let class = match kind {
ProviderStreamErrorKind::TransientProtocol => dex_loop::ErrorClass::Truncated,
ProviderStreamErrorKind::OutputTokenExhaustion
| ProviderStreamErrorKind::IncompleteResponse => {
dex_loop::ErrorClass::Incomplete
}
ProviderStreamErrorKind::ProviderDeclaredFailure => {
dex_loop::ErrorClass::Unknown
}
};
vec![Err(ModelError { class, message })]
}
StreamEvent::Error { message } => {
vec![Err(ModelError {
class: dex_loop::ErrorClass::Unknown,
message,
})]
}
_ => Vec::new(),
}
Expand Down Expand Up @@ -234,6 +252,7 @@ impl dex_loop::Model for AiRsModel {
}
Err(error) => {
let _ = tx.send(Err(ModelError {
class: dex_loop::ErrorClass::Unknown,
message: format!("{error:#}"),
}));
}
Expand All @@ -258,6 +277,42 @@ mod tests {
}
}

#[test]
fn failure_class_comes_from_the_provider_kind_not_display_words() {
use maestro_ai::ProviderStreamErrorKind;
for (kind, expected) in [
(
ProviderStreamErrorKind::TransientProtocol,
dex_loop::ErrorClass::Truncated,
),
(
ProviderStreamErrorKind::OutputTokenExhaustion,
dex_loop::ErrorClass::Incomplete,
),
(
ProviderStreamErrorKind::IncompleteResponse,
dex_loop::ErrorClass::Incomplete,
),
(
ProviderStreamErrorKind::ProviderDeclaredFailure,
dex_loop::ErrorClass::Unknown,
),
] {
let errors = ChunkTranslator::default().translate(StreamEvent::ProviderError {
kind,
message: "budget auth 429 refusal".into(),
});
assert_eq!(errors[0].as_ref().unwrap_err().class, expected);
}
let errors = ChunkTranslator::default().translate(StreamEvent::Error {
message: "budget auth 429 refusal".into(),
});
assert_eq!(
errors[0].as_ref().unwrap_err().class,
dex_loop::ErrorClass::Unknown
);
}

#[test]
fn retains_provider_reported_cache_usage() {
let chunks = ChunkTranslator::default().translate(StreamEvent::Usage {
Expand Down
1 change: 1 addition & 0 deletions packages/dex-host-rs/src/turn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ mod tests {
.pop_front()
.unwrap_or_else(|| {
vec![Err(ModelError {
class: dex_loop::ErrorClass::Unknown,
message: "no script left".into(),
})]
});
Expand Down
1 change: 1 addition & 0 deletions packages/dex-host-rs/tests/turn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Model for ScriptedModel {
.pop_front()
.unwrap_or_else(|| {
vec![Err(ModelError {
class: dex_loop::ErrorClass::Unknown,
message: "no script left".into(),
})]
});
Expand Down
Loading
Loading