fix: bounded SDK retries, runnable langgraph example, MCP client shutdown - #32
Merged
Merged
Conversation
…down Co-Authored-By: krishna <87197325+krishna3554@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Fixes #25 — three client-side lifecycle/ergonomics gaps.
1. SDK never retried replay-safe requests.
_requestturned anyhttpx.HTTPError(connect error, timeout) intoDMAConnectionErroron the first failure, even thoughremember()generates itsIdempotency-Keybefore sending, so the exact same request can be safely replayed.DMAClientnow takesmax_retries: int = 2and each call site opts in:_sendloops with exponential backoff + jitter (0.2 * 2**attempt * (0.5 + random())) and re-raisesDMAConnectionErrorafter 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.pywas broken out of the box. It constructed the client with nobase_url, falling back to the placeholderhttps://api.dma.dev, and did all its work at import time without closing the client. Now mirrorsexamples/basic-python/main.py: amain()guarded by__main__,base_url=os.getenv("DMA_BASE_URL", "http://127.0.0.1:8000"), and the graph built/invoked insidewith DMAClient(...).3. MCP server leaked its HTTP client.
main()now wrapsserver.run(transport="stdio")intry/finally: client.close()and configures stderr logging (level viaDMA_MCP_LOG_LEVEL).Tests added in
packages/dma-sdk-python/tests/test_client.pycover the retry replaying the identical idempotency key, DELETE not being retried, and the retry count being bounded.make lint,make typecheck, andmake testpass.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