Skip to content

Feat/tool module - #15

Merged
bobrykov merged 2 commits into
masterfrom
feat/tool-module
May 6, 2026
Merged

Feat/tool module#15
bobrykov merged 2 commits into
masterfrom
feat/tool-module

Conversation

@bobrykov

@bobrykov bobrykov commented May 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

coderabbitai[bot]

This comment was marked as duplicate.

@dch-labs dch-labs deleted a comment from coderabbitai Bot May 6, 2026
@bobrykov
bobrykov force-pushed the feat/tool-module branch from 44bc554 to fc5b049 Compare May 6, 2026 12:00
@dch-labs dch-labs deleted a comment from coderabbitai Bot May 6, 2026
@dch-labs dch-labs deleted a comment from coderabbitai Bot May 6, 2026
@bobrykov
bobrykov force-pushed the feat/tool-module branch from fc5b049 to d429259 Compare May 6, 2026 12:07
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d70d42a1-a662-4b2c-8d75-b6efe50af0e4

📥 Commits

Reviewing files that changed from the base of the PR and between fc5b049 and d429259.

📒 Files selected for processing (7)
  • src/core/types.rs
  • src/loop_control/convergence.rs
  • src/loop_control/detection.rs
  • src/loop_control/fallback.rs
  • src/loop_control/loop_detector.rs
  • src/stream.rs
  • src/tool.rs

📝 Walkthrough

Walkthrough

Adds a new public tool module (tool framework), implements a circuit-breaker style fallback manager for model failover, extends loop detection with per-tool hooks and result hashing, and performs minor documentation edits standardizing ellipsis usage.

Changes

Tool Framework

Layer / File(s) Summary
Module export
src/lib.rs
Exports new module: pub mod tool;.
Types & Results
src/tool.rs (lines 71–194)
Adds ToolSchema and ToolOutput types to represent tool metadata and results.
Errors & Context
src/tool.rs (lines 392–714)
Adds ToolError enum and ToolContext struct for error modes and per-call/session context.
Permissions
src/tool.rs (lines 777–1053)
Introduces PermissionCheck enum and builder-style API for pre-execution permission handling.
Trait & Registry
src/tool.rs (lines 1054–1537)
Defines Tool trait (async call interface) and ToolRegistry for registering/looking up tools.
FnTool adapter
src/tool.rs (lines 1557–1955)
Adds FnTool adapter to wrap function pointers as tools with concurrency/read-only/system-prompt options.
Tests & docs
src/tool.rs (lines 1–56, 1958–2207)
Module-level docs and comprehensive unit tests covering serialization, registry operations, execution, and PermissionCheck helpers.

Fallback Manager Circuit-Breaker

Layer / File(s) Summary
State enum
src/loop_control/fallback.rs (lines 96–99)
Adds FallbackState enum: Primary, Fallback, Recovering.
Attempt tracking
src/loop_control/fallback.rs (lines 181–313)
Adds AttemptRecord and FallbackEntry to track per-model attempts, availability, and max-fail counts.
Config
src/loop_control/fallback.rs (lines 603–640)
Adds FallbackConfig with thresholds, timeouts, and defaults (with Default impl).
Manager core
src/loop_control/fallback.rs (lines 716–839)
Adds FallbackManager with atomics and mutexes for state, counters, original/active model tracking, and cooldown timestamp.
Constructors
src/loop_control/fallback.rs (lines 862–980)
Implements new, with_config, new_with_fallback, and for_model constructors.
Queries & management
src/loop_control/fallback.rs (lines 1028–1280)
State accessors, active/fallback model queries, and methods to add/insert/remove/set fallbacks.
Failure/Recovery logic
src/loop_control/fallback.rs (lines 1717–1927)
Implements record_api_failure, record_model_failure, record_model_success, should_try_resume_primary and failure counters.
Transitions & reset
src/loop_control/fallback.rs (lines 1958–2035)
Implements transition_to_fallback, transition_to_recovering, transition_to_primary, and reset; adds Default delegating constructor.

Loop Detector Enhancements

Layer / File(s) Summary
Trait expansion
src/loop_control/loop_detector.rs (lines 186–199)
Expands ToolSignature with normalization hook and additional per-tool hooks (read/edit detection, recoverable edits, suggestions, thresholds).
Default signature
src/loop_control/loop_detector.rs (lines 468–483)
Adds NoOpToolSignature and blanket impl as a generic default.
Utilities & config
src/loop_control/loop_detector.rs (lines 1045–1053, 647–654)
Adds hash_result utility and extends LoopDetectorConfig with tool_thresholds and threshold_for_tool.
Status & internals
src/loop_control/loop_detector.rs (lines 1138–1315, 1270–1349)
Updates LoopStatus (Default, warnings, stop flag) and LoopDetector internals to use the expanded trait surface and signature handling.
Recording API & tests
src/loop_control/loop_detector.rs (lines 1401–1560, 1996–2047)
Extends recording APIs to integrate ToolSignature hooks and adds tests for hashing, per-tool thresholds, recoverable edits, and the NoOp signature path.

Documentation & minor edits

Layer / File(s) Summary
Ellipsis / wording
src/core/types.rs, src/loop_control/convergence.rs, src/loop_control/detection.rs, src/stream.rs
Replaced Unicode ellipsis with ASCII '...' and made minor formatting/wording adjustments in doc comments and lifecycle examples.

Possibly related PRs

  • dch-labs/loopctl#15: Touches the same areas (adds src/tool.rs and pub mod tool;, and related loop_control/fallback changes).
  • dch-labs/loopctl#10: Adds the fallback circuit-breaker implementation with matching types and APIs (FallbackManager, FallbackConfig, FallbackEntry, AttemptRecord).
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feat/tool module' is vague and uses generic phrasing that doesn't clearly convey the main changes in the changeset. Consider using a more descriptive title like 'Add tool module framework with registry and error handling' to better communicate the primary changes to reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tool-module

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

@bobrykov
bobrykov merged commit bf30a5f into master May 6, 2026
6 checks passed
@bobrykov
bobrykov deleted the feat/tool-module branch July 1, 2026 06:35
@coderabbitai coderabbitai Bot mentioned this pull request Jul 1, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 16, 2026
bobrykov added a commit that referenced this pull request Aug 18, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
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