Changed: ToolContext::NAME from associated const to method#121
Conversation
- Replace `const NAME: &'static str` with `fn name(&self) -> &'static str` in the ToolContext trait - Makes the trait object-safe, enabling `Box<dyn ToolContext>` for custom-tools feature - Update all tool implementations: read, write, edit, glob, grep, bash, webfetch, todo read/write, task - Update SystemPromptBuilder::track() to use tool.name() instead of T::NAME - Update all doc examples and mock tools - Add object-safety test proving Box<dyn ToolContext> construction works - Silence doc lint warning on api_type field in provider-config
|
Warning Review limit reached
More reviews will be available in 29 minutes and 8 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR refactors the Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/reloaded-code-serdesai/src/task/tool.rs`:
- Around line 121-127: The test task_tool_name_matches_metadata should call the
ToolContext::name path on a real TaskTool instance rather than re-checking
task_tool_definition(...).name(); construct a TaskTool (or a minimal test double
implementing ToolContext) and assert that ToolContext::name(&tool) ==
task_meta::NAME, keeping or reusing the existing summary/targets setup as needed
and not relying on task_tool_definition to exercise TaskTool::name; reference
TaskTool and ToolContext::name in the test replacement so a broken impl
ToolContext for TaskTool<C> would be detected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 93ee5612-42f5-45e1-9189-cd3db02676a7
📒 Files selected for processing (15)
docs/src/guides/custom-framework.mdsrc/reloaded-code-core/README.mdsrc/reloaded-code-core/examples/system_prompt/mock_tools.rssrc/reloaded-code-core/src/context/mod.rssrc/reloaded-code-core/src/system_prompt.rssrc/reloaded-code-provider-config/src/config.rssrc/reloaded-code-serdesai/src/task/tool.rssrc/reloaded-code-serdesai/src/tools/bash.rssrc/reloaded-code-serdesai/src/tools/edit.rssrc/reloaded-code-serdesai/src/tools/glob.rssrc/reloaded-code-serdesai/src/tools/grep.rssrc/reloaded-code-serdesai/src/tools/read.rssrc/reloaded-code-serdesai/src/tools/todo.rssrc/reloaded-code-serdesai/src/tools/webfetch.rssrc/reloaded-code-serdesai/src/tools/write.rs
0c7ac4e to
dee6897
Compare
ToolContext Object-Safety Migration
Summary
Migrate
ToolContext::NAMEfrom associated const to instance method for object-safety.Required for future custom tool functionality.
Changes
ToolContexttrait:const NAME->fn name(&self) -> &'static strSystemPromptBuilder::track()to usetool.name()Box<dyn ToolContext>constructibleBreaking Change
Implementations must change from:
To: