Sanitize a node so that tool call parameters and output exposed in metadata are masked. Applies to executions[].type=="tool_call", node["tool_calls"], and node["initial_response"]["tool_calls"].
(node: &mut serde_json::Value)
| 27 | /// Sanitize a node so that tool call parameters and output exposed in metadata are masked. |
| 28 | /// Applies to executions[].type=="tool_call", node["tool_calls"], and node["initial_response"]["tool_calls"]. |
| 29 | fn sanitize_node_metadata(node: &mut serde_json::Value) { |
| 30 | let obj = match node.as_object_mut() { |
| 31 | Some(o) => o, |
| 32 | None => return, |
| 33 | }; |
| 34 | // Sanitize executions array |
| 35 | if let Some(executions) = obj.get_mut("executions") { |
| 36 | if let Some(execs_arr) = executions.as_array_mut() { |
| 37 | for entry in execs_arr.iter_mut() { |
| 38 | if entry.get("type").and_then(|t| t.as_str()) == Some("tool_call") { |
| 39 | sanitize_tool_call_entry(entry); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | // Sanitize top-level tool_calls if present (e.g. flattened view) |
| 45 | if let Some(tool_calls) = obj.get_mut("tool_calls") { |
| 46 | if let Some(arr) = tool_calls.as_array_mut() { |
| 47 | for entry in arr.iter_mut() { |
| 48 | sanitize_tool_call_entry(entry); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | // Sanitize initial_response.tool_calls if present |
| 53 | if let Some(initial_response) = obj.get_mut("initial_response") { |
| 54 | if let Some(ir_obj) = initial_response.as_object_mut() { |
| 55 | if let Some(tc) = ir_obj.get_mut("tool_calls") { |
| 56 | if let Some(arr) = tc.as_array_mut() { |
| 57 | for entry in arr.iter_mut() { |
| 58 | sanitize_tool_call_entry(entry); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | impl WorkflowResult { |
| 67 | /// Create a new workflow result |
no test coverage detected