| 241 | } |
| 242 | |
| 243 | async fn check_tool_output( |
| 244 | &self, |
| 245 | tool_name: &str, |
| 246 | args: &Json, |
| 247 | result: &Json, |
| 248 | ) -> FlowResult<Json> { |
| 249 | let messages = vec![ |
| 250 | json!({ |
| 251 | "role": "user", |
| 252 | "content": tool_input_content(tool_name, args)?, |
| 253 | }), |
| 254 | json!({ |
| 255 | "role": "assistant", |
| 256 | "content": tool_output_content(tool_name, args, result)?, |
| 257 | }), |
| 258 | ]; |
| 259 | |
| 260 | match self.bridge.check(messages, LocalRailKind::Output).await? { |
| 261 | LocalCheckOutcome::Passed => Ok(result.clone()), |
| 262 | LocalCheckOutcome::Blocked { rail, .. } => { |
| 263 | Err(blocked_error("tool_output", rail.as_deref())) |
| 264 | } |
| 265 | LocalCheckOutcome::Modified { content, .. } => { |
| 266 | modified_tool_payload(&content, "result") |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | async fn guard_provider_stream( |
| 272 | &self, |