(
&self,
state: &mut ExecutionLoopState,
input: ToolCompletionInput<'_>,
)
| 16 | |
| 17 | impl AgentLoop { |
| 18 | pub(super) async fn complete_tool_call( |
| 19 | &self, |
| 20 | state: &mut ExecutionLoopState, |
| 21 | input: ToolCompletionInput<'_>, |
| 22 | ) { |
| 23 | let ToolCompletionInput { |
| 24 | tool_call, |
| 25 | event_tx, |
| 26 | session_id, |
| 27 | effective_prompt, |
| 28 | tool_start, |
| 29 | normalized, |
| 30 | } = input; |
| 31 | let tool_duration = tool_start.elapsed(); |
| 32 | crate::telemetry::record_tool_result(normalized.exit_code, tool_duration); |
| 33 | Self::collect_verification_report(&mut state.verification_reports, &normalized.metadata); |
| 34 | |
| 35 | let output = if let Some(ref sp) = self.config.security_provider { |
| 36 | sp.sanitize_output(&normalized.output) |
| 37 | } else { |
| 38 | normalized.output.clone() |
| 39 | }; |
| 40 | |
| 41 | state.remember_tool_signature(&tool_call.name, &tool_call.args, normalized.is_error); |
| 42 | |
| 43 | self.fire_post_tool_use( |
| 44 | session_id.unwrap_or(""), |
| 45 | &tool_call.name, |
| 46 | &tool_call.args, |
| 47 | &output, |
| 48 | normalized.exit_code == 0, |
| 49 | tool_duration.as_millis() as u64, |
| 50 | ) |
| 51 | .await; |
| 52 | |
| 53 | self.remember_tool_result( |
| 54 | effective_prompt, |
| 55 | &tool_call.name, |
| 56 | &output, |
| 57 | normalized.exit_code, |
| 58 | event_tx, |
| 59 | ) |
| 60 | .await; |
| 61 | |
| 62 | if let Some(tx) = event_tx { |
| 63 | tx.send(AgentEvent::ToolEnd { |
| 64 | id: tool_call.id.clone(), |
| 65 | name: tool_call.name.clone(), |
| 66 | output: output.clone(), |
| 67 | exit_code: normalized.exit_code, |
| 68 | metadata: normalized.metadata.clone(), |
| 69 | error_kind: normalized.error_kind.clone(), |
| 70 | }) |
| 71 | .await |
| 72 | .ok(); |
| 73 | } |
| 74 | |
| 75 | push_tool_result_message( |
no test coverage detected