Handle a PreToolUse or PostToolUse event. Currently tracks tool usage for informational purposes. Future enhancements may create sub-turn recordings for sub-agent (Task) tools.
(
&mut self,
event: TurnEvent,
)
| 801 | /// Currently tracks tool usage for informational purposes. Future |
| 802 | /// enhancements may create sub-turn recordings for sub-agent (Task) tools. |
| 803 | pub(super) async fn handle_tool_use( |
| 804 | &mut self, |
| 805 | event: TurnEvent, |
| 806 | ) -> AgentResult<DispatchResult> { |
| 807 | let session_id = &event.session_id; |
| 808 | |
| 809 | let session = self.load_or_create_session(session_id, &event)?; |
| 810 | let turn_number = session.turn_count.saturating_add(1); |
| 811 | self.commit_hook_event(&event, turn_number)?; |
| 812 | |
| 813 | // Log tool usage |
| 814 | if let Some(ref tool_name) = event.tool_name { |
| 815 | log::info!( |
| 816 | "Session {} tool use: {} ({})", |
| 817 | session_id, |
| 818 | tool_name, |
| 819 | event.event_type, |
| 820 | ); |
| 821 | } |
| 822 | |
| 823 | // CB-13D: surface a pending shim-watch notice before the agent's |
| 824 | // next tool call executes (RFC §11.2 rule 6). |
| 825 | let mut dispatch = DispatchResult::new(session_id, session.phase); |
| 826 | if let Some(warning) = drain_watch_notice(self, session_id) { |
| 827 | dispatch = dispatch.with_warning(warning); |
| 828 | } |
| 829 | Ok(dispatch) |
| 830 | } |
| 831 | |
| 832 | fn wait_turn_publication_lock( |
| 833 | &self, |
no test coverage detected