Skip to content

fix: bounded SDK retries, runnable langgraph example, MCP client shutdown - #32

Merged
krishna3554 merged 1 commit into
mainfrom
devin/1788202022-issue-fix
Aug 31, 2026
Merged

krishna3554 merged 1 commit into
mainfrom
devin/1788202022-issue-fix

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Fixes #25 — three client-side lifecycle/ergonomics gaps.

1. SDK never retried replay-safe requests. _request turned any httpx.HTTPError (connect error, timeout) into DMAConnectionError on the first failure, even though remember() generates its Idempotency-Key before sending, so the exact same request can be safely replayed. DMAClient now takes max_retries: int = 2 and each call site opts in:

response = self._request("POST", "v1/memories", json=payload,
                         headers={"Idempotency-Key": key}, retryable=True)  # same key on every attempt

_send loops with exponential backoff + jitter (0.2 * 2**attempt * (0.5 + random())) and re-raises DMAConnectionError after the last attempt. Retryable: remember (same key), recall (read-only POST), list, explain. Not retryable: forget (DELETE replay is 404-ambiguous). HTTP error responses (4xx/5xx) are unchanged — only transport failures are retried.

2. examples/langgraph/main.py was broken out of the box. It constructed the client with no base_url, falling back to the placeholder https://api.dma.dev, and did all its work at import time without closing the client. Now mirrors examples/basic-python/main.py: a main() guarded by __main__, base_url=os.getenv("DMA_BASE_URL", "http://127.0.0.1:8000"), and the graph built/invoked inside with DMAClient(...).

3. MCP server leaked its HTTP client. main() now wraps server.run(transport="stdio") in try/finally: client.close() and configures stderr logging (level via DMA_MCP_LOG_LEVEL).

Tests added in packages/dma-sdk-python/tests/test_client.py cover the retry replaying the identical idempotency key, DELETE not being retried, and the retry count being bounded. make lint, make typecheck, and make test pass.

Link to Devin session: https://app.devin.ai/sessions/fa1eb7437702477ca712f1984ffc9451
Open in Devin Desktop: https://app.devin.ai/desktop/session/fa1eb7437702477ca712f1984ffc9451?variant=devin
Requested by: @krishna3554

…down

Co-Authored-By: krishna <87197325+krishna3554@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
project-49zal Ready Ready Preview Aug 31, 2026 6:47pm

@krishna3554
krishna3554 merged commit 9d92efc into main Aug 31, 2026
3 checks passed
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.

DX: SDK has no retry despite idempotency-safe writes; langgraph example targets nonexistent api.dma.dev; MCP server never closes its client

1 participant