Skip to main content

Crate agent_shadow_mode

Crate agent_shadow_mode 

Source
Expand description

agent-shadow-mode: toggleable shadow mode for agent tool calls.

When rolling out a new agent, you don’t want it to actually charge cards, send emails, or delete files on day one. Wrap your tool calls through ShadowMode: when active, it records the intended call and returns a safe placeholder without running the real function.

use agent_shadow_mode::ShadowMode;
use serde_json::json;

let mut shadow = ShadowMode::new(true);

// Shadow mode active: real closure never runs
let result = shadow.intercept("charge_card", json!([]), json!({}), json!({"status": "shadowed"}), || {
    json!({"status": "charged"}) // would run the real call
});
assert_eq!(result, json!({"status": "shadowed"}));
assert_eq!(shadow.records().len(), 1);
assert_eq!(shadow.records()[0].tool_name, "charge_card");

// Deactivate: real closure runs
shadow.deactivate();
let real = shadow.intercept("charge_card", json!([]), json!({}), json!({"status": "shadowed"}), || {
    json!({"status": "charged"})
});
assert_eq!(real, json!({"status": "charged"}));

Structs§

ShadowMode
Toggleable shadow-mode manager for agent tool calls.
ShadowRecord
One recorded would-be tool call.