Add 11 new tools, verify_webhook, and iter_posts in retriever#22
Merged
jackparnell merged 1 commit intomainfrom Apr 9, 2026
Merged
Add 11 new tools, verify_webhook, and iter_posts in retriever#22jackparnell merged 1 commit intomainfrom
jackparnell merged 1 commit intomainfrom
Conversation
Brings langchain-colony's tool surface in line with crewai-colony by adding all the SDK 1.4.0 tools that were previously missing, plus the SDK 1.5.0 verify_webhook helper. New tools (auto-included in ColonyToolkit().get_tools()): - ColonyFollowUser, ColonyUnfollowUser (social graph) - ColonyReactToPost, ColonyReactToComment (emoji reactions) - ColonyGetPoll, ColonyVotePoll (polls) - ColonyJoinColony, ColonyLeaveColony (membership) - ColonyCreateWebhook, ColonyGetWebhooks, ColonyDeleteWebhook ColonyToolkit goes from 16 tools (7 read + 9 write) to 27 tools (9 read + 18 write). Standalone (NOT in get_tools(), instantiate directly): - ColonyVerifyWebhook — BaseTool wrapper around verify_webhook for agents that act as webhook receivers. Same pattern as ColonyRegister in crewai-colony. Re-exported from colony_sdk: - verify_webhook — pure-function HMAC-SHA256 verification, constant- time comparison, sha256= prefix tolerance. Re-exported (not re-wrapped) so SDK security fixes apply automatically. ColonyRetriever now uses iter_posts: - Replaces the single get_posts(limit=k) call with iter_posts(max_results=k). Lets callers ask for k larger than one API page (~20 posts) without hand-rolled pagination. - Async path dispatches on inspect.isasyncgenfunction so it works for both sync ColonyClient (sync generator → materialise in to_thread) and AsyncColonyClient (async generator → async for). Tests: - New tests/test_new_tools.py — 33 tests covering all 11 new tools (sync + async paths), verify_webhook re-export identity and signature validation, ColonyVerifyWebhook tool sync + async. - tests/test_retriever.py rewritten to mock iter_posts instead of get_posts (set side_effect=lambda **kw: iter([...]) so multiple invocations get fresh iterators). All 22 retriever tests still pass under the new dispatcher. - tests/test_toolkit.py updated for new tool counts (16→27, 7→9, exclude=14→25, etc) and new write-tool tag membership. - tests/test_async_native.py updated for the same counts and to mock iter_posts on the sync-fallback retriever test. 270 tests passing (was 237). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings langchain-colony's tool surface in line with what
colony-sdk1.4.0 / 1.5.0 actually ships, plus integrates the SDK iterators intoColonyRetriever.New tools (auto-included in
ColonyToolkit().get_tools())ColonyFollowUser,ColonyUnfollowUserColonyReactToPost,ColonyReactToCommentColonyGetPoll,ColonyVotePollColonyJoinColony,ColonyLeaveColonyColonyCreateWebhook,ColonyGetWebhooks,ColonyDeleteWebhookColonyToolkitgoes from 16 tools (7 read + 9 write) to 27 tools (9 read + 18 write).read_only=Truereturns 9 (was 7).Standalone tool
ColonyVerifyWebhook—BaseToolwrapper aroundverify_webhookfor agents that act as webhook receivers. Not inColonyToolkit().get_tools()— instantiate directly when you need it. Same pattern asColonyRegisterin crewai-colony (verification doesn't need an authenticated client).Re-exported from
colony_sdkverify_webhook—from langchain_colony import verify_webhook. HMAC-SHA256, constant-time,sha256=prefix tolerance. Re-exported, not re-wrapped —langchain_colony.verify_webhook is colony_sdk.verify_webhook, so SDK security fixes apply automatically.ColonyRetrievernow usesiter_postsThe async path dispatches on
inspect.isasyncgenfunction(self.client.iter_posts)so it works for both syncColonyClient(sync generator → materialised into_thread) andAsyncColonyClient(async generator →async fornatively).Test plan
pytest tests/ --ignore=tests/test_integration.py— 270 passed (was 237, +33 new tests)ruff checkcleanruff format --checkcleanNew
tests/test_new_tools.py(33 tests):TestFollowUnfollowunfollowcalls the right SDK method (crewai-colony 1.4.0 had a bug where it calledfollowagain)TestReactionsTestPollstextvslabelfallback testTestColonyMembershipTestWebhookToolswh-*list response and bare-list response shapesTestVerifyWebhookReExportsha256=prefix, str payloadTestColonyVerifyWebhookToolsha256=prefix, defensive catch aroundverify_webhookTestDirectConstructiontests/test_retriever.pyrewritten to mockiter_posts(viaside_effect=lambda **kw: iter([...])so re-invocations get fresh iterators).tests/test_toolkit.pyandtests/test_async_native.pyupdated for the new tool counts.This is PR 3 of 4 heading toward v0.6.0. Last code PR — up next: PR 4 (release automation, dependabot, coverage on CI), then cut the release.
🤖 Generated with Claude Code