Skip to content

feat: add error.rs - #3

Merged
bobrykov merged 2 commits into
masterfrom
feat/add-core-error
May 4, 2026
Merged

feat: add error.rs#3
bobrykov merged 2 commits into
masterfrom
feat/add-core-error

Conversation

@bobrykov

@bobrykov bobrykov commented May 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 80d5bd26-cf47-4161-afdc-d9a3dd5a4faa

📥 Commits

Reviewing files that changed from the base of the PR and between 89a3b13 and 7be3534.

📒 Files selected for processing (1)
  • src/core/error.rs
✅ Files skipped from review due to trivial changes (1)
  • src/core/error.rs

📝 Walkthrough

Walkthrough

A new core module and error subsystem introduce AgentError with structured variants and helper methods for recoverability and cancellation. Crate docs updated to reference core; package metadata repository and homepage URLs in Cargo.toml were changed to the dch-labs/loopctl organization.

Changes

Core Error Handling Framework

Layer / File(s) Summary
Data Shape
src/core/error.rs
Adds #[non_exhaustive] pub enum AgentError with variants: ToolNotFound, ToolExecution, InvalidInput, Api, MaxTurnsExceeded, ContextExceeded, PhaseFailed, Memory, Reflection, Cancelled, LoopDetected, ToolLimitReached, StreamError, Config, Internal.
Helper Methods
src/core/error.rs
Adds AgentError::tool_not_found(tool, available) which formats/caps available tool lists; AgentError::is_recoverable(&self) returning true for ToolExecution, Api, ContextExceeded, Reflection; AgentError::is_cancelled(&self) detecting Cancelled.
Tests
src/core/error.rs
Unit tests for tool_not_found formatting (empty, ≤10, >10 lists) and is_recoverable behavior across variants.
Module Integration
src/core.rs
Introduces pub mod error; and pub use error::*; with module-level docs and TODO placeholders for other submodules.
Crate Docs
src/lib.rs
Updates crate-level documentation to reference message for conversation types and core for foundational traits and errors.

Repository Metadata

Layer / File(s) Summary
Package URLs
Cargo.toml
Updates [package] repository and homepage fields from https://github.com/dch-sh/loopctl to https://github.com/dch-labs/loopctl.

Poem

🐰 I hop through code with tidy cheer,

Errors named and docs made clear,
Tools listed, trimmed, and neatly shown,
Recoverable flags carved in stone,
A soft paw pats the crate — onward we go!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose of the new error handling system and how AgentError variants support the framework's error management.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add error.rs' accurately reflects the main addition in the changeset—introducing a new error module with AgentError enum and related functionality.
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/add-core-error

Review rate limit: 8/10 reviews remaining, refill in 11 minutes and 27 seconds.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/core/error.rs (2)

85-86: ⚡ Quick win

Make the public error enum forward-compatible with #[non_exhaustive].

Since this is a central public error type, future variant additions will otherwise require a breaking release.

Suggested diff
-#[derive(Debug, Clone, thiserror::Error)]
+#[non_exhaustive]
+#[derive(Debug, Clone, thiserror::Error)]
 pub enum AgentError {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/error.rs` around lines 85 - 86, Add the #[non_exhaustive] attribute
to the public enum AgentError so new variants can be added without breaking
semver: place #[non_exhaustive] immediately above the pub enum AgentError
declaration (which currently has #[derive(Debug, Clone, thiserror::Error)]),
then update any external exhaustive pattern matches to use a wildcard arm if
needed.

299-344: ⚡ Quick win

Add unit tests for helper-method behavior contracts.

tool_not_found truncation formatting and is_recoverable variant mapping are core policy decisions; lightweight tests here will prevent accidental regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/error.rs` around lines 299 - 344, Add unit tests verifying
tool_not_found produces "none registered" when given an empty available slice,
returns a comma-joined string when <=10 entries, and truncates with the "...
(and N more)" format when >10 entries (assert on the exact formatted string);
also add tests for is_recoverable that assert it returns true for
AgentError::ToolExecution, AgentError::Api(...), AgentError::ContextExceeded,
and AgentError::Reflection(...), and false for at least one non-recoverable
variant (e.g., ToolNotFound or Cancel); place tests alongside the module tests
(e.g., a tests mod in the same module) and construct AgentError instances via
the tool_not_found constructor and the enum variants to validate behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/core/error.rs`:
- Around line 85-86: Add the #[non_exhaustive] attribute to the public enum
AgentError so new variants can be added without breaking semver: place
#[non_exhaustive] immediately above the pub enum AgentError declaration (which
currently has #[derive(Debug, Clone, thiserror::Error)]), then update any
external exhaustive pattern matches to use a wildcard arm if needed.
- Around line 299-344: Add unit tests verifying tool_not_found produces "none
registered" when given an empty available slice, returns a comma-joined string
when <=10 entries, and truncates with the "... (and N more)" format when >10
entries (assert on the exact formatted string); also add tests for
is_recoverable that assert it returns true for AgentError::ToolExecution,
AgentError::Api(...), AgentError::ContextExceeded, and
AgentError::Reflection(...), and false for at least one non-recoverable variant
(e.g., ToolNotFound or Cancel); place tests alongside the module tests (e.g., a
tests mod in the same module) and construct AgentError instances via the
tool_not_found constructor and the enum variants to validate behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 12bce791-7661-4b9d-9534-74981aefbc3f

📥 Commits

Reviewing files that changed from the base of the PR and between 8746fdb and 89a3b13.

📒 Files selected for processing (4)
  • Cargo.toml
  • src/core.rs
  • src/core/error.rs
  • src/lib.rs

@bobrykov
bobrykov force-pushed the feat/add-core-error branch from 56723a0 to 7be3534 Compare May 4, 2026 02:56
@bobrykov
bobrykov merged commit e7cdb2d into master May 4, 2026
5 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 4, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 30, 2026
@bobrykov
bobrykov deleted the feat/add-core-error branch July 1, 2026 06:35
bobrykov added a commit that referenced 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