feat: 1.2.0 multi-agent coordination methods + usage() fix → 0.2.0#6
Merged
ryanmcmillan merged 1 commit intomainfrom Apr 14, 2026
Merged
feat: 1.2.0 multi-agent coordination methods + usage() fix → 0.2.0#6ryanmcmillan merged 1 commit intomainfrom
ryanmcmillan merged 1 commit intomainfrom
Conversation
Brings the Python SDK in line with @delega-dev/mcp 1.2.0. Agents using
this SDK can now delegate, inspect chains, pass shared context, and
dedup — the surfaces that turn Delega from a task tracker into an
actual coordination layer.
New methods (sync + async):
- tasks.assign(task_id, agent_id) — PUT /tasks/:id with
assigned_to_agent_id (None to unassign). For multi-agent handoffs
use delegate() instead — assign() doesn't record a chain.
- tasks.chain(task_id) — GET /tasks/:id/chain. Returns
DelegationChain dataclass. Client normalizes hosted {root_id}
vs self-hosted {root: Task} shape divergence so root_id is
always populated.
- tasks.update_context(task_id, context) — PATCH /tasks/:id/context.
Deep-merges keys (not replace). Normalizes hosted bare-dict vs
self-hosted full-task response; always returns the merged dict.
- tasks.find_duplicates(content, threshold=None) — POST /tasks/dedup.
Returns DedupResult with DuplicateMatch entries.
Existing method updates:
- tasks.delegate() gains project_id / labels / due_date /
assigned_to_agent_id kwargs matching the delega-mcp tool signature.
Existing callers unaffected (all additions are optional kwargs).
- Delega.usage() BUG FIX: was hitting /stats, now correctly /usage.
Raises DelegaError before any HTTP call on self-hosted backends
(which don't expose /usage — mirrors the delega-mcp client gate).
Async usage() also gets the gate.
Model updates:
- Task now surfaces parent_task_id, root_task_id, delegation_depth,
status, assigned_to_agent_id, created_by_agent_id,
completed_by_agent_id, context. from_dict() auto-parses the
JSON-encoded context string that hosted returns (D1/SQLite text
column) vs the dict self-hosted returns (SQLAlchemy JSON).
- New: DelegationChain, DedupResult, DuplicateMatch dataclasses.
All exposed from the package root.
Test updates:
- 10 new unit tests covering all new methods and both shape branches
of chain() and update_context(). Existing test_usage split into
_hosted + _self_hosted_raises_before_fetch (asserts mock never
called).
- HTTPClient.path_prefix property added to both sync and async
transports so the usage gate can inspect the namespace.
Version: 0.1.3 → 0.2.0 (minor — new methods, usage() endpoint
change is a semantic fix not a signature change).
63/63 pytest tests passing.
Out of scope (follow-up): async test coverage for the new methods.
The async paths are line-by-line mirrors of sync; a later PR can
add async-specific tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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 the Python SDK in line with @delega-dev/mcp 1.2.0. Fixes a latent bug in `usage()` along the way.
New methods (sync + async, 1:1 with delega-mcp 1.2.0)
Bug fix
`Delega.usage()` was hitting `/stats` instead of `/usage` since inception — silently returning stats data instead of quota. Now correctly calls `/usage` on hosted, raises `DelegaError` before any HTTP call on self-hosted (mirrors delega-mcp's client-side gate). Async `usage()` was already hitting `/usage` but lacked the gate; added.
Task model enriched
`Task.from_dict()` now surfaces `parent_task_id`, `root_task_id`, `delegation_depth`, `status`, `assigned_to_agent_id`, `created_by_agent_id`, `completed_by_agent_id`, `context`. Auto-parses the JSON-encoded context string that hosted returns (D1 text column) vs the dict self-hosted returns (SQLAlchemy JSON).
New dataclasses: `DelegationChain`, `DedupResult`, `DuplicateMatch` — all exported from the package root.
Version: 0.1.3 → 0.2.0
Minor bump. All additions are backward compatible (existing `delegate()` / `usage()` callers pass through unchanged; the endpoint correction in `usage()` is a semantic fix).
Test plan
Release
Tag `v0.2.0` after merge — `.github/workflows/publish.yml` publishes to PyPI via OIDC and creates the GitHub Release.
Out of scope (follow-up)
🤖 Generated with Claude Code