Skip to content

Adopt colony-sdk 1.5.0 typed errors and RetryConfig#13

Merged
jackparnell merged 1 commit intomainfrom
feature/sdk-1.5-cleanup
Apr 9, 2026
Merged

Adopt colony-sdk 1.5.0 typed errors and RetryConfig#13
jackparnell merged 1 commit intomainfrom
feature/sdk-1.5-cleanup

Conversation

@ColonistOne
Copy link
Copy Markdown
Collaborator

Summary

Cleanup PR — adopts the primitives that landed in colony-sdk 1.5.0 and deletes the now-duplicated copies that lived in crewai_colony.tools.

  • Bumps colony-sdk floor to >=1.5.0
  • RetryConfig is now re-exported from colony_sdk (existing from crewai_colony import RetryConfig keeps working)
  • Retry loop, _RETRYABLE_STATUSES, _STATUS_HINTS, _is_retryable, _fmt_error's hint table — all gone. The SDK's typed exceptions already include the hint + server detail in their string form, so the tool layer just prepends Error (status) [code] —.
  • ColonyToolkit(retry=...) now hands the config straight to ColonyClient(retry=...). The SDK honours Retry-After automatically and retries 502/503/504 in addition to 429.
  • Per-tool retry= constructor arg removed (was unused after the loop moved into the SDK).
  • Test suite rewritten to use real ColonyNotFoundError / ColonyRateLimitError / ColonyConflictError / ColonyAuthError / ColonyValidationError / ColonyNetworkError exceptions rather than Exception() with monkey-patched .status attributes.

Net diff: −98 lines, mostly deleted duplication.

Behaviour notes

  • Default retry budget changes from max_retries=3 (3 total attempts, our old default) to max_retries=2 (3 total attempts under the SDK's "retries after the first try" semantics) — same total number of attempts, just labelled differently. Pass RetryConfig(max_retries=3) to bump it back up.
  • Connection errors (DNS, refused, raw timeouts) are no longer retried by the tool layer — the SDK raises them as ColonyNetworkError(status=0) directly. Document in CHANGELOG.
  • ColonyRateLimitError.retry_after is exposed for callers that want to do higher-level backoff above the SDK's internal retries.

Test plan

  • pytest — 168 passed
  • pytest --cov — 100% across all 6 source files (__init__, callbacks, cli, crews, toolkit, tools)
  • ruff check clean
  • ruff format --check clean
  • mypy src/ clean

This is the first of four PRs heading toward v0.6.0. Next: native async via AsyncColonyClient (drops the asyncio.to_thread shim).

🤖 Generated with Claude Code

Bumps the floor to colony-sdk>=1.5.0 and removes the duplicated retry
loop, _RETRYABLE_STATUSES set, and _STATUS_HINTS table — all of which
the SDK now ships natively.

- RetryConfig is re-exported from colony_sdk so existing imports keep
  working unchanged. ColonyToolkit hands it straight to ColonyClient,
  which performs retries internally with Retry-After handling.
- The tool layer's _safe_run now just call+catch+format. Errors are
  caught as ColonyAPIError (whose str() already contains the hint and
  the server's detail field) and rendered as "Error (status) [code] —".
- Per-tool retry= constructor argument removed (was unused after the
  retry loop moved into the SDK).
- Test suite rewritten to use real SDK exception classes
  (ColonyNotFoundError, ColonyRateLimitError, etc.) rather than ad-hoc
  Exception() instances with monkey-patched .status attributes.

168 tests passing, 100% coverage held across all source files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jackparnell jackparnell merged commit 2f8b8c4 into main Apr 9, 2026
7 checks passed
@jackparnell jackparnell deleted the feature/sdk-1.5-cleanup branch April 9, 2026 10:30
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.

2 participants