Skip to content

Changed: Make custom tools framework-agnostic via CustomTool trait#127

Merged
Sewer56 merged 2 commits into
mainfrom
wip-agnostic-custom-tools
Jun 5, 2026
Merged

Changed: Make custom tools framework-agnostic via CustomTool trait#127
Sewer56 merged 2 commits into
mainfrom
wip-agnostic-custom-tools

Conversation

@Sewer56

@Sewer56 Sewer56 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Introduces a framework-neutral CustomTool trait in reloaded-code-core so
custom tools can be written once and reused across LLM framework adapters
(starting with serdesAI). ToolFactory::create now returns
ToolResult<Arc<dyn CustomTool>>, replacing the Box<dyn Any> escape hatch.

Closes: #

What Changed

reloaded-code-core

  • New: CustomTool trait, CustomToolDefinition, ToolRunContext<'a>,
    CustomToolFuture<'a>.
  • Breaking: ToolFactory::create returns ToolResult<Arc<dyn CustomTool>>.
  • Re-exports + module docs/doctests updated.

reloaded-code-serdesai

  • New: tools::custom adapter wraps any Arc<dyn CustomTool> as a serdesAI
    Tool.
  • Agent builder, test stubs, agent_ext updated 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

// Before
fn create(&self, _ctx: &ToolBuildContext) -> Box<dyn Any + Send + Sync>;
// After
fn create(&self, ctx: &ToolBuildContext) -> ToolResult<Arc<dyn CustomTool>>;

Not in any released version yet, so does not matter.

Notes

  • ToolRunContext fields are all optional so the same impl works across
    adapters with different context capabilities.
  • CustomToolDefinition is serde-derivable; adapters translate to their
    native tool type.
  • No public items removed; only the create signature changed.

- 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
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Linter diff in the way? Review this PR in Change Stack to focus on meaningful changes and expand context only when needed.

Review Change Stack

Warning

Review limit reached

@Sewer56, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 832e2330-88df-466b-a252-cc57bab9772f

📥 Commits

Reviewing files that changed from the base of the PR and between 6146888 and 7280fc6.

📒 Files selected for processing (1)
  • src/reloaded-code-agents/README.md

Walkthrough

This PR introduces a framework-neutral portable custom tool abstraction to ReloadedCode. It adds CustomTool trait, CustomToolDefinition, and ToolRunContext to reloaded-code-core as the portable contract, updates ToolFactory::create to return typed ToolResult<Arc<dyn CustomTool>>, implements CustomToolAdapter in SerdesAI to wrap portable tools, integrates the new typed factory into the agent build pipeline with updated error handling, propagates tool metadata through execution contexts, and includes complete runnable examples and documentation.

Possibly related PRs

  • Reloaded-Project/ReloadedCode#123: Directly related as both implement the custom tool registration and adapter build-time attachment pipeline with shared ToolFactory wiring and error handling.
  • Reloaded-Project/ReloadedCode#121: Related because this PR's portable custom tool implementation depends on ToolContext trait behavior for tool identity and context exposure.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary change: introducing a framework-agnostic CustomTool trait to make custom tools framework-neutral, which is the main architectural improvement in this PR.
Description check ✅ Passed The PR description is comprehensive, covering summary, what changed across both crates, breaking changes with code examples, and implementation notes. However, the template itself is minimal and does not enforce detailed sections.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wip-agnostic-custom-tools

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 94bb677 and 6146888.

📒 Files selected for processing (28)
  • docs/src/examples.md
  • docs/src/getting-started.md
  • docs/src/guides/custom-framework.md
  • docs/src/tools.md
  • src/reloaded-code-agents/README.md
  • src/reloaded-code-agents/src/path/resolver.rs
  • src/reloaded-code-agents/src/runtime/builder.rs
  • src/reloaded-code-core/README.md
  • src/reloaded-code-core/src/custom_tool/definition.rs
  • src/reloaded-code-core/src/custom_tool/factory.rs
  • src/reloaded-code-core/src/custom_tool/mod.rs
  • src/reloaded-code-core/src/custom_tool/runtime.rs
  • src/reloaded-code-core/src/custom_tool/test_stubs.rs
  • src/reloaded-code-core/src/custom_tool/tool.rs
  • src/reloaded-code-core/src/lib.rs
  • src/reloaded-code-core/src/system_prompt.rs
  • src/reloaded-code-serdesai/README.md
  • src/reloaded-code-serdesai/examples/agents/custom-tool/custom-tool-demo.md
  • src/reloaded-code-serdesai/examples/serdesai-custom-tool-standalone.rs
  • src/reloaded-code-serdesai/examples/serdesai-custom-tool.rs
  • src/reloaded-code-serdesai/src/agent_ext.rs
  • src/reloaded-code-serdesai/src/agent_runtime/build.rs
  • src/reloaded-code-serdesai/src/agent_runtime/task.rs
  • src/reloaded-code-serdesai/src/agent_runtime/test_stubs.rs
  • src/reloaded-code-serdesai/src/convert.rs
  • src/reloaded-code-serdesai/src/lib.rs
  • src/reloaded-code-serdesai/src/tools/custom.rs
  • src/reloaded-code-serdesai/src/tools/mod.rs

Comment thread src/reloaded-code-agents/README.md
Comment thread src/reloaded-code-agents/README.md Outdated
The [CustomTool] reference was defined but never used in prose; the
trait is shown only in code blocks. Pre-existing working-tree cleanup.
@Sewer56 Sewer56 merged commit 4f196c7 into main Jun 5, 2026
20 checks passed
@Sewer56 Sewer56 deleted the wip-agnostic-custom-tools branch June 5, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant