Link Agents with the CLI (Early Access)

This feature is in the Early Access stage and under active development. Configuration schemas and behavior are subject to change. We recommend that you do not use this feature in production environments.

A link agent is an agent that runs outside Solace Agent Mesh and joins the mesh through an Agent Link Entrypoint, an entrypoint of type agent_link. The linkAgent kind registers one such agent: the entrypoint it connects through, the digest of its token, the agents it can call, and how Agent Mesh starts it on demand.

Deploying a link agent delivers its settings and token digest to its entrypoint. The entrypoint refuses a link agent that is not deployed, and a deployed link agent keeps the settings and token it was deployed with until the next deployment.

This page covers link agents that the Platform service manages. For more information about how an agent connects through an Agent Link Entrypoint and what it can do on the mesh, see Agent Link Entrypoints (Early Access).

Declaring a Link Agent

You declare an Agent Link Entrypoint as an entrypoint resource. The following example declares the partner-link entrypoint:

# entrypoints/partner-link.yaml
kind: entrypoint
name: partner-link
description: Lets partner agents join the mesh.
spec:
  type: agent_link
  values:
    maxInflight: 16

The values fields are optional. To see the fields that this type accepts, run sam config schema show entrypoint --type agent_link.

The following example declares a link agent that connects through the partner-link entrypoint:

# linkAgents/claims-desk.yaml
kind: linkAgent
name: Claims Desk
description: Answers claims questions for the partner.
spec:
  entrypoint: partner-link
  tokenSha256: ${CLAIMS_DESK_TOKEN_SHA256}
  owner: alice@example.com
  team: Claims Operations
  peers:
    - policy-desk
  wake:
    url: https://runtime.example.com/invocations
    tokenUrl: https://idp.example.com/oauth2/token
    clientId: claims-client
    clientSecret: ${CLAIMS_DESK_WAKE_SECRET}

In this example, policy-desk is an agent that runs from a runtime configuration file. The manifest lists the link agent under linkAgents. This example also declares the partner-link entrypoint, so the manifest lists it under entrypoints. If the entrypoint already exists on the Platform service, for example because you created it on the Entrypoints page, you do not need to list it:

# manifest.yaml
resources:
  entrypoints:
    - partner-link
  linkAgents:
    - Claims Desk

Link Agent Fields

The name must be 3 to 40 characters. It must be unique among all agents, ignoring letter case and spaces.

If the file sets a field under spec or spec.wake that the following tables do not list, sam config plan fails.

The spec accepts the following fields.

Field Required Description
entrypoint Yes The name of an Agent Link Entrypoint. The entrypoint must be declared in the same manifest or already exist on the Platform service.
tokenSha256 Only to create The SHA-256 digest of the agent's token, as 64 lowercase hexadecimal characters. For more information, see The Token Digest.
enabled No Whether the agent can connect and Agent Mesh can start it on demand. The default is true.
owner No The person or group responsible for the agent, up to 256 bytes.
team No The team responsible for the agent, up to 256 bytes.
peers No The agents that this agent can call, up to 64. For more information, see Peers.
shareUserProfile No Whether Agent Mesh sends the user's profile to the agent with each task. The default is false.
wake No The settings for an agent that starts on demand. Omit wake for an agent that stays connected.

The user's profile comes from the profile provider that the Platform service is configured with, not from the identity provider that signs users in. Without a profile provider, a task carries no profile, only the user's ID. For more information about the profile provider, see The Platform Block.

Wake Fields

When a task arrives for a link agent that has a wake block and is not connected, Agent Mesh calls wake.url to start the agent. The wake block accepts the following fields.

Field Required Description
url Yes The address that Agent Mesh calls to start the agent.
tokenUrl, clientId, clientSecret No The OAuth token address and client credentials that Agent Mesh uses to get the access token that it sends with each call. Set all three fields, or none.
scope No The OAuth scope that Agent Mesh requests at tokenUrl.
headers No The extra HTTP headers that Agent Mesh sends with each call, up to 32.
timeoutSeconds No The time that one call can take, from 1 to 86,400 seconds. The default is 900 seconds (15 minutes).
onStart No Whether Agent Mesh also starts the agent when its entrypoint starts. The default is true.

The Platform service rejects a link agent whose url, tokenUrl, or headers breaks one of these rules:

  • The url and tokenUrl addresses must use https. The Platform service accepts http only for localhost or a loopback address.

  • The url and tokenUrl hosts cannot be a reserved IP address, such as a cloud metadata, link-local, unspecified (0.0.0.0 or ::), broadcast, or multicast address.

  • The url and tokenUrl addresses cannot contain a username or password. Send credentials for url in headers, and credentials for tokenUrl in clientId and clientSecret.

  • The url address can carry the api-version query parameter once, and no other query parameter. Its value is 1 to 64 letters, digits, periods, underscores, or hyphens and starts with a letter or digit, such as 2025-05-01 or v1.

  • The tokenUrl address cannot carry a query string.

  • Two header names cannot differ only in letter case, such as X-Api-Key and x-api-key.

  • The headers cannot set Host, Content-Length, Transfer-Encoding, or Content-Type, because the wake call sets them.

  • The headers cannot set Authorization when tokenUrl is set, because Agent Mesh sends the access token in that header.

The Agent Link Entrypoint also restricts the addresses that a wake call reaches, and it ignores proxy settings. For example, it does not call a localhost or private-network address that the Platform service accepts unless the Entrypoint Executor allows it. For more information about these restrictions, see Waking Request-Driven Agents.

The clientSecret field and the values in headers are secrets, so reference them with ${VAR}. For more information about ${VAR}, see Variable Substitution. The Platform service never returns the secrets, and sam config pull writes each one as a placeholder variable. For more information, see Secrets Come Back as Placeholders.

Omitting an Optional Field

When a link agent's file no longer sets an optional field, apply clears the stored value or resets it to its default, with these exceptions:

  • Leaving tokenSha256 out keeps the stored token.

  • Leaving wake.clientSecret out keeps the stored secret only while wake.url and wake.tokenUrl stay unchanged. If either address changes, apply fails until the file sets clientSecret.

The Token Digest

A link agent proves its identity with a token. The Platform service stores only the SHA-256 digest of the token, and a resource file holds only the digest. The tokenSha256 field is required to create a link agent, because a resource file cannot receive a token that the Platform service generates and shows once. When a link agent already exists on the Platform service, a file that omits tokenSha256 keeps the stored token, and plan does not compare a digest for that link agent.

The sam-link-sdk link-token command comes with the Agent Mesh Link SDK (sam-link-sdk), the Python package that the agent uses to connect to Agent Mesh. For more information about installing the Link SDK, or issuing a token without it, see Issuing a Token for the Agent.

To issue a token, run the following command where the agent runs. The command writes the token to the file that --out names and prints the token's digest:

sam-link-sdk link-token --out claims-desk.link-token

Set tokenSha256 to the digest, or to a variable that holds the digest. Issue a separate token for each link agent, because the Platform service rejects a digest that another link agent uses.

The Platform service never returns the digest, which has two effects:

  • When the file sets tokenSha256 and the link agent's other fields match the Platform service, sam config plan asks the Platform service whether the digest in the file matches the stored digest. That comparison requires the agent_builder:*:update scope. For more information, see Comparing Secrets at Plan Time.

  • The sam config pull command does not write tokenSha256. Without the digest, a pulled repository still plans against the Platform service that it came from. To create its link agents on another Platform service, add tokenSha256 to each link agent's file first, or plan fails with spec.tokenSha256 is required to create a link agent.

If you no longer have the digest of a token, compute it from the token file. The following example computes the digest with sha256sum, which prints the digest followed by the file name. On macOS, run shasum -a 256 instead.

sha256sum claims-desk.link-token

Set tokenSha256 to the 64-character digest only. Consider the following details:

  • The digest covers the token alone, so a line break at the end of the file produces a different digest.

  • The Platform service rejects the digest of an empty token, which you get when the token or its file is empty.

To replace a token, perform these steps:

  1. Issue a new token to a new file. The link-token command does not overwrite an existing file.

    sam-link-sdk link-token --out claims-desk-2.link-token
  2. Set tokenSha256 to the digest that the command prints.

  3. Run sam config apply. The plan row for the link agent reads update + deploy. A change to the digest requires the agent_builder:*:deploy scope as well as agent_builder:*:update.

  4. Give the agent the new token file, for example by setting SAM_LINK_TOKEN_FILE to its path. When the deployment completes, the previous token stops working. For more information about SAM_LINK_TOKEN_FILE, see Connecting the Agent.

While a file sets tokenSha256, sam config apply makes that digest the link agent's token. If someone replaces the token outside the file, for example through the Platform service API, the next apply restores the file's digest. When that apply deploys the link agent, the token that the digest belongs to works again, and the replacement token stops working. Update the file whenever you replace a token, or leave tokenSha256 out after the link agent exists.

If the deployment fails, or you run apply --no-deploy, the Platform service stores the new digest, but the previous token keeps working until a later apply deploys the link agent. If you replace a token because it leaked, run apply without --no-deploy and confirm that it exits with status 0, which means that the deployment succeeded.

Peers

The peers field lists the agents that the link agent can call. List each agent by its name on the mesh, not by the name in its resource file. For an agent that the Platform service manages, the name on the mesh is its instanceName, which the Platform service assigns when it creates the agent, such as agent_0190f5ec_6f7a_7b8c_ad0e_8a9b0c1d2e3f. Use the following name for each kind of peer:

  • For an agent that the Platform service manages, use its instanceName. To read it, run the following command:

    sam api /api/v2/platform/agents -m manifest.yaml --paginate \
      --jq '.data[] | select(.name=="Billing Desk") | .instanceName'
  • For another link agent, use its instanceName, which the command in Connecting the Agent returns.

  • For an agent that runs from a runtime configuration file, use the name in that file.

A peer name contains letters, digits, hyphens, and underscores and starts with a letter or digit. A link agent cannot list itself or list a peer twice.

A peer does not have to be on the mesh when you apply. The sam config plan command fails when a peer is the name of an agent or link agent that the Platform service manages or that the manifest declares, because the link agent cannot call the agent by that name. The error names the link agent and the peer. When the agent already exists, the error also names the agent's instanceName to list in its place.

An agent in the same manifest that does not exist yet has no instanceName until apply creates it. To list an agent that the same apply creates, perform these steps:

  1. Run sam config apply without that peer.

  2. Read the agent's instanceName. For an agent, use the command earlier in this section. For a link agent, use the command in Connecting the Agent.

  3. Add the instanceName to peers and run sam config apply again.

Deployment Order

A link agent depends on its entrypoint, so apply orders the entrypoint and the link agent:

  • The apply command creates and deploys the entrypoint before the link agent.

  • A link agent cannot deploy while its entrypoint is not deployed. If the entrypoint's deployment fails, the link agent's deployment fails with an error that names the entrypoint.

  • With --prune, the apply command deletes link agents before entrypoints, because the Platform service does not delete an Agent Link Entrypoint that a link agent still names.

  • The apply command also updates link agents before it deletes entrypoints, so one apply --prune can move an undeployed link agent to a new entrypoint and delete the old entrypoint.

You cannot move a deployed link agent to another entrypoint. If you change entrypoint on a deployed link agent, apply fails for that link agent. To move a deployed link agent to another entrypoint, perform these steps:

  1. Find the ID of the link agent. For more information, see Connecting the Agent.

  2. Undeploy the link agent. This request requires the agent_builder:*:deploy scope:

    sam api -X POST /api/v2/platform/agentDeployments -m manifest.yaml \
      --field agentId=<link-agent-id> --field action=undeploy
  3. Change entrypoint in the file and run sam config apply.

Connecting the Agent

After the first apply, read the agent's connection values from the Platform service:

sam api /api/v2/platform/linkAgents -m manifest.yaml --paginate \
  --jq '.data[] | select(.name=="Claims Desk") | {id, instanceName, connectUrl, connectPath}'

If connectUrl is null, join connectPath to the address of the Agent Mesh UI, with wss:// in place of https://, or ws:// in place of http://. For example, for an Agent Mesh UI at https://sam.example.com and a connectPath of /gw/0190f5e4-8b2c-7c3e-9a1d-2f4b6c8d0e1f/v1/connect, the agent connects to wss://sam.example.com/gw/0190f5e4-8b2c-7c3e-9a1d-2f4b6c8d0e1f/v1/connect.

The Link SDK refuses a plain ws:// address to a host other than localhost or a loopback address unless you set SAM_LINK_ALLOW_INSECURE to 1, true, or yes, so use wss:// with TLS. For more information, see Network Access.

Give the agent these values in the following environment variables, which the Link SDK reads:

  • SAM_LINK_URL — Set it to the connectUrl value, or to the address that you joined. The agent connects to this address.

  • SAM_AGENT_NAME — Set it to the instanceName value, not the name in the resource file. The agent connects under this name, and the entrypoint refuses a connection under any other name.

  • SAM_LINK_TOKEN_FILE — Set it to the path of the token file that sam-link-sdk link-token wrote. Alternatively, set SAM_LINK_TOKEN to the token itself. Set only one of the two, because the Link SDK reports an error when both are set.

Renaming a Link Agent

If you change the name of a link agent in its file, the plan shows a create for the new name and a delete (needs --prune) for the old name. The new link agent gets a new instanceName, so update the agent to connect with the new name. Creating the new link agent requires tokenSha256 in the file:

  • If the file sets the digest that the old link agent holds, run apply with --prune. The apply command deletes the old link agent before it creates the new one. Without --prune, the old link agent still holds the digest, so the create fails.

  • Without --prune, you can create the new link agent by issuing the agent a new token and setting its digest in tokenSha256. The old link agent then stays on the Platform service until you run apply --prune or delete it. If the old link agent is deployed, its token keeps working until then.

Next Steps

From here, you can: