> ## Documentation Index
> Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to external agents

## External Agents

External agents are built outside watsonx Orchestrate and can be used as collaborators for native agents.

watsonx Orchestrate supports multiple provider protocols, including [external\_chat](#external-chat-chat-completions-api), the [Agent-to-Agent Protocol (A2A)](#agent-to-agent-a2a-protocol), and specialized communication protocols for integrating with [watsonx AI Agent Builder](#watsonx-ai-agent-builder) agents, [watsonx Assistants](#external-watsonx-assistants), and [Salesforce Agent Force](#salesforce-agentforce) agents.

`external_chat` and `A2A` agents can be built on any underlying agent platform such as BeeAI, Langgraph, and CrewAI, where the user hosts the agent themselves, on Code Engine.

### Providers

#### External Chat (Chat Completions API)

The `external_chat` provider can be used to integrate with any agent that is capable of providing an OpenAI style chat completions endpoint and is the most common form of integration.

The documentation for this API spec can be found on the [watsonx-orchestrate-developer-toolkit](https://github.com/watson-developer-cloud/watsonx-orchestrate-developer-toolkit/tree/main/external_agent).

A reference Langgraph external agent can be found [here](https://github.com/watson-developer-cloud/watsonx-orchestrate-developer-toolkit/tree/main/external_agent/examples/langgraph_python).

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external 
name: news_agent
title: News Agent
nickname: news_agent 
provider: external_chat
description: |
  An agent built in langchain which searches the news.
tags:
  - test
api_url: "https://someurl.com"   # the url of the external agent
auth_scheme: BEARER_TOKEN        # one of BEARER_TOKEN | API_KEY | NONE 
auth_config:
  token: "123"                   # this is token for both BEARER_TOKEN and API_KEY 
chat_params:                     # chat_parms are parameters sent to an agent on each request
  stream: true                  # should the external agent be invoked using using SSE streaming or as a rest call 
config:                          # config represents the internal configuration of this agent used by wxo
  hidden: false                  # Hide this collaborator agent from the ui
  enable_cot: true               # Does the external agent return all internal steps and tool calls
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "kind": "external",
  "name": "news_agent",
  "title": "News Agent",
  "nickname": "news_agent",
  "provider": "external_chat",
  "description": "An agent built in langchain which searches the news.\n",
  "tags": [
    "test"
  ],
  "api_url": "https://someurl.com",
  "auth_scheme": "BEARER_TOKEN",
  "auth_config": {
    "token": "123"
  },
  "chat_params": {
    "stream": true
  },
  "config": {
    "hidden": false,
    "enable_cot": true
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, ExternalAgent, AgentKind, AgentProvider, ExternalAgentAuthScheme

my_agent = ExternalAgent(
    kind=AgentKind.EXTERNAL,
    name="news_agent",
    title="News Agent",
    nickname="news_agent",
    provider=AgentProvider.EXT_CHAT,
    description="An agent built in langchain which searches the news.\n",
    tags=['test'],
    api_url="https://someurl.com",
    auth_scheme=ExternalAgentAuthScheme.BEARER_TOKEN,
    auth_config={
        "token": "123"
    },
    chat_params={
        "stream": True
    },
    config={
        "hidden": False,
        "enable_cot": True
    }
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

#### Agent to Agent (A2A) Protocol

The [Agent to Agent Protocol (A2A)](https://github.com/a2aproject/A2A) is an open standard designed to enable communication and interoperability between multiple agentic systems. Because the standard evolves rapidly, watsonx Orchestrate specifies the A2A version in the provider field to ensure compatibility when communicating with agents.

The supported versions are 0.3.0 and 1.0.0. Earlier versions, such as 0.2.1, are deprecated and will be removed in a future release. To ensure continued support, use version 0.3.0 or later when registering A2A-compatible agents.

| Protocol version | `provider` value |
| - | - |
| 0.3.0 | `external_chat/A2A/0.3.0` |
| 1.0.0 | `external_chat/A2A/1.0.0` |

For a sample LangGraph agent compatible with the A2A protocol, see the [a2a-samples repository](https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents/langgraph).

To register an agent that is compatible with the A2A protocol, set `provider` to the value for the protocol version that the agent implements. The following example uses `external_chat/A2A/0.3.0`. For an agent that implements version 1.0.0, set `provider` to `external_chat/A2A/1.0.0`.

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external 
name: news_agent
title: News Agent
nickname: news_agent 
provider: external_chat/A2A/0.3.0 # this is the identifier for A2A agents, provider/protocol/version of A2A supported
description: |
  An agent built in langchain which searches the news.
tags:
  - test
api_url: "https://someurl.com"   # the url of the external agent
auth_scheme: BEARER_TOKEN        # one of BEARER_TOKEN | API_KEY | NONE 
auth_config:
  token: "123"                   # this is token for both BEARER_TOKEN and API_KEY 
chat_params:                     # chat_parms are parameters sent to an agent on each request
  sendHistory:                   # indicates whether conversation history should be sent to the external A2A agent
  stream: false                  # should the external agent be invoked using using SSE streaming or as a rest call
  pushNotifications: true        # set to true if the external agent can send push notifications to provide updates on async tasks
config:                          # config represents the internal configuration of this agent used by wxo
  hidden: false                  # Hide this collaborator agent from the ui
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "kind": "external",
  "name": "news_agent",
  "title": "News Agent",
  "nickname": "news_agent",
  "provider": "external_chat/A2A/0.2.0",
  "description": "An agent built in langchain which searches the news.",
  "tags": ["test"],
  "api_url": "https://someurl.com",
  "auth_scheme": "BEARER_TOKEN",
  "auth_config": {
    "token": "123"
  },
  "chat_params": {
    "stream": true,
    "pushNotifications": true
  },
  "config": {
    "hidden": false
  }
}
```

**Running A2A agents on behalf of a user**

By default, watsonx Orchestrate calls an external A2A agent using its own service identity. When the A2A agent needs to act *on behalf of the end user* — for example, to call downstream enterprise systems (such as Concur or ServiceNow) using the user's identity — you can forward a user-scoped token to the A2A agent by setting `app_id` in the agent YAML definition to the name of a connection that issues a user-scoped token.

This mechanism works with any connection type that produces a user-scoped token, including:

* **[RFC 8693 OAuth 2.0 Token Exchange](https://www.rfc-editor.org/rfc/rfc8693)** (`oauth_auth_token_exchange_flow`) — watsonx Orchestrate presents the user's `sso_token` to the IdP and receives a new JWT preserving the user's identity.
* **On-Behalf-Of (OBO)** — the user's token is forwarded directly or exchanged via an OBO flow, depending on the IdP configuration.

The connection named in `app_id` must already be registered in watsonx Orchestrate before the agent is imported.

**How it works**

When `app_id` is set to a connection name, watsonx Orchestrate obtains a user-scoped token from that connection before invoking the A2A agent. The token is forwarded in the `Authorization: Bearer <token>` header of every request to the A2A agent, allowing it to call downstream services with the original user's identity rather than the platform service identity.

The full flow (shown here using RFC 8693 token exchange as an example) involves the following steps:

1. **User login** — the custom web app runs an OIDC Authorization Code + PKCE flow against the IdP. The resulting user access token is stored server-side in the session.
2. **wxO JWT minting** — the web app builds a signed RS256 JWT for watsonx Orchestrate. The user's access token is encrypted with watsonx Orchestrate's RSA public key and placed in the `user_payload.sso_token` field. This JWT is passed to the embedded chat widget as `wxOConfiguration.token`.
3. **Token exchange** — when the user sends a message that triggers the A2A agent, watsonx Orchestrate uses the configured connection to obtain a user-scoped token (for example, by presenting the `sso_token` to the IdP as the `subject_token` in an RFC 8693 request). The IdP validates the token and issues a new JWT preserving the user's identity (`sub`, `email`, group membership).
4. **A2A agent invocation** — watsonx Orchestrate places the user-scoped JWT in the `Authorization: Bearer` header and calls the A2A agent. The agent can then use this token to call downstream enterprise APIs on the user's behalf.

```mermaid theme={null}
sequenceDiagram
    autonumber
    actor User as User (Browser)
    participant WebApp as Custom Web App
    participant IdP as Identity Provider<br/>(e.g. IBM Verify)
    participant WxO as watsonx Orchestrate
    participant A2A as External A2A Agent
    participant Sys as Enterprise System

    User->>WebApp: Log in
    WebApp->>IdP: OIDC Auth Code + PKCE
    IdP-->>WebApp: access_token (user-scoped)
    WebApp-->>User: Session + wxO JWT<br/>(sso_token encrypted in user_payload)

    User->>WxO: Send message (wxO JWT)
    WxO->>IdP: RFC 8693 token exchange<br/>subject_token = sso_token
    IdP-->>WxO: Exchanged JWT (user identity preserved)

    WxO->>A2A: A2A request<br/>Authorization: Bearer <exchanged JWT>
    A2A->>Sys: Downstream API call<br/>Authorization: Bearer <exchanged JWT>
    Sys-->>A2A: Business data
    A2A-->>WxO: Result
    WxO-->>User: Agent response
```

**Registering the A2A agent**

Set `app_id` in the agent definition to the name of the connection that should provide the user-scoped token. The example below uses a connection named `verify_token_exchange` of kind `oauth_auth_token_exchange_flow`:

```yaml YAML theme={null}
spec_version: v1
kind: external
name: flights_agent
title: Flights Agent
style: react_core
nickname: flights_agent
provider: external_chat/A2A/0.3.0
description: |
  A2A Flights Agent — searches for available flights and returns user profile
  using IBM Verify token-exchange (oauth_auth_token_exchange_flow).
tags:
  - flights
  - travel
api_url: "${A2A_SERVER_URL}"
app_id: verify_token_exchange      # name of the connection that provides the user-scoped token (oauth_auth_token_exchange_flow or OBO)
chat_params:
  sendHistory: false
  stream: true
  pushNotifications: false
config:
  hidden: false
```

**Receiving and validating the token in the A2A agent**

The A2A agent receives the exchanged JWT in the `Authorization: Bearer` header. The agent should:

1. Extract the bearer token from the `Authorization` header.
2. Fetch the IdP's JWKS endpoint and verify the JWT signature (RS256).
3. Validate the `exp`, `iss`, and `aud` claims as appropriate for your environment.
4. Extract user identity and group/role membership from the JWT claims.

IBM Verify token-exchange tokens may omit the `kid` header field. If your JWT library requires a `kid` to look up the signing key, fall back to iterating all keys in the JWKS set.

Claim shapes for group membership vary across IdP configurations. Check all three locations: `groupIds[].displayName` (Verify SCIM groups), `groups[]` (flat string array), and `roles[]` (flat string array).

**Environment variables required in the A2A agent**

| Variable | Purpose |
| - | - |
| `JWKS_URI` | IdP JWKS endpoint used to verify the exchanged JWT signature (e.g. `https://<tenant>.verify.ibm.com/v1.0/endpoint/default/jwks`) |
| `JWT_ISSUER` | Expected `iss` claim in the exchanged JWT (optional; if unset, issuer check is skipped) |
| `JWT_AUDIENCE` | Expected `aud` claim (optional; if unset, audience check is skipped) |

> [!NOTE]
>
> `app_id` is supported for A2A agents only (`provider: external_chat/A2A/<version>`). It works with any connection type that produces a user-scoped token, including `oauth_auth_token_exchange_flow` (RFC 8693 token exchange) and OBO connections. The connection must be registered in your watsonx Orchestrate environment before the agent is imported.

***

**Asynchronous updates with push notifications (technical preview)**

For tasks that run for extended periods (e.g., minutes, hours, or days) or in scenarios where clients cannot maintain persistent connections—such as mobile applications or serverless functions — A2A supports asynchronous updates via push notifications. This mechanism enables the A2A Server to actively notify a client-provided webhook whenever a significant task update occurs.

If your agent supports asynchronous push notifications for long-running tasks, register this capability by setting the property:

```yaml YAML theme={null}
pushNotifications: true
```

The push notification configuration is provided to the external A2A agent in the initial message/send or message/stream request. The A2A agent must include the complete update — such as message, task, and artifact details (as applicable) — in the notification payload, along with the `corr_id` value received in the metadata of the initial request.

Push notifications use Bearer token authentication, where the token is generated from API keys as described in the [Getting Started](https://developer.ibm.com/apis/catalog/watsonorchestrate--custom-assistants/Getting+Started) guide.

**Callback URL and authentication**

The callback URL is included in the request sent to the A2A agent. To send push notifications, you must:

* Use a valid [API key](https://developer.ibm.com/apis/catalog/watsonorchestrate--custom-assistants/Getting+Started) to generate a Bearer token for authentication.
* Provide complete task update details in the notification payload, following the [A2A protocol’s task object specification](https://a2a-protocol.org/latest/specification/#61-task-object). Partial status updates are not sufficient.

> [!NOTE]
>
> WXO supports the A2A protocol only over `JSON-RPC 2.0` on HTTP. Although A2A can use multiple transport protocols, this implementation is limited to `JSON-RPC 2.0`.

***

**SSE stream lifecycle for asynchronous tool execution**

When a watsonx Orchestrate agent invokes an asynchronous tool through `message/stream`, the SSE stream may close while the task is still in the `working` state. This applies to all asynchronous tool types, including agentic workflows (Flows), OpenAPI tools, and Python tools that execute asynchronously.

This behavior is intentional and is aligned with the [A2A Protocol v0.3.0 specification](https://a2a-protocol.org/v0.3.0/specification/), which permits a server to close the stream before a task reaches a terminal state. The specification defines two mechanisms for clients to track task progress after the stream has ended:

1. **Polling** — the client polls `GET /tasks/{task_id}` until the task reaches a terminal state (`completed`, `failed`, or `canceled`).
2. **Push notifications** — the server calls a client-provided webhook URL with task updates. See [Asynchronous updates with push notifications](#asynchronous-updates-with-push-notifications-technical-preview) for details on the technical preview support in watsonx Orchestrate.

watsonx Orchestrate currently implements the **polling** mechanism. Push notification support is on the roadmap but is not yet generally available.

**What to expect during agentic workflow (Flow) execution**

When a native agent invokes an agentic workflow tool, the following sequence of SSE events is received before the stream closes:

| # | Event type | State | Notes |
| - | - | - | - |
| 1 | `task` | `submitted` | Task accepted |
| 2 | `status-update` | `working` | `final=false` — agent is running |
| 3 | `artifact-update` | — | Contains a message such as `"A new flow has started. This chat session is currently dedicated to the flow and will resume once the flow is complete."` |
| 4 | `task` | `working` | Stream closes here |

The `artifact-update` message is the platform's explicit signal that execution has handed off to the Flow engine. At that point the SSE stream has nothing more to deliver for this segment and closes normally. The task remains in `working` because the Flow is still executing asynchronously in the background.

**Recommended client design**

Design A2A clients that invoke asynchronous tools to handle SSE closure before `final=true` as a normal condition rather than an error:

1. Capture the `task_id` from the first `task` event received on the stream.
2. When the SSE stream closes, check whether the task has reached a terminal state.
3. If the task is still `working`, begin polling `GET /tasks/{task_id}` (for example, every 5–10 seconds) until the task reaches `completed`, `failed`, or `canceled`.
4. Retrieve the final result and full message history from the completed task response.

> [!NOTE]
>
> Reconnecting to the original `message/stream` endpoint is not the correct approach after the stream closes — the stream segment is intentionally closed. Use `GET /tasks/{task_id}` to retrieve task progress and the final result.
>
> For the full A2A endpoint reference, see [Agent-to-Agent (A2A) protocol endpoints](https://www.ibm.com/docs/en/watsonx/watson-orchestrate/base?topic=reference-agent-agent-a2a-protocol-endpoints).

#### Register an external agent for the control plane only

By default, you can chat directly with an external agent and expose it through channels such as webchat. To use an external agent only for cataloging, discovery metadata, and as a collaborator of a native agent, register it for the control plane only. Agents that are registered for the control plane only can't be run directly, so the following commands fail for them:

* `orchestrate channels` commands that create or modify a channel, including webchat
* `orchestrate phone` commands that attach a phone configuration

To set the option when you create an external agent, use the `--control-plane-only` flag with `orchestrate agents create`. Use `--no-control-plane-only` to turn the option off.

```bash BASH theme={null}
orchestrate agents create \
  --name news_agent \
  --kind external \
  --title "News Agent" \
  --description "An agent that searches the news." \
  --api "https://someurl.com" \
  --control-plane-only
```

You can also set the `control_plane_only` field in the `config` section of the agent specification:

```yaml YAML theme={null}
config:
  hidden: false
  control_plane_only: true
```

The `orchestrate agents discover` command also accepts `--control-plane-only` and `--no-control-plane-only`. When you don't pass either flag, agents that you discover from an A2A agent card (`--url`) or from a cloud provider (`--provider`) are registered for the control plane only. Pass `--no-control-plane-only` to register discovered agents so that they can be run directly.

To see which external agents are registered for the control plane only, run `orchestrate agents list`. The `CP Only` column shows a check mark for these agents.

#### Import external agents from a URL

Use the `orchestrate agents discover` command to retrieve and import external agents without manually defining the full agent configuration. You can discover agents in two ways:

* By using a URL that hosts an A2A agent card (`--url`). This is described in this section.
* By using a cloud provider connection (`--provider`). Supported providers are `bedrock_agent`, `azure_ai_foundry`, and `vertex_agent`. For more information, see [Discover agents from cloud providers](#discover-agents-from-cloud-providers).

Use a URL that hosts an agent card to retrieve and import an external agent. This approach removes the need to manually define the full agent configuration when the external agent already exposes its metadata.
External agents that follow the A2A protocol typically publish an agent card at a well-known endpoint. The default location is `.well-known/agent-card.json`. The discovery command uses this endpoint unless a custom endpoint is provided.
After the agent is discovered, the configuration is retrieved and the agent can be exported and saved locally. The exported agent can then be imported and used like other external agents.

##### Discover an agent by using the default endpoint

```bash BASH theme={null}
orchestrate agents discover -u https://example.com
```

##### Discover an agent by using a custom endpoint

Use a custom endpoint when the agent card is not located at the default path.

```bash BASH theme={null}
orchestrate agents discover -u https://example.com -e .well-known/agent-card-2.json
```

##### Discover an agent by using a connection for authentication

Some external agents require authentication. Provide a connection to retrieve the agent configuration.

```bash BASH theme={null}
orchestrate agents discover -u https://example.com -a my-a2a-connection
```

##### Discover an agent by using a custom name

Override the agent name defined in the agent card.

```bash BASH theme={null}
orchestrate agents discover -u https://example.com -n my_custom_agent -a my-a2a-connection
```

#### Command behavior

* Retrieves agent configuration from a URL that hosts an agent card.
* Uses .well-known/agent-card.json as the default endpoint.
* Supports custom endpoints for environments that expose multiple agents or non-standard paths.
* Supports authenticated access through a configured connection.
* Allows overriding the agent name during discovery.
* Enables exporting the discovered agent for local use and later import into an environment.

#### Discover agents from cloud providers

Use the `--provider` flag to discover agents that are hosted on a cloud provider and register them in watsonx Orchestrate. The command uses the credentials stored in a [connection](https://developer.watson-orchestrate.ibm.com/connections/build_connections.md) to list the agents available to you, and then registers the agents that you select as external agents.

```bash BASH theme={null}
orchestrate agents discover \
  --provider <bedrock_agent | azure_ai_foundry | vertex_agent> \
  --app-id <connection-name> \
  [--name <agent-name>] \
  [--yes]
```

| Flag | Description |
| - | - |
| `--provider` | The cloud provider to discover agents from. Supported values: `bedrock_agent`, `azure_ai_foundry`, `vertex_agent`. |
| `--app-id`, `-a` | The `app_id` of the connection that holds the provider credentials. |
| `--name`, `-n` | Only register discovered agents whose display name matches this value. Repeat the flag to select multiple agents. For more information, see [Filter discovered agents by name](#filter-discovered-agents-by-name). |
| `--yes`, `-y` | Skip the confirmation prompt and register all discovered agents. Use this flag for non-interactive and CI/CD usage. Supported for the `bedrock_agent` and `vertex_agent` providers. |
| `--control-plane-only` / `--no-control-plane-only` | Register the discovered agents for the control plane only. When you omit the flag, discovered agents are registered for the control plane only. For more information, see [Register an external agent for the control plane only](#register-an-external-agent-for-the-control-plane-only). |

> [!NOTE]
>
> Create and configure the connection before you run the discovery command. For more information, see [Build connections](https://developer.watson-orchestrate.ibm.com/connections/build_connections.md).

##### Filter discovered agents by name

The `--name` flag is repeatable. Matching is case-insensitive and is performed against the display name of the agent in the provider. If a `--name` value does not match any discovered agent, the CLI displays a warning for that value.

```bash BASH theme={null}
orchestrate agents discover \
  --provider bedrock_agent \
  --app-id my-bedrock-conn \
  --name "Customer Support" \
  --name "Sales Assistant"
```

##### Agent names in watsonx Orchestrate

Discovered agent names are converted to watsonx Orchestrate-compatible names by applying the following rules:

* The name is converted to lowercase.
* Spaces and hyphens are replaced with underscores.
* Any character that is not `a-z`, `0-9`, or `_` is replaced with an underscore.
* The name is truncated to 64 characters.
* If the result is empty, a fallback name is used: `bedrock_agent_<id>` for AWS Bedrock, `azure_agent_<id>` for Microsoft Azure AI Foundry, and `vertex_agent_<last-segment-of-resource-path>` for Google Vertex.

For example, the agent `Customer Support-Bot` is registered as `customer_support_bot`.

##### Discover AWS Bedrock agents

Discover agents from Amazon Bedrock and register them in your watsonx Orchestrate workspace.

**Prerequisites**

Install the ADK with the `aws` extra. Discovery uses AWS Signature Version 4 (SigV4) signing, which requires the `botocore` package. If the package is missing, the command fails with `ImportError: The 'botocore' package is required for AWS Bedrock agent discovery`.

```bash BASH theme={null}
pip install 'ibm-watsonx-orchestrate[aws]'
```

You also need valid AWS IAM credentials that are allowed to list Bedrock agents (`bedrock:ListAgents`). The CLI signs all requests to AWS for you.

> [!NOTE]
>
> **Availability:** SaaS environments only. AWS Bedrock agent discovery is not available in Developer Edition or on-premises (CPD) environments.

**Step 1: Configure AWS Bedrock connection credentials**

Store your AWS credentials in a `key_value` connection. The connection supports the following entries:

| Entry key | Required | Description |
| - | - | - |
| `region` | Yes | The AWS region, for example `us-east-1`. |
| `access_key_id` | Yes | The AWS access key ID. |
| `secret_access_key` | Yes | The AWS secret access key. |
| `session_token` | No | The AWS STS session token. Required only when you use temporary credentials, such as an assumed role. |

```bash BASH theme={null}
# 1. Create the connection
orchestrate connections add --app-id my-bedrock-conn

# 2. Configure it as a team key_value connection in draft
orchestrate connections configure \
  --app-id my-bedrock-conn \
  --kind key_value \
  --type team \
  --environment draft

# 3. Store the credentials
orchestrate connections set-credentials \
  --app-id my-bedrock-conn \
  --environment draft \
  --entries region=us-east-1 \
  --entries access_key_id=<your-access-key-id> \
  --entries secret_access_key=<your-secret-access-key>
```

To use temporary credentials, add `--entries session_token=<your-session-token>` to the `set-credentials` command.

**Step 2: Discover and register agents**

Discover and register all agents:

```bash BASH theme={null}
orchestrate agents discover \
  --provider bedrock_agent \
  --app-id my-bedrock-conn
```

The CLI displays a table of discovered agents and prompts for confirmation before registration. To skip the prompt in scripts and CI/CD pipelines, add the `--yes` flag:

```bash BASH theme={null}
orchestrate agents discover \
  --provider bedrock_agent \
  --app-id my-bedrock-conn \
  --yes
```

Discover specific agents by name:

```bash BASH theme={null}
orchestrate agents discover \
  --provider bedrock_agent \
  --app-id my-bedrock-conn \
  --name "Customer Support"
```

**Step 3: Verify registered agents**

```bash BASH theme={null}
orchestrate agents list
```

Discovered agents appear with `provider: bedrock_agent` and can be configured as collaborators for your native agents.

##### Discover Microsoft Azure AI Foundry agents

Discover agents deployed in **Microsoft Azure AI Foundry** and register them in your watsonx Orchestrate workspace. Authentication uses a Microsoft Entra ID service principal with the OAuth 2.0 client credentials flow.

> [!NOTE]
>
> **Availability:** SaaS environments only. Azure AI Foundry discovery is not available in Developer Edition or on-premises (CPD) environments.

**Step 1: Configure Azure AI Foundry connection credentials**

Store your Microsoft Azure credentials in a `key_value` connection. The connection requires five entries:

| Entry key | Description |
| - | - |
| `tenant_id` | Microsoft Entra ID (Azure AD) tenant ID. |
| `client_id` | Service principal (app registration) client ID. |
| `client_secret` | Service principal client secret. |
| `endpoint` | Azure AI Foundry resource endpoint, for example `https://<resource-name>.services.ai.azure.com`. |
| `project_name` | Azure AI Foundry project name. |

```bash BASH theme={null}
# 1. Create the connection
orchestrate connections add --app-id azure-conn

# 2. Configure it as a team key_value connection in draft
orchestrate connections configure \
  --app-id azure-conn \
  --kind key_value \
  --type team \
  --environment draft

# 3. Store the credentials
orchestrate connections set-credentials \
  --app-id azure-conn \
  --environment draft \
  --entries tenant_id=00000000-0000-0000-0000-000000000000 \
  --entries client_id=11111111-1111-1111-1111-111111111111 \
  --entries client_secret=<your-client-secret> \
  --entries endpoint=https://my-resource.services.ai.azure.com \
  --entries project_name=my-project
```

**Step 2: Discover and register agents**

Discover and register all agents in the project:

```bash BASH theme={null}
orchestrate agents discover \
  --provider azure_ai_foundry \
  --app-id azure-conn
```

The CLI displays a table of discovered agents and prompts for confirmation before registration.

Discover specific agents by name:

```bash BASH theme={null}
orchestrate agents discover \
  --provider azure_ai_foundry \
  --app-id azure-conn \
  --name "Customer Support" \
  --name "Sales Assistant"
```

**Step 3: Verify registered agents**

```bash BASH theme={null}
orchestrate agents list
```

Discovered agents appear with `provider: azure_ai_foundry` and can be configured as collaborators for your native agents.

##### Discover Google Vertex agents

Discover agents hosted on Google Vertex and register them in your watsonx Orchestrate workspace by using the `vertex_agent` provider.

> [!NOTE]
>
> **Availability:** SaaS environments only. Google Vertex agent discovery is not available in Developer Edition or on-premises (CPD) environments.

**Step 1: Configure Google Vertex connection credentials**

Store your Google Cloud credentials in a `key_value` connection. The connection requires three entries:

| Entry key | Description |
| - | - |
| `service_account_json` | The full Google service account JSON, as a string. |
| `project_id` | The GCP project ID. |
| `location` | The GCP region, for example `us-central1`. |

```bash BASH theme={null}
# 1. Create the connection
orchestrate connections add --app-id my-vertex-conn

# 2. Configure it as a team key_value connection in draft
orchestrate connections configure \
  --app-id my-vertex-conn \
  --kind key_value \
  --type team \
  --environment draft

# 3. Store the credentials
orchestrate connections set-credentials \
  --app-id my-vertex-conn \
  --environment draft \
  --entries service_account_json='<service-account-json>' \
  --entries project_id=<your-project-id> \
  --entries location=us-central1
```

**Step 2: Discover and register agents**

```bash BASH theme={null}
orchestrate agents discover \
  --provider vertex_agent \
  --app-id my-vertex-conn
```

The CLI displays a table of discovered agents and prompts for confirmation before registration. Use the `--name` flag to select specific agents, or the `--yes` flag to skip the confirmation prompt:

```bash BASH theme={null}
orchestrate agents discover \
  --provider vertex_agent \
  --app-id my-vertex-conn \
  --name "Customer Support" \
  --yes
```

**Step 3: Verify registered agents**

```bash BASH theme={null}
orchestrate agents list
```

Discovered agents appear with `provider: vertex_agent` and can be configured as collaborators for your native agents.

#### watsonx AI Agent Builder

You can also integrate with agents built using watsonx.ai's [agent builder platform](https://www.ibm.com/products/watsonx-ai/ai-agent-development).

For more information, see [Registering agents from watsonx.ai](https://www.ibm.com/docs/en/watsonx/watson-orchestrate/current?topic=agent-managing-agents-in-ai-chat#registering-agents-from-watsonxai).
Instead of using the API, complete the following YAML file and import your agent.

Provide well-crafted descriptions for your agents. These descriptions are used by supervisor agents to determine how to route user requests. For more information, see [Writing descriptions for agents](https://developer.watson-orchestrate.ibm.com/agents/descriptions.md#writing-descriptions-for-agents).

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external 
name: news_agent
title: News Agent
    provider: wx.ai                  # the provider will always be wx.ai
description: | 
  An agent built in langchain which searches the news.
tags:
  - test
api_url: "https://us-south.ml.cloud.ibm.com/ml/v4/deployments/<id>/ai_service_stream?version=2021-05-01"
auth_scheme: API_KEY             # this will always be API_KEY         
auth_config:
  token: "<my_api_key>"          # this is the API key for wx.ai  
chat_params:
  stream: true                   # should the external agent be invoked using using SSE streaming or as a rest call 
config:
  hidden: false                  # Hide this collaborator agent from the ui
  enable_cot: true               # Does the external agent return all internal steps and tool calls
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "kind": "external",
  "name": "news_agent",
  "title": "News Agent",
  "provider": "wx.ai",
  "description": "An agent built in langchain which searches the news.\n",
  "tags": [
    "test"
  ],
  "api_url": "https://us-south.ml.cloud.ibm.com/ml/v4/deployments/<id>/ai_service_stream?version=2021-05-01",
  "auth_scheme": "API_KEY",
  "auth_config": {
    "token": "my-api-key"
  },
  "chat_params": {
    "stream": true
  },
  "config": {
    "hidden": false,
    "enable_cot": true
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, ExternalAgent, AgentKind, AgentProvider, ExternalAgentAuthScheme

my_agent = ExternalAgent(
    kind=AgentKind.EXTERNAL,
    name="news_agent",
    title="News Agent",
    nickname="news_agent",
    provider=AgentProvider.WATSONX,                         # the provider will always be AgentProvider.WATSONX 
    description="An agent built in langchain which searches the news.\n",
    tags=['test'],
    api_url="https://us-south.ml.cloud.ibm.com/ml/v4/deployments/<id>/ai_service_stream?version=2021-05-01",
    auth_scheme=ExternalAgentAuthScheme.API_KEY,            # the auth_schema will always be ExternalAgentAuthScheme.API_KEY
    auth_config={
        "token": "my-api-key"
    },
    chat_params={
        "stream": True                                      # should the external agent be invoked using using SSE streaming or as a rest call
    },
    config={
        "hidden": False,
        "enable_cot": True
    }
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

#### Salesforce AgentForce

To register an agent that is built within Salesforce Agent Force as an external agent:

1. Follow the **Getting Started Guide** for the Agent API. For more information, see the [Getting Started Guide](https://developer.salesforce.com/docs/einstein/genai/guide/agent-api-get-started.html).

![getting-started-salesforce.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/salesforce/getting-started-salesforce.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=980fee13e9d1867838a8e2e146dda862)

1. On the **Create a token** page, the following information applies to all Salesforce agents within the instance:

   * **`api_url`**: Always set to `https://api.salesforce.com/einstein/ai-agent/v1`.
   * **`auth_config.token`**: Use the `CONSUMER_SECRET` provided in the guide.
   * **`chat_params`**:
     * **`client_id`**: Use the `CONSUMER_KEY`.
     * **`domain_url`**: Use the `DOMAIN_URL`.
     * Optionally, specify a list of display types to pass to Orchestrate as a comma-separated string.

2. Provide well-crafted descriptions for your agents. These descriptions are used by supervisor agents to determine how to route user requests. For more information, see [Writing descriptions for agents](https://developer.watson-orchestrate.ibm.com/agents/descriptions.md#writing-descriptions-for-agents).

3. Lastly, under `chat_params` you need to specify your `agent_id`. This can be found by hovering over one of your agents and either right-clicking and copying the URL, or by manually writing it based on hover text. In the following example, the agent\_id is `0XxfJ0000001d8zSAA`.

![agent-selection-salesforce.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/salesforce/agent-selection-salesforce.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=498acc84189f5f399d3daf32bb871055)

```yaml YAML [expandable] theme={null}
name: salesforce_ext_agent 
kind: external 
provider: salesforce                            # the provider will always be salesforce
title: Customer Service Agent by Salesforce
tags:
- "salesforce" 
description: An AI customer service agent whose job is to help customers with support questions or other issues. 
api_url: "https://api.salesforce.com/einstein/ai-agent/v1"
auth_scheme: API_KEY
auth_config:
  token: "my-api-key"
chat_params:
  agent_id: "my-agent-id"
  client_id: "my-client-id"
  domain_url: "https://agentforceXXX-dev-ed.develop.my.salesforce.com"
  # display_types: TextChunk,Confirm,Error,Failure,Inquire,Inform
config:
  hidden: false
  enable_cot: false
```

```json JSON [expandable] theme={null}
{
  "name": "salesforce_ext_agent",
  "kind": "external",
  "provider": "salesforce",
  "title": "Customer Service Agent by Salesforce",
  "tags": [
    "salesforce"
  ],
  "description": "An AI customer service agent whose job is to help customers with support questions or other issues.",
  "api_url": "https://api.salesforce.com/einstein/ai-agent/v1",
  "auth_scheme": "API_KEY",
  "auth_config": {
    "token": "my-api-key"
  },
  "chat_params": {
    "agent_id": "my-agent-id",
    "client_id": "my-client-id",
    "domain_url": "https://agentforceXXX-dev-ed.develop.my.salesforce.com"
  },
  "config": {
    "hidden": false,
    "enable_cot": false
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, ExternalAgent, AgentKind, AgentProvider, ExternalAgentAuthScheme

my_agent = ExternalAgent(
    name="salesforce_ext_agent",
    kind=AgentKind.EXTERNAL,
    provider=AgentProvider.SALESFORCE,                         # the provider will always be AgentProvider.SALESFORCE 
    title="Customer Service Agent by Salesforce",
    description="An AI customer service agent whose job is to help customers with support questions or other issues.",
    tags=['salesforce'],
    api_url="https://api.salesforce.com/einstein/ai-agent/v1",
    auth_scheme=ExternalAgentAuthScheme.API_KEY,            # the auth_schema will always be ExternalAgentAuthScheme.API_KEY
    auth_config={
        "token": "my-api-key"
    },
    chat_params={
        "agent_id": "my-agent-id",
        "client_id": "my-client-id",
        "domain_url": "https://agentforceXXX-dev-ed.develop.my.salesforce.com"
    },
    config={
        "hidden": False,
        "enable_cot": True
    }
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

### Microsoft Copilot Studio

You can integrate Microsoft Copilot Studio agents as external agents in watsonx Orchestrate using the Direct Line API. This integration allows you to leverage your existing Copilot Studio agents within the watsonx Orchestrate platform.

#### Prerequisites

Before you begin, ensure you have:

1. A Microsoft Copilot Studio agent configured and published
2. Access to the agent's Web channel security settings
3. The bot secret from your Copilot Studio agent

#### Configuration steps

1. In Microsoft Copilot Studio, navigate to your agent settings and select **No authentication** under agent settings.

   ![No authentication setting](https://mintlify.s3.us-west-1.amazonaws.com/ibm-2e3153bf/assets/salesforce/msftstudio-no-auth.png)

2. Obtain your bot secret from **Security → Web channel security** in the Copilot Studio interface.

   ![Web channel security](https://mintlify.s3.us-west-1.amazonaws.com/ibm-2e3153bf/assets/salesforce/msftstudio-security.png)

3. Configure your external agent YAML file with the following parameters:

   * **`provider`**: Always set to `microsoft_copilot_studio`.
   * **`api_url`**: The Direct Line API endpoint. For most users, this is `https://directline.botframework.com/v3/directline`. This may vary slightly based on your region.
   * **`auth_scheme`**: Set to `NONE` since authentication is handled through the bot secret.
   * **`auth_config.bot_secret`**: The bot secret obtained from Web channel security settings.
   * **`chat_params.token_endpoint`**: The token generation endpoint. For most users, this is `https://directline.botframework.com/v3/directline/tokens/generate`. This may vary slightly based on your region.

4. Provide well-crafted descriptions for your agents. These descriptions are used by supervisor agents to determine how to route user requests. For more information, see [Writing descriptions for agents](https://developer.watson-orchestrate.ibm.com/agents/descriptions.md#writing-descriptions-for-agents).

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external
name: copilot_studio_agent
title: Copilot Studio Agent
provider: microsoft_copilot_studio
description: |
  A Microsoft Copilot Studio agent exposed through Direct Line.

api_url: https://directline.botframework.com/v3/directline
auth_scheme: NONE

auth_config:
  bot_secret: <your-bot-secret>

chat_params:
  token_endpoint: https://directline.botframework.com/v3/directline/tokens/generate
  # timeout_seconds: 180
  # poll_interval: 0.5
  # stream_chunk_size: 40
  can_collaborate: false

config:
  hidden: false
  enable_cot: false
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "kind": "external",
  "name": "copilot_studio_agent",
  "title": "Copilot Studio Agent",
  "provider": "microsoft_copilot_studio",
  "description": "A Microsoft Copilot Studio agent exposed through Direct Line.\n",
  "api_url": "https://directline.botframework.com/v3/directline",
  "auth_scheme": "NONE",
  "auth_config": {
    "bot_secret": "<your-bot-secret>"
  },
  "chat_params": {
    "token_endpoint": "https://directline.botframework.com/v3/directline/tokens/generate",
    "can_collaborate": false
  },
  "config": {
    "hidden": false,
    "enable_cot": false
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, ExternalAgent, AgentKind, AgentProvider, ExternalAgentAuthScheme

my_agent = ExternalAgent(
    name="copilot_studio_agent",
    kind=AgentKind.EXTERNAL,
    provider=AgentProvider.MICROSOFT_COPILOT_STUDIO,
    title="Copilot Studio Agent",
    description="A Microsoft Copilot Studio agent exposed through Direct Line.",
    api_url="https://directline.botframework.com/v3/directline",
    auth_scheme=ExternalAgentAuthScheme.NONE,
    auth_config={
        "bot_secret": "<your-bot-secret>"
    },
    chat_params={
        "token_endpoint": "https://directline.botframework.com/v3/directline/tokens/generate",
        "can_collaborate": False
    },
    config={
        "hidden": False,
        "enable_cot": False
    }
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

> [!NOTE]
>
> For more information about the Microsoft Direct Line API, see [Configure web channel security](https://learn.microsoft.com/en-us/microsoft-copilot-studio/configure-web-security).

#### LangGraph agent

You can import LangGraph agents directly into watsonx Orchestrate. During the upload process, Orchestrate applies the Agent to Agent protocol behind the scenes to make the agent compatible with the platform. You use the same streamlined experience that you use for Python agents or MCP agents. A2A‑enabled LangGraph agents support lifecycle tasks such as update, delete, and export.

For a detailed description of how to import LangGraph agents, see [Importing LangGraph agents](https://www.ibm.com/docs/en/watsonx/watson-orchestrate/base?topic=agents-importing-langgraph).

**Limitations:**

* Supported for Python implementations only.
* Agents that are run inside the watsonx Orchestrate environment with the required isolation.
* Supports only `messages` in the agent graph between turns, so complex custom state objects get lost between turns.

**Example:**

```python PYTHON [expandable] theme={null}
"""
Simple Agent: No LLM - Hello World
A simple agent that returns a static "Hello World" message without using any LLM.
"""
from typing import Annotated, List, TypedDict
from langchain_core.messages import AIMessage, BaseMessage
from langchain_core.runnables.config import RunnableConfig
from langgraph.graph import StateGraph, START, END


class AgentState(TypedDict):
    """Simple state with just messages."""
    messages: Annotated[List[BaseMessage], "conversation history"]


def hello_world_node(state: AgentState) -> AgentState:
    """
    Node that returns a static Hello World message.
    No LLM involved - just returns a hardcoded response.
    """
    # Get the last user message if available
    user_message = ""
    if state["messages"]:
        user_message = state["messages"][-1].content
    
    # Create a simple response
    response = AIMessage(
        content=f"Hello World! I received your message: '{user_message}'. "
                f"I'm a simple test agent with no LLM - I just return this static message."
    )
    
    return {"messages": state["messages"] + [response]}


def create_agent(config: RunnableConfig) -> StateGraph:
    """
    Factory function that creates and returns a LangGraph StateGraph.
    This agent has no LLM and just returns a static message.
    
    Args:
        config: Runtime configuration (not used in this simple agent)
    
    Returns:
        StateGraph: The compiled agent graph
    """
    # Build a simple linear graph: START -> hello_world -> END
    workflow = StateGraph(AgentState)
    workflow.add_node("hello_world", hello_world_node)
    workflow.add_edge(START, "hello_world")
    workflow.add_edge("hello_world", END)
    
    return workflow


if __name__ == "__main__":
    # Test the agent locally
    from langchain_core.messages import HumanMessage
    
    app = create_agent({}).compile()
    
    # Test 1: Simple message
    result = app.invoke({"messages": [HumanMessage(content="Hi there!")]})
    print("Test 1 - Simple message:")
    print(result["messages"][-1].content)
    print()
    
    # Test 2: Different message
    result = app.invoke({"messages": [HumanMessage(content="What can you do?")]})
    print("Test 2 - Different message:")
    print(result["messages"][-1].content)
```

> [!NOTE]
>
> This capability is supported through the A2A protocol.

##### Configuring checkpointers

Checkpointers persist agent state so you can resume execution and maintain context.

Choose the checkpointer that fits your environment and persistence needs, then add its configuration to the checkpointer section of the agent YAML file.

> [tab] Memory (development or testing)
>
> Use in-memory storage to persist state during execution. State resets when the process restarts.
>
> ```yml YAML theme={null}
> checkpointer:
>   type: memory
> ```
>
> **Example:**
>
> ```yaml theme={null}
> spec_version: v1
> kind: agent
> name: my-agent
> title: My LangGraph Agent
> description: Agent with PostgreSQL state persistence
> framework: langgraph
>
> deployment:
>   code_bundle:
>     entrypoint: "main:create_graph"
>
> checkpointer:
>   type: memory
> ```

> [tab] SQLite
>
> Use a local SQLite file to persist state. State resets when the agent pod restarts.
>
> ```yml YAML theme={null}
> checkpointer:
>   type: sqlite
> ```
>
> **Requirements:**
>
> * Add `langgraph-checkpoint-sqlite` to the agent `requirements.txt` file.
>
> **Example:**
>
> ```yaml theme={null}
> spec_version: v1
> kind: agent
> name: my-agent
> title: My LangGraph Agent
> description: Agent with PostgreSQL state persistence
> framework: langgraph
>
> deployment:
>   code_bundle:
>     entrypoint: "main:create_graph"
>
> checkpointer:
>   type: sqlite
> ```

> [tab] PostgreSQL (production)
>
> Use PostgreSQL to persist state across restarts and deployments.
>
> ```yml YAML theme={null}
> checkpointer:
>   type: postgres
>   connection_string_key: db_connection_string
> ```
>
> **Requirements:**
>
> * Add `langgraph-checkpoint-postgres` to the agent `requirements.txt` file.
> * Add the PostgreSQL connection to the file.
>
> **Example:**
>
> ```yaml theme={null}
> spec_version: v1
> kind: agent
> name: my-agent
> title: My LangGraph Agent
> description: Agent with PostgreSQL state persistence
> framework: langgraph
>
> deployment:
>   code_bundle:
>     entrypoint: "main:create_graph"
>
> checkpointer:
>   type: postgres
>   connection_string_key: db_connection_string
> ```

> [tab] No checkpointer (stateless)
>
> Exclude the `checkpointer` section to run the agent without state persistence.

> [!NOTE]
>
> **Notes:**
>
> * The `connection_string_key` maps to a credential entry that stores the database connection string. Choose API key as the connection type and enter the connection string as the value.
> * For SQLite and PostgreSQL, the system manages database connections and schema setup automatically.
> * The memory checkpointer requires no credentials or additional configuration.

## External watsonx Assistants

To register assistants from watsonx Assistant, you must obtain the following information:

* `service_instance_url`
* `api_key`
* `assistant_id`
* `environment_id`

> [!NOTE]
>
> **Note:** The location of the `service_instance_url` and `api_key` varies depending on whether the assistant is imported to IBM Cloud or AWS.

To retrieve your assistant ID:

1. Navigate to the settings on the actions page and open the settings.

![actions\_page.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/assistant/actions-page.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=130b799824d666fed7e27bffa34fa816)

1. On the farthest right tab, select Upload/Download, and click the **Download** button.

![actions-page.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/assistant/settings.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=9d894aa38a01aeaf05786e6b0a1759a1)

1. Locate your `environment_id` and `assistant_id` in the output JSON.

![environment-id.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/assistant/environment-id.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=e603992aa0b27ba0e6d77920e9a36b3d)

#### IBM Cloud

On IBM Cloud, your `service_instance_url` and `api_key` can be found on the page where you launch your assistant's tooling UI.

![ibmcloud-service-keys.png](https://mintcdn.com/ibm-2e3153bf/CUC4--rm2jCi7sPV/assets/assistant/ibmcloud-service-keys.png?fit=max\&auto=format\&n=CUC4--rm2jCi7sPV\&q=85\&s=ac0c40eb87883ade326e1b8e81cbecec)

Provide well-crafted descriptions for your agents. These descriptions are used by supervisor agents to determine how to route user requests. For more information, see [Writing descriptions for agents](https://developer.watson-orchestrate.ibm.com/agents/descriptions.md#writing-descriptions-for-agents).

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: assistant
name: hr_assistant
title: HR Agent
description: |
  This assistant is capable of acting as a first point of contact for all support requests.
tags:
- wxa
config:
  assistant_id: assistantid
  environment_id: environmentid
  hidden: false
  api_key: my-api-key
  service_instance_url: https://api.eu-de.assistant.watson.cloud.ibm.com/instances/<my-instance-id>
  api_version: '2023-06-15T00:00:00.000Z'
  auth_type: IBM_CLOUD_IAM
  authorization_url: https://iam.cloud.ibm.com
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "kind": "assistant",
  "name": "hr_assistant",
  "title": "HR Agent",
  "description": "This assistant is capable of acting as a first point of contact for all support requests.\n",
  "tags": [
    "wxa"
  ],
  "config": {
    "assistant_id": "assistantid",
    "environment_id": "environmentid",
    "hidden": false,
    "api_key": "my-api-key",
    "service_instance_url": "https://api.eu-de.assistant.watson.cloud.ibm.com/instances/<my-instance-id>",
    "api_version": "2023-06-15T00:00:00.000Z",
    "auth_type": "IBM_CLOUD_IAM",
    "authorization_url": "https://iam.cloud.ibm.com"
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, AssistantAgent, AssistantAgentConfig, AgentKind
from ibm_watsonx_orchestrate.agent_builder.agents.types import AssistantAgentAuthType

my_agent = AssistantAgent(
    name="hr_assistant",
    kind=AgentKind.ASSISTANT,
    title="HR Agent",
    description="This assistant is capable of acting as a first point of contact for all support requests.\n",
    tags=['wxa'],
    config=AssistantAgentConfig(
        assistant_id="assistantid",
        environment_id="environmentid",
        hidden=False,
        api_key="my-api-key",
        service_instance_url="https://api.eu-de.assistant.watson.cloud.ibm.com/instances/<my-instance-id>",
        api_version="2023-06-15T00:00:00.000Z",
        auth_type=AssistantAgentAuthType.IBM_CLOUD_IAM,
        authorization_url="https://iam.cloud.ibm.com"
    )
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

#### AWS

Provide well-crafted descriptions for your agents. These descriptions are used by supervisor agents to determine how to route user requests. For more information, see [Writing descriptions for agents](https://developer.watson-orchestrate.ibm.com/agents/descriptions.md#writing-descriptions-for-agents).

```yaml YAML [expandable] theme={null}
spec_version: v1
name: my_assistant
title: my_assistant
description: |
  This assistant is capable of handling call center operations.
kind: assistant
tags:
- wxa
config:
  assistant_id: assistantid
  environment_id: environmentid
  hidden: false
  api_key: my-api-key
  service_instance_url: https://api.us-east-1.preprod.aws.watsonassistant.ibm.com/instances/<my-instance-id>
  api_version: '2023-06-15'
  auth_type: MCSP
  authorization_url: https://account-iam.platform.saas.ibm.com
```

```json JSON [expandable] theme={null}
{
  "spec_version": "v1",
  "name": "my_assistant",
  "title": "my_assistant",
  "description": "This assistant is capable of handling call center operations.\n",
  "kind": "assistant",
  "tags": [
    "wxa"
  ],
  "config": {
    "assistant_id": "assistantid",
    "environment_id": "environmentid",
    "hidden": false,
    "api_key": "my-api-key",
    "service_instance_url": "https://api.us-east-1.preprod.aws.watsonassistant.ibm.com/instances/<my-instance-id>",
    "api_version": "2023-06-15",
    "auth_type": "MCSP",
    "authorization_url": "https://account-iam.platform.saas.ibm.com"
  }
}
```

```python Python [expandable] theme={null}
from ibm_watsonx_orchestrate.agent_builder.agents import Agent, AssistantAgent, AssistantAgentConfig, AgentKind
from ibm_watsonx_orchestrate.agent_builder.agents.types import AssistantAgentAuthType

my_agent = AssistantAgent(
    name="hr_assistant",
    kind=AgentKind.ASSISTANT,
    title="HR Agent",
    description="This assistant is capable of acting as a first point of contact for all support requests.\n",
    tags=['wxa'],
    config=AssistantAgentConfig(
        assistant_id="assistantid",
        environment_id="environmentid",
        hidden=False,
        api_key="my-api-key",
        service_instance_url="https://api.us-east-1.preprod.aws.watsonassistant.ibm.com/instances/<my-instance-id>",
        api_version="2023-06-15T00:00:00.000Z",
        auth_type=AssistantAgentAuthType.MCSP,
        authorization_url="https://account-iam.platform.saas.ibm.com"
    )
)

# External Agents can only be used as a collaborator of a native agent as shown below
native_agent = Agent(
    # omitted for brevity
    collaborators=[my_agent]
)
```

## Additional features of external agents

### Providing access to context variables

Context variables enable builders to incorporate user-specific identifiers—such as username, user ID, or tenant ID—from upstream systems into an agent. For a full explanation of how context variables work, including delivery methods, precedence, scope, persistence strategies, and channel limitations, see [Context variables](https://developer.watson-orchestrate.ibm.com/conversation/context_variables.md).

By default, agents invoked during a run do not have access to context. To enable access, set the `context_access_enabled` field to `true` and provide a list of `context_variables` to expose to the agent.

Context variables are passed to the agent in the following ways:

* **[Runs API](https://developer.watson-orchestrate.ibm.com/apis/orchestrate-agent/chat-with-orchestrate-assistant.md)**: Use the [context](https://developer.watson-orchestrate.ibm.com/apis/orchestrate-agent/chat-with-orchestrate-assistant.md#body-context) field at the root of the request.
* **[Chat Completions API](https://developer.watson-orchestrate.ibm.com/apis/orchestrate-agent/chat-with-agents.md)**: Use the [context](https://developer.watson-orchestrate.ibm.com/apis/orchestrate-agent/chat-with-agents.md#body-context) field at the root of the request.
* **[Streaming variant](https://developer.watson-orchestrate.ibm.com/apis/orchestrate-agent/chat-with-orchestrate-assistant-as-stream.md)**: Each SSE event sent to the agent includes the context object.
* For external A2A agents, the context variables defined are accessible in the metadata of the `message` object.

> [!NOTE]
>
> ##### System and custom variables
>
> Context variables are either system variables or custom variables. System variables use the reserved `wxo_` prefix and are populated automatically by the platform on every run. Custom variables are defined and supplied by your application. For details, see [Types of context variables](https://developer.watson-orchestrate.ibm.com/conversation/context_variables.md#types-of-context-variables).
>
> ##### Naming convention for context variables
>
> Follow the standard naming rules for custom context variables. For details, see [Naming rules](https://developer.watson-orchestrate.ibm.com/conversation/context_variables.md#naming-rules).
>
> ##### Scope and persistence
>
> Context is scoped to a single run and is not persisted across turns in a thread. For details and persistence strategies, see [Persisting context across turns](https://developer.watson-orchestrate.ibm.com/conversation/context_variables.md#persisting-context-across-turns).
>
> ##### Channel support
>
> Channels might not support context-variable propagation. For details, see [Channel support](https://developer.watson-orchestrate.ibm.com/conversation/context_variables.md#channel-support).

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external
name: news_agent
title: News Agent
nickname: news_agent
provider: external_chat/A2A/0.3.0 # this is the identifier for A2A agents, provider/protocol/version of A2A supported
description: |
  An agent built in langchain which searches the news.
tags:
- test
api_url: "https://someurl.com" # the url of the external agent
auth_scheme: BEARER_TOKEN # one of BEARER_TOKEN | API_KEY | NONE
auth_config:
  token: "123" # this is token for both BEARER_TOKEN and API_KEY
chat_params:                     # chat_parms are parameters sent to an agent on each request
  sendHistory:                   # indicates whether conversation history should be sent to the external A2A agent
  stream: false                  # should the external agent be invoked using using SSE streaming or as a rest call 
config:
  hidden: false # Hide this collaborator agent from the ui
context_access_enabled: true
context_variables:
  - clientID
```

```json JSON [expandable] theme={null}
{
    "spec_version": "v1",
    "kind": "external",
    "name": "news_agent",
    "title": "News Agent",
    "nickname": "news_agent",
    "provider": "external_chat/A2A/0.3.0",
    "description": "An agent built in langchain which searches the news.\n",
    "tags": [
        "test"
    ],
    "api_url": "https://someurl.com",
    "auth_scheme": "BEARER_TOKEN",
    "auth_config": {
        "token": "123"
    },
    "chat_params": {
        "stream": true
    },
    "config": {
        "hidden": false
    },
    "context_access_enabled": true,
    "context_variables": [
        "clientID"
    ]
}
```

**detailed parameter descriptions**

**context\_access\_enabled** `object` (default: false)

Indicates whether this agent can access context variables set by the Runs API.

**context\_variables** `list\<string\>` (default: \[])

Specifies the list of context variables the agent can access.

### Restricting Agents

You can restrict external agents in watsonx Orchestrate by using the restrictions parameter in your external agent configuration.

```yaml YAML [expandable] theme={null}
spec_version: v1
kind: external
name: news_agent
title: News Agent
nickname: news_agent
provider: external_chat/A2A/0.2.0 # this is the identifier for A2A agents, provider/protocol/version of A2A supported
description: |
  An agent built in langchain which searches the news.
tags:
- test
api_url: "https://someurl.com" # the url of the external agent
auth_scheme: BEARER_TOKEN # one of BEARER_TOKEN | API_KEY | NONE
auth_config:
  token: "123" # this is token for both BEARER_TOKEN and API_KEY
chat_params:                     # chat_parms are parameters sent to an agent on each request
  sendHistory:                   # indicates whether conversation history should be sent to the external A2A agent
  stream: false                  # should the external agent be invoked using using SSE streaming or as a rest call 
config:
  hidden: false # Hide this collaborator agent from the ui
restrictions: editable
```

```json JSON [expandable] theme={null}
{
    "spec_version": "v1",
    "kind": "external",
    "name": "news_agent",
    "title": "News Agent",
    "nickname": "news_agent",
    "provider": "external_chat/A2A/0.3.0",
    "description": "An agent built in langchain which searches the news.\n",
    "tags": [
        "test"
    ],
    "api_url": "https://someurl.com",
    "auth_scheme": "BEARER_TOKEN",
    "auth_config": {
        "token": "123"
    },
    "chat_params": {
        "stream": true
    },
    "config": {
        "hidden": false
    },
    "restrictions": "editable"
}
```

**detailed parameter descriptions**

**restrictions** `string`

Specifies whether the Agent remains editable after import. This field accepts one of the following options:

* `editable`
  Sets the Agent as editable. This is the default value.
* `non_editable`
  Sets the Agent as non-editable and prevents it from being exported.
