Apply program context to tools that Q may not have. We cannot attach this any other way because Tools are constructed by deserializing output from Amazon Q. TODO: Is there a better way?
(&self, tool: &mut Tool)
| 3482 | // output from Amazon Q. |
| 3483 | // TODO: Is there a better way? |
| 3484 | fn contextualize_tool(&self, tool: &mut Tool) { |
| 3485 | if let Tool::GhIssue(gh_issue) = tool { |
| 3486 | let allowed_tools = self |
| 3487 | .conversation |
| 3488 | .agents |
| 3489 | .get_active() |
| 3490 | .map(|a| a.allowed_tools.iter().cloned().collect::<Vec<_>>()) |
| 3491 | .unwrap_or_default(); |
| 3492 | gh_issue.set_context(GhIssueContext { |
| 3493 | // Ideally we avoid cloning, but this function is not called very often. |
| 3494 | // Using references with lifetimes requires a large refactor, and Arc<Mutex<T>> |
| 3495 | // seems like overkill and may incur some performance cost anyway. |
| 3496 | context_manager: self.conversation.context_manager.clone(), |
| 3497 | transcript: self.conversation.transcript.clone(), |
| 3498 | failed_request_ids: self.failed_request_ids.clone(), |
| 3499 | tool_permissions: allowed_tools, |
| 3500 | }); |
| 3501 | } |
| 3502 | } |
| 3503 | |
| 3504 | async fn print_tool_description(&mut self, os: &Os, tool_index: usize, trusted: bool) -> Result<(), ChatError> { |
| 3505 | let tool_use = &self.tool_uses[tool_index]; |
no test coverage detected