The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(triage): replace inline trailing-comma fix with shared utility
Steven Enamakel7c0dfc23065b
diff --git a/crates/openhuman-core/src/agent/triage/decision.rs b/crates/openhuman-core/src/agent/triage/decision.rsindex 6d0f2f0532..1f5d26c304 100644--- a/crates/openhuman-core/src/agent/triage/decision.rs+++ b/crates/openhuman-core/src/agent/triage/decision.rs@@ -27,6 +27,7 @@use serde::Deserialize;use thiserror::Error;+use tinytools_agent::repair::json::strip_trailing_commas;/// The four outcomes the triage agent is allowed to choose.#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]@@ -225,53 +226,6 @@ fn last_balanced_brace_object(text: &str) -> Option<String> {best.map(|(s, e)| text[s..e].to_string())}-/// Strip trailing commas before closing `}` / `]` — a very common-/// small-model mistake that otherwise trips `serde_json`.-fn strip_trailing_commas(src: &str) -> String {- let mut out = String::with_capacity(src.len());- let mut in_string = false;- let mut escape = false;- let bytes = src.as_bytes();- let mut i = 0;- while i < bytes.len() {- let b = bytes[i];- if in_string {- out.push(b as char);- if escape {- escape = false;- } else if b == b'\\' {- escape = true;- } else if b == b'"' {- in_string = false;- }- i += 1;- continue;- }- if b == b'"' {- in_string = true;- out.push('"');- i += 1;- continue;- }- if b == b',' {- // Look ahead past whitespace for the next non-ws char.- let mut j = i + 1;- while j < bytes.len() && (bytes[j] as char).is_whitespace() {- j += 1;- }- if j < bytes.len() && (bytes[j] == b'}' || bytes[j] == b']') {- // Drop the comma; continue from the whitespace so the- // preserved indentation lands in `out` naturally.- i += 1;- continue;- }- }- out.push(b as char);- i += 1;- }- out-}-/// Rewrite `"action": "Drop"` / `"action": "ESCALATE"` as/// `"action": "drop"` / `"action": "escalate"` so serde's/// `rename_all = "lowercase"` attribute accepts whatever casing thediff --git a/crates/openhuman-core/src/agent/triage/decision_tests.rs b/crates/openhuman-core/src/agent/triage/decision_tests.rsindex 6e2dd8b96e..446db7d693 100644--- a/crates/openhuman-core/src/agent/triage/decision_tests.rs+++ b/crates/openhuman-core/src/agent/triage/decision_tests.rs@@ -33,18 +33,6 @@ fn brace_inside_string_does_not_break_matching() {assert!(slice.contains("has } and { chars"));}-#[test]-fn trailing_commas_are_stripped() {- let src = "{ \"a\": 1, \"b\": [1, 2,], }";- assert_eq!(strip_trailing_commas(src), "{ \"a\": 1, \"b\": [1, 2] }");-}--#[test]-fn trailing_comma_inside_string_is_left_alone() {- let src = "{ \"reason\": \"a, b, c,\" }";- assert_eq!(strip_trailing_commas(src), src);-}-#[test]fn action_value_is_lowercased() {let src = "{\"action\": \"Drop\", \"reason\": \"x\"}";