Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(credential_scrub): remove token before scrubbing instead of masking it

Steven Enamakel2f1c7b6da0f7
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/credential_scrub.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/credential_scrub.rs
index fd1a0f8614..a5eafe6a6c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/credential_scrub.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/credential_scrub.rs
@@ -11,6 +11,9 @@ use tinyagents_harness::middleware::{
/// handle, not a credential from page content. Protect only that field in a
/// `NeedsConfirmation` result; every other string still crosses the ordinary
/// credential scrubber, including page text and action input.
+///
+/// The token is removed before scrubbing and put back afterwards, so it is
+/// never seen by (or counted against) the scrubber.
fn scrub_with_notice_for_tool(tool_name: &str, content: &str) -> Option<(String, usize)> {
if tool_name != "browser" {
return scrub_with_notice(content);
@@ -27,7 +30,12 @@ fn scrub_with_notice_for_tool(tool_name: &str, content: &str) -> Option<(String,
if token.len() != 36 || uuid::Uuid::parse_str(&token).is_err() {
return scrub_with_notice(content);
}
- value["pending"]["token"] = serde_json::Value::String("x".into());
+ // Take the token out of the document instead of masking it with a dummy
+ // value: the scrubber redacts every labelled `token` value regardless of
+ // length, so any placeholder under that key is redacted and counted too.
+ if let Some(pending) = value["pending"].as_object_mut() {
+ pending.remove("token");
+ }
let protected = match serde_json::to_string(&value) {
Ok(protected) => protected,
Err(_) => return scrub_with_notice(content),