Execute session tools

Executing session tools

When your model asks to call a session tool, execute it with session.execute(). It routes the call through the session's tool router, which is the only place session meta-tools run:

result = session.execute("COMPOSIO_SEARCH_TOOLS", arguments={"queries": [{"use_case": "send an email"}]})

if result.result_type == "failed":
    raise RuntimeError(result.error or f"Tool execution failed (log ID: {result.log_id})")

print(result.data)

Do not execute session tools with tools.execute(), or by passing a user ID to a provider's handle_tool_calls helper — both take the direct execution path, which does not carry your session, and meta-tools fail there with "can only be called inside a tool-router session". The OpenAI and Anthropic helpers also accept the session itself (handle_tool_calls(response=response, session=session) in Python, handleToolCalls(session, response) in TypeScript), which routes through the session while keeping provider argument normalization.

Reading execution results

session.execute() returns a result envelope, not the tool payload directly:

TypeScriptPythonMeaning
datadataThe tool-specific output.
errorerrorError text, or null (None in Python). A failed execution can have no error text.
logIdlog_idThe execution log ID. Local tools return an empty string.
resultTyperesult_typecompleted if execution succeeded, or failed if it failed.

The result can also include instantCharge (instant_charge in Python) when you enable Instant usage charge reporting.

Use resultType (result_type in Python) to check success, as shown above. Checking error alone can mistake a failed execution with an empty error for a success.

Unlike direct composio.tools.execute() results, session results have no top-level successful field. A successful field inside data belongs to the tool-specific payload and is not guaranteed. Don't use result.data.successful as a general session success check.

If you pass a custom TypeScript ToolCallSession to a provider, its execute() method must return resultType; providers use it to determine successful.

Handling requests for user input

A session tool can request user input, such as an approval, before it runs. In Python, catch ToolInputRequiredError from composio.exceptions. In TypeScript, catch ComposioToolInputRequiredError from @composio/core. The error carries the questions on input_requests / inputRequests and opaque continuation state on request_state / requestState.

This also applies to provider-wrapped session tools, session.proxy_execute() / session.proxyExecute(), and the session execution helpers passed to local tools. Present the questions to your user rather than treating the error as an empty tool result.

An input-required call has not executed and is not retried. To resume session.execute() or session.executeMeta() in TypeScript, repeat the call with inputResponses and requestState. In Python, repeat session.execute() or session.execute_meta() with input_responses and request_state. Wait for the person's answers and forward decline and cancel responses unchanged. Keep the continuation state unchanged; it is excluded from logs and serialized error output, so read it directly from the error object.

The TypeScript Google and Cloudflare providers also accept executeToolCall(session, toolCall). Pass the Session that produced the tools to preserve its execution settings. Passing a user ID uses direct execution.

executeMeta() / execute_meta()

Run a COMPOSIO_* meta tool directly from your session with a slug and optional arguments:

from composio import Composio

composio = Composio(api_key="your_api_key")
session = composio.create(user_id="user_123")
result = session.execute_meta(
    "COMPOSIO_SEARCH_TOOLS",
    arguments={"queries": [{"use_case": "send an email"}]},
)
print(result.data, result.result_type)

The exported ToolRouterSessionMetaToolSlug type lists the accepted slugs. The response includes resultType (result_type in Python). If execution needs input, such as approval, the SDK raises ComposioToolInputRequiredError (ToolInputRequiredError in Python). Calls are sent once without retries, so retry only when the operation is safe to repeat.

In TypeScript, the third argument holds input-response options: session.executeMeta(slug, args, { inputResponses, requestState }). Request options belong in the fourth argument. To pass only request options, use session.executeMeta(slug, args, undefined, requestOptions).

COMPOSIO_MULTI_EXECUTE_TOOL calls through this method run on the backend. Local tools named in those calls are not executed in your process.

For framework examples, see OpenAI or Vercel AI SDK. To connect over MCP, see Using sessions via MCP.