[Feature] Improve plugin tools execution and multimodal support#758
Conversation
…ive matching and native shell spawning - Normalize tool names to lowercase in agent executor for consistent matching - Refactor error handling for tool input parsing into dedicated function - Add runtime error handler support for tool execution failures - Fix config patching for callback propagation in tool invocation - Replace shelljs with native child_process spawn for better control - Add Windows shell resolution (Git Bash, PowerShell) detection - Improve command execution with proper UTF-8 encoding handling - Add signal-based termination detection alongside exit codes - Update timeout handling with cleaner child process lifecycle management - Remove unnecessary validation constraints on offset/limit/timeout parameters
- Extend llm-call-tool event signature with AgentAction content parameter - Update plugin_chat_chain to pass content from agent actions to events - Refactor tool call handler to support multimodal message content - Add hasMessageContent() helper to validate message content - Extract sendRenderedMessage() for consistent message rendering - Improve tool call event handling with content-aware message delivery
- Remove hasMessageContent() helper function - Inline content validation logic directly into createToolCallHandler - Simplify single-use helper abstraction for better code clarity
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough本次变更:统一工具名称为小写以做映射查找;集中处理工具输入解析错误并包装为观察;在事件链与中间件中传播 AgentAction.content;并为 BashTool 引入跨平台(含 Windows PowerShell / Git Bash)命令执行与更宽松的 schema 校验。 Changes
Sequence DiagramsequenceDiagram
participant Agent as AgentExecutor
participant Chain as PluginChatChain
participant Middleware as RequestMiddleware
participant Events as ChatEvents
Agent->>Agent: 查找工具(name.toLowerCase())
activate Agent
Agent->>Agent: 调用工具或捕获解析错误
Agent-->>Events: 生成/返回 AgentAction (含 content)
deactivate Agent
Chain->>Events: emit llm-call-tool(tool,args,content,log)
activate Chain
deactivate Chain
Events->>Middleware: 接收事件并处理发送
activate Middleware
alt content 存在
Middleware->>Middleware: render(content) -> sendRenderedMessage
else showThoughtMessage false
Middleware->>Middleware: 不发送
else log 非工具调用
Middleware->>Middleware: render(log) -> sendRenderedMessage
else
Middleware->>Middleware: render(格式化工具调用) -> sendRenderedMessage
end
deactivate Middleware
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the agent's tool execution capabilities and multimodal content handling. It refines how tools are identified and invoked, introduces more robust error management, and modernizes the underlying command execution mechanism for enhanced cross-platform compatibility and reliability. These changes aim to make tool usage more flexible, resilient, and capable of processing diverse content types. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to tool execution, including case-insensitive tool matching, native shell command execution via child_process.spawn (replacing shelljs), and enhanced multimodal content support. It also improves robustness and cross-platform compatibility through refactored error handling and a Windows shell resolver for Git Bash and PowerShell. However, it introduces significant security vulnerabilities related to path traversal and scope bypass in the FileStore class and the BashTool, as paths are not properly normalized before scope checks, potentially allowing unauthorized file access. Additionally, the removal of some input validation in the tool schemas could lead to unexpected behavior. Addressing these path normalization issues and re-instating the necessary input validations are critical for both security and robustness.
- Use patchConfig to pass runManager callbacks in ExceptionTool.invoke() call - Ensure consistent callback propagation across all tool invocations - Fix callback chain for error handling in agent executor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae87c93e90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (handleParsingErrors === true || handleParsingErrors === false) { | ||
| return 'Invalid or incomplete tool input. Please try again.' |
There was a problem hiding this comment.
Re-throw tool input parse errors when handling is disabled
This helper now treats handleParsingErrors === false the same as true, so ToolInputParsingException is converted into a generic observation instead of being thrown. Because handleParsingErrors defaults to false, the default runtime behavior changed from fail-fast to silently continuing in both _call and _takeNextStep, which can hide malformed tool inputs and trap the agent in retry loops rather than surfacing the actual error.
Useful? React with 👍 / 👎.
This PR improves tool execution with case-insensitive matching, native shell spawning, and enhanced multimodal content support for tool call events.
New Features
AgentAction['content']parameterBug fixes
Other Changes
child_process.spawn()for better control