@devries-cameron20 / composio Mirror · read-only / commits / b48711c58
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 21:00 UTC

Clarify custom preload use behavior

Dhawal Upadhyay committed May 7, 2026 at 16:44 UTC b48711c587172e923f9b4a372d1099133b5e57ab
3 files changed +17 -15
python/composio/core/models/custom_tool_types.py
-1
@@ -111,7 +111,6 @@ class CustomTool:
111
112
113 CustomToolWireDefinition = session_create_params.ExperimentalCustomTool
114 -CustomToolkitToolWireDefinition = session_create_params.ExperimentalCustomToolkitTool
114 CustomToolkitWireDefinition = session_create_params.ExperimentalCustomToolkit
115
116
python/composio/core/models/tool_router.py
+11 -7
@@ -1046,6 +1046,11 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
1046 Provide ``custom_tools`` or ``custom_toolkits`` to bind SDK-local tools
1047 to the session for search and execution.
1048
1049 + If the existing session has ``preload.tools = "all"``, every bound
1050 + custom tool is also exposed via ``session.tools()`` and re-injected
1051 + with ``preload=True`` on subsequent search/execute calls. A custom tool
1052 + with explicit ``preload=False`` still opts out.
1053 +
1054 :param session_id: The session ID to use.
1055 :param custom_tools: Optional custom tools to bind to the session.
1056 :param custom_toolkits: Optional custom toolkits to bind to the session.
@@ -1092,15 +1097,14 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
1097 else:
1098 session = self._client.tool_router.session.retrieve(session_id)
1099
1095 - # For use(..., custom_tools=...), we only learn the existing session's
1096 - # top-level preload config after attach returns. If that existing config
1097 - # is preload.tools = "all", custom tools should follow the same
1098 - # SDK-local direct exposure rule.
1100 default_custom_preload = _preloads_all_custom_tools(session.config.preload)
1101 if has_customs and default_custom_preload:
1101 - # Attach already happened above with the caller's explicit custom
1102 - # preload hints. This rebuild only changes the payload stored on
1103 - # ToolRouterSession and reused by future search/execute calls.
1102 + # preload.tools = "all" on the existing session is server-authoritative:
1103 + # the backend exposes every custom tool regardless of per-definition
1104 + # preload flags, so the initial attach above (which used the caller's
1105 + # explicit hints) doesn't need re-sending. We only rebuild the in-memory
1106 + # payload so future search/execute calls re-inject with preload=True and
1107 + # session.tools() locally mirrors what the server returns.
1108 inline_custom_tools_payload = _prepare_inline_custom_tools(
1109 custom_tools=custom_tools,
1110 custom_toolkits=custom_toolkits,
ts/packages/core/src/models/ToolRouter.ts
+6 -7
@@ -293,15 +293,14 @@ export class ToolRouter<
293 session = await this.client.toolRouter.session.retrieve(id);
294 }
295
296 - // For use(...customTools), we only learn the existing session's top-level
297 - // preload config after attach returns. If that existing config is
298 - // preload.tools = "all", custom tools should follow the same SDK-local
299 - // direct exposure rule.
296 const defaultCustomPreload = preloadsAllCustomTools(session.config.preload);
297 if (hasCustoms && defaultCustomPreload) {
302 - // Attach already happened above with the caller's explicit custom preload
303 - // hints. This rebuild only changes the payload stored on ToolRouterSession
304 - // and reused by future search/execute calls.
298 + // preload.tools = "all" on the existing session is server-authoritative:
299 + // the backend exposes every custom tool regardless of per-definition
300 + // preload flags, so the initial attach above (which used the caller's
301 + // explicit hints) doesn't need re-sending. We only rebuild the in-memory
302 + // payload so future search/execute calls re-inject with preload=true and
303 + // session.tools() locally mirrors what the server returns.
304 inlineCustomToolsPayload = prepareInlineCustomTools({
305 customTools,
306 customToolkits,