---
title: "Connectors as Tools"
description: "An agent can call official Connector operations as tools. Each call runs one operation in its own tool Step, with the Connector's credentials and the same stable Call ID that a Connector Step gets. A Mutation derives the idempotency key it sends to the provider from that Call ID, so every attempt of the call sends the same key."
canonical_url: "https://docs.superdurable.io/build-ai-agents/connectors-as-tools/"
source: "docs/content/agent-frameworks/connectors-as-tools.mdx"
locale: "en"
framework: "claude-agent-sdk"
language: "python"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Connectors as Tools

This file shows the Claude Agent SDK version. Other frameworks: [Eino](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.eino.md) · [Google ADK](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.google-adk.md) · [LangGraph](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.langchain-langgraph.md) · [Mastra](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.mastra.md) · [OpenAI Agents SDK](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.openai-agents-sdk.md) · [Pi](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.pi.md) · [Pydantic AI](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.pydantic-ai.md) · [Vercel AI SDK](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.vercel-ai-sdk.md) · [Dex Agent Framework](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.built-in-agent-loop.md)

Code on this page is in Python. Other languages: [TypeScript](https://docs.superdurable.io/build-ai-agents/connectors-as-tools.typescript.md)

An agent can call official [Connector](https://docs.superdurable.io/concepts/connector.md) operations as tools. Each call runs one operation in its own tool Step, with the Connector's credentials and the same stable Call ID that a Connector Step gets. A Mutation derives the idempotency key it sends to the provider from that Call ID, so every attempt of the call sends the same key.

<a id="connectors-as-tools"></a>

## How it works

`ConnectorToolSource` offers the operations you name. The agent takes it as a tool source: `tool_sources` in Python, `toolSources` in TypeScript, and the `WithToolSources` option in Go. [Name the tools](https://docs.superdurable.io/reference/agents/connector-tools.md#connector-tools-offered) says which operations a manifest lets an agent use.

Dex checks the model's arguments against the operation's input schema first. A wrong or missing field fails the call before the operation runs, with a message the model can correct.

<a id="connector-tools-effects"></a>

### Effect classes

The operation's [effect class](https://docs.superdurable.io/concepts/connector.md#effect-classes) becomes the tool's effect class, and so picks the Step that runs a call:

| Operation                                                           | Effect class           | Runs in                                                                                                                                                               |
| ------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query                                                               | **read**               | `CallTool`, with retries                                                                                                                                              |
| Mutation that the manifest marks retry-safe (**agent.retry: safe**) | `idempotent_write`     | `CallTool`, with retries                                                                                                                                              |
| Mutation with bounded resends (**agent.repeatOnUnknown: limited**)  | `non_idempotent_write` | `CallSingleAttemptTool`; after an unknown outcome it can [resend](https://docs.superdurable.io/reference/agents/connector-tools.md#bounded-resends) within a send cap |
| Any other Mutation                                                  | `non_idempotent_write` | `CallSingleAttemptTool`, [one attempt](https://docs.superdurable.io/reference/agents/failures.md#tool-runs-twice) for the call                                        |

Bounded resends suit a write where a rare duplicate is acceptable, such as a chat message or an email. A session's tool policy cannot change a Connector tool's effect class; see [Step options](https://docs.superdurable.io/reference/agents/connector-tools.md#step-options).

<a id="connector-tools-approval"></a>

### Approval

A Connector tool waits for approval when its manifest recommends it (**agent.approval: recommended**), as for a refund. Other Mutations run directly by default. The application can override that per tool, or pass a predicate that decides per call from its arguments, such as refunds above a limit. A predicate that raises asks for approval. A session's tool policy wins over both; see [Step options](https://docs.superdurable.io/reference/agents/connector-tools.md#step-options).

<a id="connector-tools-outcomes"></a>

### Outcomes

The operation's branch decides the tool call's record: **succeeded**, **failed**, or `outcome_unknown` when a write may have taken effect. [Outcomes](https://docs.superdurable.io/reference/agents/connector-tools.md#outcomes) lists every branch. Reconcile `outcome_unknown` [as for any tool](https://docs.superdurable.io/reference/agents/failures.md#reconcile-outcome-unknown).

After a Worker crash, a Connector call follows [What runs again](https://docs.superdurable.io/reference/agents/failures.md#what-runs-again), and a [new call](https://docs.superdurable.io/reference/agents/failures.md#tool-runs-twice) can repeat its effect. A Mutation with bounded resends sends again only after an unknown outcome that read-back cannot settle, within a cap that counts every send. [Crashes](https://docs.superdurable.io/reference/agents/connector-tools.md#crashes) shows each case.

<a id="connector-tools-write-order"></a>

### Write order

Connector writes of one model response run one at a time, in the model's order. Reads, and calls of other tools, run in parallel. A write that needs approval asks for it only when its turn comes.

When a write fails, ends `outcome_unknown`, or is rejected, the later Connector writes of that response are skipped. Each records **failed** with **skipped** set and an error that starts "the tool did not run, so it is safe to call again". The Claude Agent SDK refuses such a write inside its segment instead; see [Connector tools: Framework adapters](https://docs.superdurable.io/reference/agents/connector-tools.md#framework-adapters).

<a id="connect-connectors"></a>

## Connect a Connector

With the Slack connection **support-slack** configured, each example agent gets the tool `slack_post_thread_reply`, which runs the Slack operation `postThreadReply` to reply in a thread. Without that connection, the examples log one line and run without the tool. Every example sets `requires_approval=True` (**requiresApproval: true** in TypeScript, `connectortools.WithRequiresApproval(true)` in Go), so every post waits for a person and then runs in `CallSingleAttemptTool`. The Go example's Slack Connector release adds bounded resends; [The Slack tool in the examples](https://docs.superdurable.io/reference/agents/connector-tools.md#slack-example) says what each example's post can repeat.

<a id="offer-connector-tools"></a>

### Offer the tool

**Python**

Install the **connectors** extra of **dex-agents** and the Connector package, such as **dex-connector-slack** ([commands](https://docs.superdurable.io/reference/agents/connector-tools.md#install)). `connector_tool` turns the operation into a tool.

```python
def build_slack_tool_sources(connection: slack.Connection | None) -> list[ToolSource]:
    """Returns the Slack tool source, or no source when Slack is not configured."""
    if connection is None:
        return []
    return [
        ConnectorToolSource([
            # The manifest does not ask for approval; this agent asks before every post.
            connector_tool(
                connection.post_thread_reply(), connection.reference, requires_approval=True
            ),
        ]),
    ]

# ...

async def open_slack_project_connection(
    environment: Mapping[str, str] = os.environ,
) -> SlackProjectConnection | None:
    # ...
    # An incomplete or invalid configuration raises here, so the Worker fails at startup.
    try:
        project = await load_from_environment(environment)
    except FileNotFoundError:
        _log_slack_not_set_up("the connector configuration file does not exist")
        return None
    # ...
    try:
        connection = slack.new_project_connection(project, SLACK_CONNECTION_NAME)
    except BaseException:
        await project.close()
        raise
    return SlackProjectConnection(project, connection)
```

Example: [examples/python/agent-harnesses/agent_harness_examples/slack_connector_tools.py](https://github.com/superdurable/dex/tree/main/examples/python/agent-harnesses/agent_harness_examples/slack_connector_tools.py)

The Worker opens the connection once, at startup, and every agent uses it:

**Python**

```python
async def main() -> None:
    config = AgentHarnessExamplesConfig.from_env()
    slack_setup = await open_slack_project_connection()
    try:
        app_state = AgentHarnessExamplesApp(config, slack_setup.connection if slack_setup else None)
        # ...
    finally:
        if slack_setup is not None:
            await slack_setup.aclose()
```

Example: [examples/python/agent-harnesses/agent_harness_examples/\_\_main\_\_.py](https://github.com/superdurable/dex/tree/main/examples/python/agent-harnesses/agent_harness_examples/__main__.py)

The agent passes the tool source next to its own tools:

**Python**

```python
    return claude_agent_session_flow(
        build_options,
        [look_up_order, cancel_order],
        flow_type=CLAUDE_AGENT_SDK_ORDER_SUPPORT_FLOW_TYPE,
        tool_sources=build_slack_tool_sources(slack_connection),
        # ...
    )
```

Example: [examples/python/agent-harnesses/agent_harness_examples/claude_agent_sdk_order_support.py](https://github.com/superdurable/dex/tree/main/examples/python/agent-harnesses/agent_harness_examples/claude_agent_sdk_order_support.py)

<a id="try-the-slack-tool"></a>

### Try the Slack tool

Start the example with `DEX_CONNECTOR_CONFIG_FILE` set; [Connections](https://docs.superdurable.io/reference/agents/connector-tools.md#connector-tools-connection) says where the Worker finds **support-slack**. Then ask the agent to reply in a Slack thread, with the channel ID and the thread timestamp:

```text
Reply in Slack thread C0123456789 1710000000.000100: Order 1002 ships on Thursday.
```

The post waits for approval, like `cancel_order`.

## Next

- [Dex Agent Framework](https://docs.superdurable.io/build-ai-agents/dex-agent-framework.md): an agent without another agent SDK.
- [Connector tools reference](https://docs.superdurable.io/reference/agents/connector-tools.md): packages, tool names, result size, connections, and how each agent SDK hands a call to its tool Step.
- [Connector Triggers](https://docs.superdurable.io/reference/agents/connector-triggers.md): start a session and send it messages from Connector events.
