Skip to content

feat(payments): Add LangGraph integration for payment handling#546

Open
ragsu43 wants to merge 12 commits into
aws:mainfrom
ragsu43:ragsu/langgraph-integration
Open

feat(payments): Add LangGraph integration for payment handling#546
ragsu43 wants to merge 12 commits into
aws:mainfrom
ragsu43:ragsu/langgraph-integration

Conversation

@ragsu43

@ragsu43 ragsu43 commented Jun 23, 2026

Copy link
Copy Markdown

Description of changes:

Added LangGraph middleware and config files for developer integration with ACP.

@ragsu43 ragsu43 requested a review from a team June 23, 2026 18:03
Comment thread src/bedrock_agentcore/payments/integrations/langgraph/config.py Outdated
Comment thread src/bedrock_agentcore/payments/integrations/langgraph/errors.py
Comment thread src/bedrock_agentcore/payments/integrations/langgraph/middleware.py Outdated
  Merge AgentCorePaymentsConfig (LangGraph) and AgentCorePaymentsPluginConfig
  (Strands) into a single dataclass in integrations/config.py. Both names
  remain available as aliases for backward compatibility.
ragsu43 added 5 commits July 1, 2026 23:03
…ersion floor

Fix TYPE_CHECKING import in errors.py to use ..config (parent package)
instead of .config (non-existent sibling module). This resolves mypy/pyright
failures for PaymentErrorContext.config type resolution.

Raise langchain and langgraph minimum versions from >=0.2.0 to >=1.0.0 in
both dev dependencies and the [langgraph] optional group.
AgentMiddleware, create_agent, and the langchain.agents.middleware namespace
are langchain 1.0 APIs — the 0.2.0 floor allowed installations that would
fail at import time.
Cover the auto_session feature path that was previously only validated
live against testnet. Tests verify:
- Session created on first 402 when auto_session=True
- Config mutated with new session ID for subsequent calls
- Session reused across multiple tool calls (no duplicate creation)
- auto_session=False still raises PAYMENT ERROR without session
- Budget and expiry config values passed correctly
- Pre-existing session_id skips auto-creation
Add PRE-MERGE REQUIREMENT note to test_functional.py docstring clarifying
that any middleware changes must be validated against live testnet before
merge, since these tests are skipped in CI.
Add note that one middleware instance should be created per agent
invocation/request. The middleware is not thread-safe due to config
mutations in auto_session and on_payment_error callbacks.
…cation

Extract guard checks, 402 detection, payment request extraction, header
injection, and post-payment rejection detection into shared private
methods. The sync and async paths now only differ at await/sleep
boundaries. Future bug fixes to detection or injection logic only need
to be applied in one place instead of four.

No behavioral changes — 128 tests pass identically before and after.
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:43 — with GitHub Actions Waiting
@ragsu43 ragsu43 force-pushed the ragsu/langgraph-integration branch from 17b79dc to b44cf37 Compare July 2, 2026 01:52
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:52 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:52 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:52 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:52 — with GitHub Actions Waiting
@ragsu43 ragsu43 requested a deployment to manual-approval July 2, 2026 01:52 — with GitHub Actions Waiting
Document when each path is used (.invoke vs .ainvoke), what the async
path does differently (non-blocking sleep, to_thread for signing, async
callbacks), and provide FastAPI and script examples.
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.

3 participants