Changed: Make custom tools framework-agnostic via CustomTool trait#127
Conversation
- Add framework-neutral `CustomTool` trait, `CustomToolDefinition`, and `ToolRunContext` in core - Refactor `ToolFactory::create` to return `ToolResult<Arc<dyn CustomTool>>` (breaking) - Add serdesai `tools::custom` adapter that wraps `CustomTool` for the serdesAI runtime - Add custom-tool examples (single + standalone) and example agent config - Update docs (tools, getting-started, examples, custom-framework guide) and READMEs
|
Linter diff in the way? Review this PR in Change Stack to focus on meaningful changes and expand context only when needed. Warning Review limit reached
More reviews will be available in 44 minutes and 15 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 introduces a framework-neutral portable custom tool abstraction to ReloadedCode. It adds 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: 2
🤖 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-agents/README.md`:
- Line 370: Remove or reference the unused Markdown link definition
`[CustomTool]:
https://docs.rs/reloaded_code_core/latest/reloaded_code_core/trait.CustomTool.html`
to satisfy markdownlint MD053; either delete that link definition from README.md
or add a corresponding inline reference (e.g., `[CustomTool]` usage) so the
label is actually used, ensuring the README no longer contains an unused link
label.
- Line 315: Replace the specific error type in the example tail (Ok::<(),
reloaded_code_core::permissions::ExpandError>(())) with a neutral, copy-paste
friendly error type so AgentRuntimeBuilder::build()? output types align; for
example use Ok::<(), Box<dyn std::error::Error>>(()) or Ok::<(),
anyhow::Error>(()) (or change the surrounding Result signature to use Box<dyn
std::error::Error> / anyhow::Error) so the example compiles without requiring
reloaded_code_core::permissions::ExpandError.
🪄 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: 5d738d17-ca35-4dae-8f07-ba4b1dd3264d
📒 Files selected for processing (28)
docs/src/examples.mddocs/src/getting-started.mddocs/src/guides/custom-framework.mddocs/src/tools.mdsrc/reloaded-code-agents/README.mdsrc/reloaded-code-agents/src/path/resolver.rssrc/reloaded-code-agents/src/runtime/builder.rssrc/reloaded-code-core/README.mdsrc/reloaded-code-core/src/custom_tool/definition.rssrc/reloaded-code-core/src/custom_tool/factory.rssrc/reloaded-code-core/src/custom_tool/mod.rssrc/reloaded-code-core/src/custom_tool/runtime.rssrc/reloaded-code-core/src/custom_tool/test_stubs.rssrc/reloaded-code-core/src/custom_tool/tool.rssrc/reloaded-code-core/src/lib.rssrc/reloaded-code-core/src/system_prompt.rssrc/reloaded-code-serdesai/README.mdsrc/reloaded-code-serdesai/examples/agents/custom-tool/custom-tool-demo.mdsrc/reloaded-code-serdesai/examples/serdesai-custom-tool-standalone.rssrc/reloaded-code-serdesai/examples/serdesai-custom-tool.rssrc/reloaded-code-serdesai/src/agent_ext.rssrc/reloaded-code-serdesai/src/agent_runtime/build.rssrc/reloaded-code-serdesai/src/agent_runtime/task.rssrc/reloaded-code-serdesai/src/agent_runtime/test_stubs.rssrc/reloaded-code-serdesai/src/convert.rssrc/reloaded-code-serdesai/src/lib.rssrc/reloaded-code-serdesai/src/tools/custom.rssrc/reloaded-code-serdesai/src/tools/mod.rs
The [CustomTool] reference was defined but never used in prose; the trait is shown only in code blocks. Pre-existing working-tree cleanup.
Summary
Introduces a framework-neutral
CustomTooltrait inreloaded-code-coresocustom tools can be written once and reused across LLM framework adapters
(starting with serdesAI).
ToolFactory::createnow returnsToolResult<Arc<dyn CustomTool>>, replacing theBox<dyn Any>escape hatch.Closes: #
What Changed
reloaded-code-coreCustomTooltrait,CustomToolDefinition,ToolRunContext<'a>,CustomToolFuture<'a>.ToolFactory::createreturnsToolResult<Arc<dyn CustomTool>>.reloaded-code-serdesaitools::customadapter wraps anyArc<dyn CustomTool>as a serdesAITool.agent_extupdated for the new shape.Examples & docs
examples/serdesai-custom-tool.rs+ standalone variant + agent config.tools.md,getting-started.md,examples.md,custom-framework.md,READMEs refreshed.
Breaking Change
Not in any released version yet, so does not matter.
Notes
ToolRunContextfields are all optional so the same impl works acrossadapters with different context capabilities.
CustomToolDefinitionis serde-derivable; adapters translate to theirnative tool type.
createsignature changed.