Skip to content

feat: DELEGA_AGENT_KEY env fallback + async test coverage → 0.2.1#7

Merged
ryanmcmillan merged 1 commit intomainfrom
fix/env-tolerance-and-async-tests
Apr 14, 2026
Merged

feat: DELEGA_AGENT_KEY env fallback + async test coverage → 0.2.1#7
ryanmcmillan merged 1 commit intomainfrom
fix/env-tolerance-and-async-tests

Conversation

@ryanmcmillan
Copy link
Copy Markdown
Member

Summary

Two small additions shipped together as a patch.

T2.4 — env var tolerance

Accept `DELEGA_AGENT_KEY` as a fallback for `DELEGA_API_KEY` so agents configuring @delega-dev/mcp (primary: `DELEGA_AGENT_KEY`) and this SDK (primary: `DELEGA_API_KEY`) in one shell don't need to set both. `DELEGA_API_KEY` still wins when both are set.

Sibling patches: @delega-dev/mcp@1.2.1 and @delega-dev/cli@1.2.1 already shipped.

T3.1 — async test coverage

New `tests/test_async_client.py` with 11 tests using `httpx.MockTransport` to mirror the sync 0.2.0 coverage — `delegate/assign/chain/update_context/find_duplicates` each covered with both hosted and self-hosted response shapes where they diverge. Also covers the hosted-only `usage()` gate with a "mock transport never called" assertion.

`.github/workflows/ci.yml` gains `pytest-asyncio` so the matrix (Python 3.9-3.13) actually runs the new file.

Test plan

  • `pytest` — 76 passed (65 sync + 11 async)
  • CI matrix runs pytest-asyncio
  • Env fallback test covers both branches (primary wins, fallback used when primary unset)

T2.4 + T3.1 from followups-after-1.2.0-night.md

🤖 Generated with Claude Code

Two small additions shipped together as a patch.

1. Env var tolerance (T2.4)
   - Accept DELEGA_AGENT_KEY as fallback for DELEGA_API_KEY so agents
     configuring @delega-dev/mcp (primary: DELEGA_AGENT_KEY) and this
     SDK (primary: DELEGA_API_KEY) in one shell don't need to set both.
   - DELEGA_API_KEY still wins when both are set.
   - Applied to both Delega and AsyncDelega.
   - 2 new sync tests, 1 new async test cover the env fallback.

2. Async test coverage (T3.1)
   - New tests/test_async_client.py with 11 tests using httpx.MockTransport
     to mirror the sync coverage added in 0.2.0 — delegate/assign/chain/
     update_context/find_duplicates each covered with both hosted and
     self-hosted response shapes where the shape differs. Also covers the
     hosted-only usage() gate with a "mock transport never called" assertion.
   - .github/workflows/ci.yml gains pytest-asyncio so CI actually runs
     the new file across the Python 3.9-3.13 matrix.

Full test suite: 76 passed (65 sync + 11 async).

Sibling patches: @delega-dev/mcp@1.2.1 and @delega-dev/cli@1.2.1 both
shipped. The three packages are now consistent on env var handling.

T2.4 + T3.1 from followups-after-1.2.0-night.md

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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@ryanmcmillan ryanmcmillan merged commit 7eabd02 into main Apr 14, 2026
5 checks passed
@ryanmcmillan ryanmcmillan deleted the fix/env-tolerance-and-async-tests branch April 14, 2026 18:40
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