Skip to content

docs(langchain): add tutorial reference + Python LangChain module reference#178

Merged
r-marques merged 2 commits into
mainfrom
docs/langchain-tutorial-and-python-module
May 22, 2026
Merged

docs(langchain): add tutorial reference + Python LangChain module reference#178
r-marques merged 2 commits into
mainfrom
docs/langchain-tutorial-and-python-module

Conversation

@r-marques
Copy link
Copy Markdown
Member

@r-marques r-marques commented May 22, 2026

Summary

Three changes for the LangChain integration docs:

  1. docs/integrate/add-to-your-agent/langchain.mdx — surfaces the new SDK helpers and the x402 discovery-first flow:
    • <Card> link to the new langchain-paid-agent-py tutorial at the top.
    • New "Discovery-first flow with create_paid_react_agent (Python)" subsection that walks the canonical x402 dance: invoke without a token → catch PaymentRequiredError → read accepts[0].scheme/network/plan_id → acquire token via DelegationConfig → retry.
    • New "Reading the settlement receipt" subsection using last_settlement() — explains the LangGraph copies-configurable-per-node quirk and how the SDK works around it.
    • <Note> callout in the Dynamic Credits section on fixed-vs-range plan credit semantics (per nvm-monorepo#1568).
  2. docs.json — sidebar slot for the new docs/api-reference/python/langchain-module page (will be auto-populated by the SDK release pipeline, see below).
  3. skills/nevermined-payments/references/langchain-integration.md (NEW) — closes the pre-existing skill-ref gap that aaitor flagged. Mirrors the strands / fastapi / express patterns: quick start, discovery flow, LangGraph helper, settlement read, decorator configuration, credits semantics, and the HTTP-middleware alternative.

What changed since the original PR (in response to aaitor's review)

The original PR included a hand-authored docs/api-reference/python/langchain-module.mdx and listed the skill reference as out of scope. On checking aaitor's "convention drift" note, I confirmed there IS a Python doc-publish pipeline (payments-py/.github/workflows/publish-mintlify-docs.yml) that does rm -f "$TARGET_DIR"/*.mdx before copying converted output on every release tag — so a hand-authored mdx in docs/api-reference/python/ would be silently wiped. The docs CLAUDE.md rule ("sourced from different repositories — don't modify directly") is correctly stated.

So this PR:

  • Drops the hand-authored langchain-module.mdx — it now lives as a Markdown source in nevermined-io/payments-py#187 (which adds docs/api/12-langchain-integration.md + a FILE_MAPPING entry in scripts/convert_to_mintlify.py + bumps the workflow's expected-file count from 11 to 12). The MDX will be generated by the release pipeline and land here automatically.
  • Adds the skill reference that was previously deferred.

Merge sequence (release-train coordination)

  1. payments-py#187 merges to payments-py main.
  2. payments-py tags a release (e.g. v1.6.1 or v1.7.0). The workflow runs, opens an auto-PR on this repo with the new converted langchain-module.mdx, auto-merges it.
  3. This PR rebases on the updated main (which now contains langchain-module.mdx) and merges. The sidebar entry in docs.json lights up; cross-links from langchain.mdx and the skill reference resolve.

Test plan

  • mintlify broken-linkssuccess no broken links found.
  • docs.json validates as JSON.
  • Integration-page edits + skill ref are coherent on their own (don't depend on the new module page).
  • Hold merge until payments-py#187 merges AND a release ships — the docs.json sidebar entry points at a file that doesn't exist in this repo yet.

Motivation

Sprint 0 of the LangChain integration epic (nevermined-io/nvm-monorepo#1703, sub-issue #1704). The new SDK helpers (last_settlement, create_paid_react_agent) are on payments-py main via #183 (merged) but await a release.

🤖 Generated with Claude Code

…erence

Three changes for the LangChain integration docs:

1. docs/integrate/add-to-your-agent/langchain.mdx:
   - <Card> link to the new langchain-paid-agent-py tutorial at the top
   - "Discovery-first flow with create_paid_react_agent (Python)"
     subsection that shows the x402 discovery → token-acquisition → retry
     pattern using the new SDK helpers
   - "Reading the settlement receipt" subsection using last_settlement()
   - <Note> callout on fixed-vs-range plan credit semantics in the
     Dynamic Credits section (per nvm-monorepo#1568)

2. NEW docs/api-reference/python/langchain-module.mdx: full Python
   module reference covering requires_payment, PaymentRequiredError,
   last_settlement, create_paid_react_agent + end-to-end example.

3. docs.json: wires the new module page into the Python API reference
   sidebar after x402-module.

Surfaced during Sprint 0 of the LangChain integration epic
(nevermined-io/nvm-monorepo#1703). The new helpers
(last_settlement, create_paid_react_agent) are on payments-py main
via #183 but await a release — merging this PR should be coordinated
with the payments-py 1.6.1+ release.

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

mintlify Bot commented May 22, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Nevermined 🟢 Ready View Preview May 22, 2026, 3:05 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@r-marques r-marques marked this pull request as ready for review May 22, 2026 15:08
@r-marques r-marques requested a review from a team as a code owner May 22, 2026 15:08
aaitor
aaitor previously approved these changes May 22, 2026
Copy link
Copy Markdown
Member

@aaitor aaitor left a comment

Choose a reason for hiding this comment

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

Tight docs PR that fully matches the payments-py #183 surface I just reviewed. The new langchain-module.mdx reference page documents all four exports (requires_payment, PaymentRequiredError, last_settlement, create_paid_react_agent) with signatures, the credits-semantics note pointing at nvm-monorepo#1568, and the same multi-tenant warning on last_settlement() that's in the SDK docstring. The integration-guide additions (Discovery-first flow + Reading the settlement receipt + Dynamic Credits clarification) thread cleanly with the new reference page. Cross-references all pass Mintlify link-rot. Approving with two LOW body observations and a merge-gate reminder.

Verification I ran

  • gh pr diff 178 (427 lines, all signal — no lockfile-style noise).
  • Cross-checked every code example in langchain-module.mdx against the actual SDK shapes I verified in payments-py #183:
    • X402TokenOptions(scheme=..., delegation_config=DelegationConfig(...)) wrapping — matches get_x402_access_token(plan_id, agent_id=None, token_options=None) signature.
    • from payments_py.x402.langchain import ... exports list — matches the __all__ I saw in the SDK PR.
    • last_settlement() multi-tenant <Warning> wording — verbatim mirror of the SDK docstring.
    • credits semantics note — accurate per the nvm-monorepo#1568 fixed-vs-range behaviour (matches the SDK's updated requires_payment docstring I read yesterday).
  • Verified docs.json slot for langchain-module lands after x402-module in the Python API reference sidebar (line 272 of the diff).
  • Verified the new module page's section anchors (#requires-payment, #paymentrequirederror, #last-settlement, #create-paid-react-agent, #credits-semantics) match the cross-link target IDs from langchain.mdx.
  • Spot-checked the apparent docs/api-reference/ convention concern (the docs CLAUDE.md at L384 says "All the documentation included in the 'docs/api-reference' folder is sourced from different repositories. Don't modify it directly"): no sync workflow exists in .github/workflows/, no scripts/ directory, and the existing module pages (x402-module.mdx, installation.mdx, …) have no auto-gen markers — they're hand-authored. The rule appears aspirational rather than enforced today. See the body note for the suggested follow-up.
  • CI: Mintlify Deployment ✓, link-rot ✓, vale-spellcheck skipping (correctly).
  • Parallel agent panel: skipped — small docs PR, cross-referenced against the payments-py SDK PR I reviewed yesterday, no auth / DB / contract surface. The integration is fully covered by the manual verification above.

Merge-gate reminder

Author's test plan correctly flags "Hold merge until payments-py 1.6.1+ ships" as the open prerequisite. The helpers documented here (last_settlement, create_paid_react_agent) are on payments-py main (PR #183 merged) but await a release. The <Card> link at the top of langchain.mdx points at nevermined-io/tutorials/tree/main/langchain-paid-agent-py — also worth confirming that tutorial repo is ready (or close enough) on merge day, since a broken link from a freshly-deployed docs page would be visible to readers immediately.

Out-of-scope observations (not blocking)

  • docs/api-reference/ convention drift: The docs CLAUDE.md rule ("sourced from different repositories — don't modify directly") doesn't match the current state of the repo. The pre-existing Python module pages have no auto-gen markers; no sync workflow exists. Either the rule needs to be relaxed ("sourced where applicable; new module pages can be hand-authored") or a real sync mechanism needs to be set up. Worth a small follow-up to clarify the CLAUDE.md text so future contributors don't second-guess legitimate additions like this one.
  • skills/nevermined-payments/references/langchain-integration.md is missing: The author's PR description acknowledges this as a pre-existing gap (other frameworks like a2a, express, fastapi, mcp, strands all have *-integration.md files in skills/nevermined-payments/references/). The docs CLAUDE.md L23 explicitly asks contributors to keep these in sync with framework integration changes. Worth a small follow-up PR that mirrors the new module-reference content into a langchain-integration.md skill reference file.

Two changes responding to aaitor's review of #178:

1. Remove docs/api-reference/python/langchain-module.mdx. The Python
   API reference under docs/api-reference/python/ is auto-generated
   on every payments-py release via the `publish-mintlify-docs.yml`
   workflow — the workflow does `rm -f "$TARGET_DIR"/*.mdx` before
   copying converted output. A hand-authored mdx here would be
   silently wiped on the next release. The langchain-module.mdx will
   instead come from nevermined-io/payments-py#187 (adds the source
   MD + converter FILE_MAPPING entry) once that merges and a release
   ships.

2. Add skills/nevermined-payments/references/langchain-integration.md.
   The existing skill references (a2a, express, fastapi, mcp, strands,
   client) all have framework-integration files; langchain was the
   pre-existing gap noted in this PR's description. Mirrors the
   patterns from strands-integration.md — quick start, payment-error
   flow, LangGraph helper (create_paid_react_agent), reading the
   receipt (last_settlement), decorator configuration variants,
   credits semantics, and the HTTP-middleware alternative.

The docs.json sidebar slot for langchain-module stays. It links to a
file that doesn't exist in the docs repo yet, but will once the SDK
release pipeline lands it (per the merge sequence in the PR body).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@r-marques
Copy link
Copy Markdown
Member Author

Thanks @aaitor — your two out-of-scope observations turned into real fixes:

On the convention-drift note (N1): double-checked and the rule docs/api-reference/ is sourced from other reposis **correctly stated** —payments-py/.github/workflows/publish-mintlify-docs.ymldoesrm -f "$TARGET_DIR"/*.mdxbefore copying converted output on every release tag. The reason it's not visible from inside this repo: the workflow lives in the SDK repo, not here. So a hand-authoredlangchain-module.mdx` would have been silently wiped on the next payments-py release. Force-pushed the PR to drop it; the source MD + converter entry now live in nevermined-io/payments-py#187 and the MDX will be produced by the pipeline on next release.

On the skill-reference note (N2): added skills/nevermined-payments/references/langchain-integration.md mirroring the existing strands/fastapi/express patterns.

PR body updated with the new merge sequence. Holding until payments-py#187 lands AND a release ships.

r-marques added a commit to nevermined-io/payments-py that referenced this pull request May 22, 2026
…lify pipeline (#187)

Adds the missing 12th documentation file so the
`publish-mintlify-docs.yml` workflow produces a
`docs/api-reference/python/langchain-module.mdx` in the docs site on
the next `v*.*.*` release tag — same flow as the existing 11 Python
module pages.

Changes:
- `docs/api/12-langchain-integration.md` (NEW): source MD covering
  `requires_payment`, `PaymentRequiredError`, `last_settlement`, and
  `create_paid_react_agent`, plus an end-to-end discovery → token →
  retry walk. Plain Markdown with MkDocs admonitions so the converter
  produces a Mintlify-compatible MDX with frontmatter + Note/Warning
  components.
- `scripts/convert_to_mintlify.py`: adds FILE_MAPPING + LINK_MAPPING
  entries for the new file. Converter ran locally — 12 of 12 files
  converted, 0 errors.
- `.github/workflows/publish-mintlify-docs.yml`: bumps both `-lt 11`
  count checks to `-lt 12`, updates "Updated all 11" → "Updated all
  12", and adds `langchain-module.mdx` to the auto-generated PR body's
  file list.

Motivation: while preparing the hand-authored
`docs/api-reference/python/langchain-module.mdx` in
nevermined-io/docs#178 we noticed the docs CLAUDE.md rule ("sourced
from different repositories — don't modify directly") was correct —
`publish-mintlify-docs.yml` wipes `*.mdx` from the docs python
reference dir on every release before copying the converted output.
Hand-authoring in docs would have been silently deleted on the next
release. This PR is the structurally correct path: source lives here,
the workflow converts and lands on release.

Merge sequence:
1. Merge this PR (no immediate user-facing change — the source MD is
   not part of the converter output until the next tag).
2. Tag a payments-py release (e.g., 1.6.1 or 1.7.0). The workflow
   converts, opens a PR on nevermined-io/docs, auto-merges → the new
   `langchain-module.mdx` lands in the docs site.
3. Then nevermined-io/docs#178 can merge (it relies on this file
   existing in the docs site for cross-links from the integration
   guide).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@r-marques r-marques merged commit 038ad02 into main May 22, 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.

2 participants