Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

docs(middleware): fix 7→8 hooks, cross-link deferred tools from Agents/MCP

xf gongf9e37cc443cb
diff --git a/website/docs/guides/agents/tool-use.md b/website/docs/guides/agents/tool-use.md
index daeff1e..a260a61 100644
--- a/website/docs/guides/agents/tool-use.md
+++ b/website/docs/guides/agents/tool-use.md
@@ -255,3 +255,7 @@ and exits.
HTTP-calling tool, end-to-end.
- [MCP Loading](../mcp/loading) — pull an entire toolset off an MCP
server in one call.
+- [Deferred Tool Groups](../middleware/deferred-tools) — when the
+ combined tool list across several MCP servers is dozens or hundreds
+ of tools, hide the schemas behind a catalog and let the model expand
+ groups on demand via the built-in `load_tools` tool.
diff --git a/website/docs/guides/mcp/loading.md b/website/docs/guides/mcp/loading.md
index cd4bd92..c2c1dca 100644
--- a/website/docs/guides/mcp/loading.md
+++ b/website/docs/guides/mcp/loading.md
@@ -119,6 +119,15 @@ agent = Agent(
The model sees one combined JSON Schema; the loop dispatches each
call to the right implementation.
+:::tip Many MCP servers? Defer them.
+If you wire up several MCP servers and only a few are needed per
+conversation, eagerly loading every schema into the system prompt
+becomes the dominant context cost. Wrap each server's tools in a
+[`DeferredToolGroup`](../middleware/deferred-tools) — CubePi replaces
+the full schemas with a compact catalog and lets the model expand a
+group on demand via the built-in `load_tools` tool.
+:::
+
## Per-call vs reusable connections
CubePi opens a new transport per `execute` call. That's:
@@ -166,3 +175,7 @@ downstream programmatic access, but not shown to the model.
dispatched.
- [`make_mcp_agent_tool` source](https://github.com/cubeplexai/cubepi/blob/main/cubepi/mcp/_adapter.py)
— the schema → Pydantic adapter, if you need to customise.
+- [Deferred Tool Groups](../middleware/deferred-tools) — hide MCP
+ schemas from the system prompt and let the model expand them on
+ demand. Useful when several MCP servers add up to a context-heavy
+ toolbelt.
diff --git a/website/docs/guides/middleware/examples.md b/website/docs/guides/middleware/examples.md
index f77180d..0164d67 100644
--- a/website/docs/guides/middleware/examples.md
+++ b/website/docs/guides/middleware/examples.md
@@ -353,7 +353,7 @@ cross-process suspend/resume — are in the [HITL guide](../hitl/overview).
## See also
-- [The 7 Hooks](./hooks) — exact semantics of each hook.
+- [The 8 Hooks](./hooks) — exact semantics of each hook.
- [Composition Rules](./composition) — how multiple middlewares
combine.
- [Recipes](../../recipes/weather-agent) — middleware composed into
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/agents/tool-use.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/agents/tool-use.md
index 8741f5d..585a3ea 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/agents/tool-use.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/agents/tool-use.md
@@ -236,3 +236,6 @@ CubePi 仅在当前批次中 *每个* 工具结果都是 `terminate=True` 时才
HTTP 请求的工具,端到端。
- [MCP 加载](../mcp/loading) —— 一次性把一个 MCP server 的整套工具
拉下来。
+- [延迟工具组](../middleware/deferred-tools) —— 当多个 MCP server 加起来
+ 有几十上百个工具时,可以把 schema 藏在目录后面,让模型通过内置的
+ `load_tools` 工具按需展开。
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mcp/loading.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mcp/loading.md
index ae16d70..ac161c7 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mcp/loading.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mcp/loading.md
@@ -103,6 +103,14 @@ agent = Agent(
模型看到的是合并后的统一 JSON Schema;循环会将每次调用分发给对应的实现。
+:::tip MCP server 很多?延迟加载它们
+如果你接了好几个 MCP server、但每次对话只用到其中一两个,把每个 server
+的 schema 全部塞进 system prompt 就成了主要的上下文成本。把每组 tool
+包成一个 [`DeferredToolGroup`](../middleware/deferred-tools)——CubePi 会把
+完整 schema 换成一份紧凑目录,让模型通过内置的 `load_tools` 工具按需
+展开。
+:::
+
## 按次连接与复用连接
CubePi 每次 `execute` 调用都会建立新的传输连接。这样做:
@@ -131,3 +139,6 @@ CubePi 每次 `execute` 调用都会建立新的传输连接。这样做:
- [MCP 认证](./auth) —— Bearer token、请求头、基于环境变量的凭据。
- [工具使用](../agents/tool-use) —— 工具(MCP 或其他)的分发机制。
- [`make_mcp_agent_tool` 源码](https://github.com/cubeplexai/cubepi/blob/main/cubepi/mcp/_adapter.py) —— schema → Pydantic 适配器,如需自定义可参考。
+- [延迟工具组](../middleware/deferred-tools) —— 把 MCP schema 从 system
+ prompt 里藏起来,让模型按需展开。当多个 MCP server 加起来构成一个
+ 上下文沉重的工具集时很有用。
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/examples.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/examples.md
index 164c0db..65ab043 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/examples.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/examples.md
@@ -279,6 +279,6 @@ agent = Agent(
## 另请参阅
-- [7 个 Hook](./hooks) —— 每个 hook 的精确语义。
+- [8 个 Hook](./hooks) —— 每个 hook 的精确语义。
- [组合规则](./composition) —— 多个中间件如何组合。
- [配方](../../recipes/weather-agent) —— 中间件在真实应用中的组合。
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/agents/tool-use.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/agents/tool-use.md
index 8741f5d..585a3ea 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/agents/tool-use.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/agents/tool-use.md
@@ -236,3 +236,6 @@ CubePi 仅在当前批次中 *每个* 工具结果都是 `terminate=True` 时才
HTTP 请求的工具,端到端。
- [MCP 加载](../mcp/loading) —— 一次性把一个 MCP server 的整套工具
拉下来。
+- [延迟工具组](../middleware/deferred-tools) —— 当多个 MCP server 加起来
+ 有几十上百个工具时,可以把 schema 藏在目录后面,让模型通过内置的
+ `load_tools` 工具按需展开。
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/mcp/loading.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/mcp/loading.md
index ae16d70..ac161c7 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/mcp/loading.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/mcp/loading.md
@@ -103,6 +103,14 @@ agent = Agent(
模型看到的是合并后的统一 JSON Schema;循环会将每次调用分发给对应的实现。
+:::tip MCP server 很多?延迟加载它们
+如果你接了好几个 MCP server、但每次对话只用到其中一两个,把每个 server
+的 schema 全部塞进 system prompt 就成了主要的上下文成本。把每组 tool
+包成一个 [`DeferredToolGroup`](../middleware/deferred-tools)——CubePi 会把
+完整 schema 换成一份紧凑目录,让模型通过内置的 `load_tools` 工具按需
+展开。
+:::
+
## 按次连接与复用连接
CubePi 每次 `execute` 调用都会建立新的传输连接。这样做:
@@ -131,3 +139,6 @@ CubePi 每次 `execute` 调用都会建立新的传输连接。这样做:
- [MCP 认证](./auth) —— Bearer token、请求头、基于环境变量的凭据。
- [工具使用](../agents/tool-use) —— 工具(MCP 或其他)的分发机制。
- [`make_mcp_agent_tool` 源码](https://github.com/cubeplexai/cubepi/blob/main/cubepi/mcp/_adapter.py) —— schema → Pydantic 适配器,如需自定义可参考。
+- [延迟工具组](../middleware/deferred-tools) —— 把 MCP schema 从 system
+ prompt 里藏起来,让模型按需展开。当多个 MCP server 加起来构成一个
+ 上下文沉重的工具集时很有用。
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/middleware/examples.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/middleware/examples.md
index 164c0db..65ab043 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/middleware/examples.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.10/guides/middleware/examples.md
@@ -279,6 +279,6 @@ agent = Agent(
## 另请参阅
-- [7 个 Hook](./hooks) —— 每个 hook 的精确语义。
+- [8 个 Hook](./hooks) —— 每个 hook 的精确语义。
- [组合规则](./composition) —— 多个中间件如何组合。
- [配方](../../recipes/weather-agent) —— 中间件在真实应用中的组合。
diff --git a/website/versioned_docs/version-0.10/guides/agents/tool-use.md b/website/versioned_docs/version-0.10/guides/agents/tool-use.md
index daeff1e..a260a61 100644
--- a/website/versioned_docs/version-0.10/guides/agents/tool-use.md
+++ b/website/versioned_docs/version-0.10/guides/agents/tool-use.md
@@ -255,3 +255,7 @@ and exits.
HTTP-calling tool, end-to-end.
- [MCP Loading](../mcp/loading) — pull an entire toolset off an MCP
server in one call.
+- [Deferred Tool Groups](../middleware/deferred-tools) — when the
+ combined tool list across several MCP servers is dozens or hundreds
+ of tools, hide the schemas behind a catalog and let the model expand
+ groups on demand via the built-in `load_tools` tool.
diff --git a/website/versioned_docs/version-0.10/guides/mcp/loading.md b/website/versioned_docs/version-0.10/guides/mcp/loading.md
index cd4bd92..c2c1dca 100644
--- a/website/versioned_docs/version-0.10/guides/mcp/loading.md
+++ b/website/versioned_docs/version-0.10/guides/mcp/loading.md
@@ -119,6 +119,15 @@ agent = Agent(
The model sees one combined JSON Schema; the loop dispatches each
call to the right implementation.
+:::tip Many MCP servers? Defer them.
+If you wire up several MCP servers and only a few are needed per
+conversation, eagerly loading every schema into the system prompt
+becomes the dominant context cost. Wrap each server's tools in a
+[`DeferredToolGroup`](../middleware/deferred-tools) — CubePi replaces
+the full schemas with a compact catalog and lets the model expand a
+group on demand via the built-in `load_tools` tool.
+:::
+
## Per-call vs reusable connections
CubePi opens a new transport per `execute` call. That's:
@@ -166,3 +175,7 @@ downstream programmatic access, but not shown to the model.
dispatched.
- [`make_mcp_agent_tool` source](https://github.com/cubeplexai/cubepi/blob/main/cubepi/mcp/_adapter.py)
— the schema → Pydantic adapter, if you need to customise.
+- [Deferred Tool Groups](../middleware/deferred-tools) — hide MCP
+ schemas from the system prompt and let the model expand them on
+ demand. Useful when several MCP servers add up to a context-heavy
+ toolbelt.
diff --git a/website/versioned_docs/version-0.10/guides/middleware/examples.md b/website/versioned_docs/version-0.10/guides/middleware/examples.md
index f77180d..0164d67 100644
--- a/website/versioned_docs/version-0.10/guides/middleware/examples.md
+++ b/website/versioned_docs/version-0.10/guides/middleware/examples.md
@@ -353,7 +353,7 @@ cross-process suspend/resume — are in the [HITL guide](../hitl/overview).
## See also
-- [The 7 Hooks](./hooks) — exact semantics of each hook.
+- [The 8 Hooks](./hooks) — exact semantics of each hook.
- [Composition Rules](./composition) — how multiple middlewares
combine.
- [Recipes](../../recipes/weather-agent) — middleware composed into