fix(langgraph): add retry for checkpoint write HTTP calls#1711
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds retry + timeout handling to LangGraph checkpoint write paths to reduce silent checkpoint loss when transient HTTP failures occur between the Python LangGraph integration and the Go checkpoint service.
Changes:
- Add 3-attempt retry loop with 500ms backoff and 10s request timeout for
aput()andaput_writes()checkpoint POSTs. - Add unit tests covering success, retry-on-transient-failure, and exhaustion behavior for both write APIs.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/kagent-langgraph/src/kagent/langgraph/_checkpointer.py | Implements retry/backoff + per-request timeout for checkpoint and writes POST calls. |
| python/packages/kagent-langgraph/tests/test_checkpointer.py | Adds unit tests validating retry behavior and failure propagation. |
| python/packages/kagent-langgraph/tests/init.py | Test package marker (no functional changes). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2603075 to
4ad7fde
Compare
EItanya
previously approved these changes
Apr 20, 2026
KAgentCheckpointer HTTP POST calls to persist checkpoints can fail transiently during rolling updates or network interruptions. LangGraph catches the exception internally, so the checkpoint is silently lost and conversation history appears empty on subsequent reads. Add 3-attempt retry with 500ms backoff and 10s timeout to aput() and aput_writes(). Only transient errors (network failures, 5xx, 429) are retried; client errors (4xx) and CancelledError propagate immediately. Add unit tests for retry behavior. Signed-off-by: Ziwen Ning <ziwen@ningziwen.com>
555aa8e to
80a7675
Compare
EItanya
approved these changes
Apr 21, 2026
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.
Motivation
The
KAgentCheckpointermakes HTTP POST calls to the Go service to persist LangGraph checkpoints. These calls can fail transiently due to connection timeouts, network interruptions, or the Go service being briefly unavailable during rolling updates. Whenaput()oraput_writes()fails, LangGraph catches the exception internally and continues execution — the agent responds successfully but the checkpoint is silently lost, causing conversation history to be empty on subsequent reads.Summary
Add 3-attempt retry with 500ms backoff and explicit 10s timeout to both
aput()andaput_writes()inKAgentCheckpointer. If all attempts fail, the error is logged and re-raised so LangGraph can handle it.Before
Transient HTTP failure → checkpoint silently lost →
GET /api/langgraph/checkpoints?thread_id=...returns empty → conversation history missing.After
Transient failures are retried automatically. Persistent failures are logged with full context before re-raising.
Reproducing steps (before fix)
GET /api/langgraph/checkpoints?thread_id={session_id}&limit=1After fix
Same steps — checkpoint is always present after chat completes.
Testing Plan