feat(runtime): implement JSON repair function for truncated tool-call arguments

This commit is contained in:
asepharyana
2026-07-15 01:42:15 +07:00
parent 4b16bc3112
commit e13f040833
3 changed files with 371 additions and 20 deletions
+21
View File
@@ -182,3 +182,24 @@ fn claude_credentials_from_env() -> Option<(String, String)> {
let key = std::env::var("ANTHROPIC_API_KEY").ok()?;
Some((base_url, key))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn claude_credentials_from_env_resolves_real_env_vars() {
// In the test runner's environment ANTHROPIC_BASE_URL and
// ANTHROPIC_API_KEY may or may not be set — we only verify that
// the function returns Some(..) when both are present.
let (b, k) = match claude_credentials_from_env() {
Some(v) => v,
None => {
// Not an error: CI / local without the vars.
return;
}
};
assert!(!b.is_empty(), "ANTHROPIC_BASE_URL must not be empty");
assert!(!k.is_empty(), "ANTHROPIC_API_KEY must not be empty");
}
}