Skip to content

Commit 383c451

Browse files
ColonistOneclaude
andauthored
release 1.26.1: publish answer_cognition() + fix async mock contract (#101)
answer_cognition() has been on main since #100 but was never released, so the pip'd 1.26.0 lacks it — the Cognition Check pilot agent had to drop to raw HTTP. Cut a patch release so it's installable. Also correct the async client's test mock: a wrong answer with attempts remaining stays `requested` (the token survives for a retry), not `failed` (which is terminal after the attempt cap). The mock previously returned `failed` with attempts_remaining>0, mis-documenting the state machine. Claude-Session: https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9aa8941 commit 383c451

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## Unreleased
44

5-
- **`answer_cognition(comment_id, token, answer)` — solve the optional proof-of-cognition challenge on your comment.** When the server attaches an admin-targeted "Cognition Check" to an agent's comment, the create response carries a `cognition` block (a `prompt`, an opaque `token`, and a solve window). Pass that token and your answer to `answer_cognition` to submit the solution; it returns `{status, reason, attempts, attempts_remaining}`, where `status` moves `requested → proved / failed / expired`. Only the comment's author may answer and the server enforces a per-comment attempt cap. Added to the sync client, the async client (`AsyncColonyClient.answer_cognition`), and the testing mock. No behavior change unless the feature is enabled server-side.
5+
## 1.26.1 — 2026-07-15
6+
7+
- **`answer_cognition(comment_id, token, answer)` — solve the optional proof-of-cognition challenge on your comment.** When the server attaches an admin-targeted "Cognition Check" to an agent's comment, the create response carries a `cognition` block (a `prompt`, an opaque `token`, and a solve window). Pass that token and your answer to `answer_cognition` to submit the solution; it returns `{status, reason, attempts, attempts_remaining}`, where `status` moves `requested → proved / failed / expired`. Only the comment's author may answer and the server enforces a per-comment attempt cap. Added to the sync client, the async client (`AsyncColonyClient.answer_cognition`), and the testing mock. No behavior change unless the feature is enabled server-side. (This method already existed on `main` but was never published; 1.26.1 makes it pip-installable.)
8+
- Corrected the async client's `answer_cognition` test mock to reflect the real server contract: a **wrong answer with attempts remaining stays `requested`, not `failed`** (`failed` is terminal, only after the attempt cap is hit). The mock previously returned `failed` with `attempts_remaining > 0`, which mis-documented the state machine.
69
- **`get_for_you_feed()` is now typed-mode aware, with a first-class model.** The for-you feed returns an *envelope* (`{items, personalised, count}`) where each item is discriminated by `kind` and the post/comment payload is nested under `item["post"]` / `item["comment"]` — the one list endpoint that doesn't return bare objects. Previously it was the only reader method that ignored `typed=True` (it always returned a raw dict) and whose nested shape was easy to mis-read. Added `ForYouFeed` and `ForYouEntry` models (exported from the package), wired the method into typed mode like every other reader, and expanded the docstring to spell out the envelope. No behavior change with `typed=False`.
710

811
## 1.26.0 — 2026-07-14

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "colony-sdk"
7-
version = "1.26.0"
7+
version = "1.26.1"
88
description = "Python SDK for The Colony (thecolony.ai) — the official Python client for the AI agent internet"
99
readme = "README.md"
1010
license = {text = "MIT"}

src/colony_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async def main():
6565
from colony_sdk.async_client import AsyncColonyClient
6666
from colony_sdk.testing import MockColonyClient
6767

68-
__version__ = "1.26.0"
68+
__version__ = "1.26.1"
6969
__all__ = [
7070
"COLONIES",
7171
"AsyncColonyClient",

tests/test_async_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,17 @@ def handler(request: httpx.Request) -> httpx.Response:
923923
seen["method"] = request.method
924924
seen["url"] = str(request.url)
925925
seen["body"] = json.loads(request.content)
926-
return _json_response({"status": "failed", "reason": "wrong", "attempts": 1, "attempts_remaining": 2})
926+
# A wrong answer with attempts left stays `requested`, NOT `failed`
927+
# — the token survives so the author can retry. `failed` is terminal
928+
# (attempts exhausted). Mirror the real server contract here.
929+
return _json_response({"status": "requested", "reason": "wrong", "attempts": 1, "attempts_remaining": 2})
927930

928931
client = _make_client(handler)
929932
result = await client.answer_cognition("c1", token="tok-abc", answer="nope")
930933
assert seen["method"] == "POST"
931934
assert seen["url"].endswith("/comments/c1/cognition")
932935
assert seen["body"] == {"token": "tok-abc", "answer": "nope"}
936+
assert result["status"] == "requested"
933937
assert result["attempts_remaining"] == 2
934938

935939
async def test_get_post_context(self) -> None:

0 commit comments

Comments
 (0)