[PR #3938] docs(middleware): add langchain-runcycles community middleware integration #3947

Open
opened 2026-06-05 18:53:40 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/3938
Author: @amavashev
Created: 5/10/2026
Status: 🔄 Open

Base: mainHead: add-langchain-runcycles-middleware


📝 Commits (10+)

  • ab5e0ab docs(middleware): add langchain-runcycles community middleware integration
  • be6a1d6 fix(runcycles): address CI feedback (langchain.tools import + Vale dashes)
  • 6630bf4 docs(runcycles): brand fix + accuracy pass per upstream review
  • 0a718e6 docs(runcycles): add retry-duplicate side-effect callout under settlement policy
  • 120b713 docs(runcycles): drop SaaS-only framing under Setup
  • 0a953d8 docs(runcycles): scrub remaining em-dashes from Production notes
  • c57427f docs(runcycles): mirror v0.1.3 namespace section + em-dash scrub
  • 5206626 docs(runcycles): replace undefined current_run_id() in callable example
  • 1828e25 docs(runcycles): add CyclesModelGate (v0.1.5) section + 3-class composition example
  • 14e3a67 docs(runcycles): cleanup pass — Tabler icons + version-added Notes + 3-class wording

📊 Changes

2 files changed (+403 additions, -0 deletions)

View changed files

📝 src/oss/python/integrations/middleware/index.mdx (+1 -0)
src/oss/python/integrations/middleware/runcycles.mdx (+402 -0)

📄 Description

Summary

Adds the langchain-runcycles middleware to the integrations directory. The package exposes two AgentMiddleware subclasses on top of the LangChain 1.x middleware API:

  • CyclesToolGate — gates each tool call via wrap_tool_call, authorizing through an external Cycles policy/budget service and optionally reserving budget per call. Returns a ToolMessage on denial so the agent can recover gracefully.
  • CyclesFanOutGate — caps model turns per run via before_model with @hook_config(can_jump_to=["end"]). Optionally consults a remote policy on each turn for runaway-loop and burst-budget enforcement.

Both middleware support sync (agent.invoke) and async (agent.ainvoke) paths and compose with HumanInTheLoopMiddleware for production-grade agent governance.

Changes

  1. src/oss/python/integrations/middleware/runcycles.mdx — full integration page following TEMPLATE.mdx (Overview with metadata table + Features, Setup with Credentials + Installation, Instantiation, Use with an agent, dedicated sections for each middleware class, Async support, API reference).
  2. src/oss/python/integrations/middleware/index.mdx — adds a row to the Community integrations table linking to the new docs page.

Package details

PyPI https://pypi.org/project/langchain-runcycles/
Source https://github.com/runcycles/langchain-runcycles
License Apache-2.0
Python 3.10+
LangChain >=1.0,<2.0
Latest version v0.1.1

Compliance with publishing guide

Followed docs.langchain.com/oss/python/contributing/publish-langchain:

  • Standalone PyPI package under our own GitHub organization (not submitted to langchain-ai/langchain)
  • Naming follows the langchain-<service> convention (matches langchain-anthropic, langchain-openai)
  • Documentation page uses the official middleware template
  • All code examples in the MDX run against the published package
  • Apache-2.0 license, typed (py.typed marker present)

Positioning note for reviewers

I added both a dedicated MDX page and a Community-table row pointing to it. The publish guide says to "create the relevant documentation pages", but the existing Community integrations table currently links straight to GitHub repos with no dedicated MDX. Happy to:

  • Drop the MDX page and convert to a plain Community-table row pointing at the GitHub repo (matches the existing Community pattern), or
  • Move to the Official integrations table if that's preferred for langchain-<service>-naming-convention third-party packages.

Whatever positioning the maintainers prefer, just let me know in review and I'll adjust.

Test plan

  • All code examples in the new MDX file have been validated against langchain-runcycles==0.1.1 installed from real PyPI in a fresh venv
  • Package itself: 68 tests, 99.26% coverage, ruff + mypy strict clean (CI)
  • Integration smoke test (tests/integration/test_live_agent.py) confirms both middleware classes work with a real create_agent call against FakeMessagesListChatModel
  • Mintlify-flavored components used in the MDX (<CodeGroup>, <Tooltip>, <Tip>, <Icon>) match the patterns in existing official integration pages

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/3938 **Author:** [@amavashev](https://github.com/amavashev) **Created:** 5/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `add-langchain-runcycles-middleware` --- ### 📝 Commits (10+) - [`ab5e0ab`](https://github.com/langchain-ai/docs/commit/ab5e0ab76de2ee861efa3c9f507f0c208e9a5bb9) docs(middleware): add langchain-runcycles community middleware integration - [`be6a1d6`](https://github.com/langchain-ai/docs/commit/be6a1d695d39292946f331856780ff795d3ebce3) fix(runcycles): address CI feedback (langchain.tools import + Vale dashes) - [`6630bf4`](https://github.com/langchain-ai/docs/commit/6630bf4a443dfa51962cd55ccc034f3b689c7605) docs(runcycles): brand fix + accuracy pass per upstream review - [`0a718e6`](https://github.com/langchain-ai/docs/commit/0a718e6450bf0c2d4ac04087ea85420bfc19aee7) docs(runcycles): add retry-duplicate side-effect callout under settlement policy - [`120b713`](https://github.com/langchain-ai/docs/commit/120b713ab15e9196436e9540018e37252e63e857) docs(runcycles): drop SaaS-only framing under Setup - [`0a953d8`](https://github.com/langchain-ai/docs/commit/0a953d8473b85e9b7e2a4812e6424cc5da2ca04a) docs(runcycles): scrub remaining em-dashes from Production notes - [`c57427f`](https://github.com/langchain-ai/docs/commit/c57427f63254f1eb779e45357c47dd8dae78d69e) docs(runcycles): mirror v0.1.3 namespace section + em-dash scrub - [`5206626`](https://github.com/langchain-ai/docs/commit/5206626304415ff79ba5ff0c067e72d05cf61578) docs(runcycles): replace undefined current_run_id() in callable example - [`1828e25`](https://github.com/langchain-ai/docs/commit/1828e25e9e4c0c151d6fc6e2257bbad0ee5675b9) docs(runcycles): add CyclesModelGate (v0.1.5) section + 3-class composition example - [`14e3a67`](https://github.com/langchain-ai/docs/commit/14e3a6773c576290ab25c3776db4af3daf8e1e95) docs(runcycles): cleanup pass — Tabler icons + version-added Notes + 3-class wording ### 📊 Changes **2 files changed** (+403 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/python/integrations/middleware/index.mdx` (+1 -0) ➕ `src/oss/python/integrations/middleware/runcycles.mdx` (+402 -0) </details> ### 📄 Description ## Summary Adds the [`langchain-runcycles`](https://pypi.org/project/langchain-runcycles/) middleware to the integrations directory. The package exposes two `AgentMiddleware` subclasses on top of the LangChain 1.x middleware API: - **`CyclesToolGate`** — gates each tool call via `wrap_tool_call`, authorizing through an external Cycles policy/budget service and optionally reserving budget per call. Returns a `ToolMessage` on denial so the agent can recover gracefully. - **`CyclesFanOutGate`** — caps model turns per run via `before_model` with `@hook_config(can_jump_to=["end"])`. Optionally consults a remote policy on each turn for runaway-loop and burst-budget enforcement. Both middleware support sync (`agent.invoke`) and async (`agent.ainvoke`) paths and compose with `HumanInTheLoopMiddleware` for production-grade agent governance. ## Changes 1. **`src/oss/python/integrations/middleware/runcycles.mdx`** — full integration page following [`TEMPLATE.mdx`](https://github.com/langchain-ai/docs/blob/main/src/oss/python/integrations/middleware/TEMPLATE.mdx) (Overview with metadata table + Features, Setup with Credentials + Installation, Instantiation, Use with an agent, dedicated sections for each middleware class, Async support, API reference). 2. **`src/oss/python/integrations/middleware/index.mdx`** — adds a row to the Community integrations table linking to the new docs page. ## Package details | | | |---|---| | PyPI | https://pypi.org/project/langchain-runcycles/ | | Source | https://github.com/runcycles/langchain-runcycles | | License | Apache-2.0 | | Python | 3.10+ | | LangChain | `>=1.0,<2.0` | | Latest version | v0.1.1 | ## Compliance with publishing guide Followed [`docs.langchain.com/oss/python/contributing/publish-langchain`](https://docs.langchain.com/oss/python/contributing/publish-langchain): - [x] Standalone PyPI package under our own GitHub organization (not submitted to `langchain-ai/langchain`) - [x] Naming follows the `langchain-<service>` convention (matches `langchain-anthropic`, `langchain-openai`) - [x] Documentation page uses the official middleware template - [x] All code examples in the MDX run against the published package - [x] Apache-2.0 license, typed (`py.typed` marker present) ## Positioning note for reviewers I added both a dedicated MDX page **and** a Community-table row pointing to it. The publish guide says to "create the relevant documentation pages", but the existing Community integrations table currently links straight to GitHub repos with no dedicated MDX. Happy to: - Drop the MDX page and convert to a plain Community-table row pointing at the GitHub repo (matches the existing Community pattern), **or** - Move to the Official integrations table if that's preferred for `langchain-<service>`-naming-convention third-party packages. Whatever positioning the maintainers prefer, just let me know in review and I'll adjust. ## Test plan - [x] All code examples in the new MDX file have been validated against `langchain-runcycles==0.1.1` installed from real PyPI in a fresh venv - [x] Package itself: 68 tests, 99.26% coverage, ruff + mypy strict clean ([CI](https://github.com/runcycles/langchain-runcycles/actions)) - [x] Integration smoke test (`tests/integration/test_live_agent.py`) confirms both middleware classes work with a real `create_agent` call against `FakeMessagesListChatModel` - [x] Mintlify-flavored components used in the MDX (`<CodeGroup>`, `<Tooltip>`, `<Tip>`, `<Icon>`) match the patterns in existing official integration pages --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 18:53:40 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#3947