Changed: Migrate examples to agent builder pattern#13
Conversation
- Added AgentBuilderExt trait for serdesai to bridge Tool<Deps> to AgentBuilder - Updated rig examples to use client.agent().tool() instead of ToolSet::builder() - Updated serdesai examples to use AgentBuilderExt::tool_impl() - Updated READMEs and doc comments to reflect the new patterns - Simplified convert.rs tests by removing unnecessary Result wrapping The agent builder pattern is the idiomatic way to construct agents with tools, replacing the deprecated ToolSet::builder().static_tool() approach.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
==========================================
- Coverage 59.26% 58.93% -0.33%
==========================================
Files 46 47 +1
Lines 1274 1281 +7
==========================================
Hits 755 755
- Misses 519 526 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- Renamed AgentBuilderExt::tool_impl() to tool() to match rig's API - Changed ignore to no_run in doc examples - Removed needless borrows in system_prompt() calls
WalkthroughThis PR replaces ToolSet/ToolRegistry examples with an agent-builder workflow: tools are registered via chained Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)src/**/*.rs📄 CodeRabbit inference engine (src/AGENTS.md)
Files:
src/llm-coding-tools-serdesai/**/*.rs📄 CodeRabbit inference engine (src/AGENTS.md)
Files:
🧠 Learnings (4)📓 Common learnings📚 Learning: 2026-01-17T06:12:43.046ZApplied to files:
📚 Learning: 2026-01-17T06:12:43.046ZApplied to files:
📚 Learning: 2026-01-17T06:12:43.046ZApplied to files:
🧬 Code graph analysis (1)src/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rs (2)
🔇 Additional comments (4)
✏️ Tip: You can disable this entire section by setting 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.MD (1)
69-78: Update example command names to match actual files.The documented example names don't match the actual example files. The commands as written will fail:
basic→ should berig-basicsandboxed→ should berig-sandboxedfull_agentexample file doesn't existUpdate lines 69-78 to use
rig-basicandrig-sandboxed, or remove thefull_agentreference.
🤖 Fix all issues with AI agents
In `@src/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rs`:
- Around line 29-33: The tool constructors (ReadTool::new, WriteTool::new,
EditTool::new, GlobTool::new, GrepTool::new) currently call unwrap() and will
panic on error; replace each unwrap() with the ? operator to propagate errors
from main (e.g., let read: ReadTool<true> =
ReadTool::new(allowed_paths.clone())?; and similarly for write, edit, glob,
grep), keeping the same variable names (read, write, edit, glob, grep) and
cloning of allowed_paths as before; ensure the surrounding function signature
remains Result<(), Box<dyn std::error::Error>> so the ? operator compiles.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
README.MDsrc/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-core/src/preamble.rssrc/llm-coding-tools-rig/README.mdsrc/llm-coding-tools-rig/examples/rig-basic.rssrc/llm-coding-tools-rig/examples/rig-sandboxed.rssrc/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/README.mdsrc/llm-coding-tools-serdesai/examples/serdesai-basic.rssrc/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rssrc/llm-coding-tools-serdesai/src/agent_ext.rssrc/llm-coding-tools-serdesai/src/convert.rssrc/llm-coding-tools-serdesai/src/lib.rs
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.rs
📄 CodeRabbit inference engine (src/AGENTS.md)
src/**/*.rs: Keep modules under 500 lines (excluding tests); split larger modules into multiple files
Document all public items with///documentation comments
Add examples in documentation where helpful for public items
Use//!for module-level documentation comments
Focus comments on explaining 'why' rather than 'what' the code does
Use [TypeName] rustdoc links instead of backticks for type references in documentation
Preallocate collections when size is known or estimable usingString::with_capacity(),Vec::with_capacity(), orBufReader::with_capacity()
Prefer&strand&[T]return types over owned types when lifetimes allow
UseCow<'_, str>for conditional ownership scenarios such as withString::from_utf8_lossy
Use&'static strfor compile-time constant strings
Reuse buffers by calling.clear()and reusingVec/Stringinstead of reallocating new instances
Use const generics for compile-time branching (e.g.,<const LINE_NUMBERS: bool>) to enable zero-cost abstractions
Apply#[inline]attribute to small, hot-path functions
Prefercorecrate overstdwhere possible (e.g.,core::memoverstd::mem)
Stream data instead of loading entire files into memory when possible
Usememchrcrate for fast byte searching instead of manual iteration
Placeusestatements inside functions only for#[cfg]conditional compilation
Files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-core/src/preamble.rssrc/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/examples/serdesai-basic.rssrc/llm-coding-tools-serdesai/src/agent_ext.rssrc/llm-coding-tools-rig/examples/rig-basic.rssrc/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rssrc/llm-coding-tools-serdesai/src/convert.rssrc/llm-coding-tools-rig/examples/rig-sandboxed.rssrc/llm-coding-tools-serdesai/src/lib.rs
src/llm-coding-tools-rig/**/*.rs
📄 CodeRabbit inference engine (src/AGENTS.md)
For
llm-coding-tools-rigandllm-coding-tools-serdesaicrates, only implement asyncTooltraits; theblockingfeature only applies tollm-coding-tools-core
Files:
src/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-rig/examples/rig-basic.rssrc/llm-coding-tools-rig/examples/rig-sandboxed.rs
src/llm-coding-tools-serdesai/**/*.rs
📄 CodeRabbit inference engine (src/AGENTS.md)
For
llm-coding-tools-serdesaicrate, implement asyncTooltraits; theblockingfeature only applies tollm-coding-tools-core
Files:
src/llm-coding-tools-serdesai/examples/serdesai-basic.rssrc/llm-coding-tools-serdesai/src/agent_ext.rssrc/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rssrc/llm-coding-tools-serdesai/src/convert.rssrc/llm-coding-tools-serdesai/src/lib.rs
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/llm-coding-tools-rig/**/*.rs : For `llm-coding-tools-rig` and `llm-coding-tools-serdesai` crates, only implement async `Tool` traits; the `blocking` feature only applies to `llm-coding-tools-core`
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/llm-coding-tools-serdesai/**/*.rs : For `llm-coding-tools-serdesai` crate, implement async `Tool` traits; the `blocking` feature only applies to `llm-coding-tools-core`
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Use `//!` for module-level documentation comments
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Document all public items with `///` documentation comments
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/llm-coding-tools-serdesai/**/*.rs : For `llm-coding-tools-serdesai` crate, implement async `Tool` traits; the `blocking` feature only applies to `llm-coding-tools-core`
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-core/src/preamble.rssrc/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/examples/serdesai-basic.rssrc/llm-coding-tools-serdesai/src/agent_ext.rssrc/llm-coding-tools-rig/examples/rig-basic.rssrc/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rsREADME.MDsrc/llm-coding-tools-serdesai/src/convert.rssrc/llm-coding-tools-rig/README.mdsrc/llm-coding-tools-rig/examples/rig-sandboxed.rssrc/llm-coding-tools-serdesai/src/lib.rssrc/llm-coding-tools-serdesai/README.md
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Prefer `core` crate over `std` where possible (e.g., `core::mem` over `std::mem`)
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/llm-coding-tools-rig/**/*.rs : For `llm-coding-tools-rig` and `llm-coding-tools-serdesai` crates, only implement async `Tool` traits; the `blocking` feature only applies to `llm-coding-tools-core`
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-core/src/preamble.rssrc/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/examples/serdesai-basic.rssrc/llm-coding-tools-serdesai/src/agent_ext.rssrc/llm-coding-tools-rig/examples/rig-basic.rssrc/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rsREADME.MDsrc/llm-coding-tools-serdesai/src/convert.rssrc/llm-coding-tools-rig/README.mdsrc/llm-coding-tools-rig/examples/rig-sandboxed.rssrc/llm-coding-tools-serdesai/src/lib.rssrc/llm-coding-tools-serdesai/README.md
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Add examples in documentation where helpful for public items
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: All changes must pass the full build, test, and lint suite: `cargo build`, `cargo test`, `cargo clippy` with `-D warnings`, and `cargo fmt` without errors for all three workspace crates
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/Cargo.toml : Keep dependency footprint minimal and avoid unnecessary dependencies
Applied to files:
src/llm-coding-tools-core/src/lib.rssrc/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/Cargo.toml : The `async` feature flag is for internal use only and should not be enabled directly; use the `tokio` feature instead for async functionality
Applied to files:
src/llm-coding-tools-core/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/Cargo.toml : Enable only the `tokio` feature (default) for async mode with tokio runtime, or the `blocking` feature for sync/blocking mode - never enable both `async` and `blocking` features simultaneously as they are mutually exclusive and cause compile errors
Applied to files:
src/llm-coding-tools-core/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Use [`TypeName`] rustdoc links instead of backticks for type references in documentation
Applied to files:
src/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Applies to src/**/*.rs : Focus comments on explaining 'why' rather than 'what' the code does
Applied to files:
src/llm-coding-tools-rig/src/lib.rs
📚 Learning: 2026-01-17T06:12:43.046Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-01-17T06:12:43.046Z
Learning: Place core operation implementations (read, write, edit, glob, grep, bash, etc.) in `src/operations/` directory within `llm-coding-tools-core`
Applied to files:
src/llm-coding-tools-rig/src/lib.rssrc/llm-coding-tools-serdesai/src/lib.rs
🧬 Code graph analysis (4)
src/llm-coding-tools-serdesai/examples/serdesai-basic.rs (3)
src/llm-coding-tools-serdesai/src/todo.rs (1)
create_todo_tools(145-152)src/llm-coding-tools-rig/examples/rig-basic.rs (1)
main(18-46)src/llm-coding-tools-core/src/preamble.rs (1)
new(96-98)
src/llm-coding-tools-rig/examples/rig-basic.rs (4)
src/llm-coding-tools-rig/examples/rig-sandboxed.rs (1)
main(20-65)src/llm-coding-tools-serdesai/examples/serdesai-basic.rs (1)
main(17-55)src/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rs (1)
main(18-63)src/llm-coding-tools-core/src/preamble.rs (1)
new(96-98)
src/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rs (5)
src/llm-coding-tools-rig/examples/rig-basic.rs (1)
main(18-46)src/llm-coding-tools-rig/examples/rig-sandboxed.rs (1)
main(20-65)src/llm-coding-tools-serdesai/examples/serdesai-basic.rs (1)
main(17-55)src/llm-coding-tools-core/src/preamble.rs (1)
new(96-98)src/llm-coding-tools-core/src/path/allowed.rs (1)
allowed_paths(84-86)
src/llm-coding-tools-rig/examples/rig-sandboxed.rs (1)
src/llm-coding-tools-core/src/preamble.rs (1)
new(96-98)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-and-test (windows-latest, x86_64-pc-windows-msvc, false)
- GitHub Check: build-and-test (macos-latest, aarch64-apple-darwin, false)
- GitHub Check: build-and-test (ubuntu-latest, x86_64-unknown-linux-gnu, false)
🔇 Additional comments (17)
src/llm-coding-tools-serdesai/src/convert.rs (1)
144-164: LGTM! Test simplifications improve consistency.The direct calls to
core_error_to_serdesalign with the pattern already used in other tests in this file (e.g.,io_error_maps_to_execution_error,execution_error_maps_to_execution_failed). Removing the unnecessaryResultwrapping andunwrap_errmakes the test intent clearer.src/llm-coding-tools-core/src/lib.rs (1)
1-1: LGTM - Documentation sourced from README.Using
include_str!withCARGO_PKG_READMEensures crate documentation stays in sync with the README file, following the single source of truth principle.src/llm-coding-tools-core/src/preamble.rs (1)
122-130: LGTM - Documentation updated to reflect agent builder pattern.The example correctly demonstrates the new idiomatic pattern: tracking tools with
pb.track()and attaching the preamble via.preamble(&pb.build())on the agent builder.src/llm-coding-tools-rig/src/lib.rs (2)
1-46: LGTM - Well-structured public API expansion.The expanded re-exports and the
allowed_toolsnamespace module provide a clean API surface for the agent builder pattern. The namespace approach correctly avoids conflicts betweenabsoluteandallowedmodule types with identical names.
48-72: LGTM - Test validates the new API.The test correctly verifies that [
PreambleBuilder] works with the real tool types and that tracked tools are returned unchanged.src/llm-coding-tools-rig/examples/rig-sandboxed.rs (1)
45-62: LGTM - Correct agent builder pattern for sandboxed tools.The example correctly demonstrates:
- Creating tools with a shared
AllowedPathResolver- Tracking tools via
pb.track()during the builder chain- Building and attaching the preamble after all tools are tracked
The evaluation order ensures all
.tool(pb.track(...))calls complete before.preamble(&pb.build())is evaluated.src/llm-coding-tools-rig/examples/rig-basic.rs (1)
17-45: LGTM - Clean migration to agent builder pattern.The example correctly demonstrates the new workflow:
- Creating shared state (
TodoTools)- Building an agent with chained
.tool()calls- Tracking tools for preamble generation
- Integrating the preamble via
.preamble(&pb.build())This aligns well with the serdesai examples that use
.tool_impl()and.system_prompt().README.MD (1)
41-65: LGTM - Quick Start updated for agent builder pattern.The example correctly demonstrates the new workflow with
PreambleBuilder, tool tracking, and agent construction via the builder pattern. Usingrust,no_runis appropriate since this requires an API key.src/llm-coding-tools-rig/README.md (2)
32-55: Quick Start snippet cleanly reflects the new tool-tracking flow.
84-94: Usage snippet remains clear for absolute vs allowed tools.src/llm-coding-tools-serdesai/src/lib.rs (2)
1-1: Crate docs sourced from the README are a nice touch.
5-5: Publicagent_extmodule exposure looks appropriate.src/llm-coding-tools-serdesai/src/agent_ext.rs (1)
1-79: Adapter + extension trait form a clean bridge for tool registration.src/llm-coding-tools-serdesai/examples/serdesai-basic.rs (1)
6-53: Example flow is cohesive after the agent-builder migration.src/llm-coding-tools-serdesai/examples/serdesai-sandboxed.rs (1)
35-60: Sandboxed agent build/readout flow looks good.src/llm-coding-tools-serdesai/README.md (2)
31-62: Quick Start block aligns cleanly with the new builder pattern.
71-98: Usage + examples remain consistent with the updated API.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Propagate errors from tool constructors instead of panicking.
Changed: Migrate examples to agent builder pattern
Summary
AgentBuilderExttrait for serdesai to bridgeTool<Deps>toAgentBuilderclient.agent().tool()instead ofToolSet::builder()AgentBuilderExt::tool()Details
The agent builder pattern is the idiomatic way to construct agents with tools, replacing the deprecated
ToolSet::builder().static_tool()approach.Rig Examples
SerdesAI Examples
Created
AgentBuilderExttrait with.tool()method to bridge the gap betweenserdes_ai::tools::Toolandserdes_ai::agent::ToolExecutor.