Skip to main content

Trigger Background Agents

Causely pushes structured diagnoses to your agents and automation through webhooks as Issues are detected, not only through MCP queries. A background agent doesn't need to poll or wait for someone to ask a question. It starts working as soon as Causely identifies the problem.

Causely can reach a background agent in two ways:

How it works​

  1. Causely detects an Issue and determines its underlying diagnosis.
  2. The Causely Mediator sends the notification to your agent, either as a Generic Webhook request or as an A2A message. Either way it carries the Causely notification payload, which includes the Issue, the affected entity, its severity, and the diagnosis.
  3. The agent receives the notification and starts an investigation.
  4. The agent calls the Causely MCP server to retrieve the causal chain, logs, topology, and other evidence, then resolves the Issue or recommends a remediation.

The webhook tells the agent that something happened and what Causely concluded. MCP gives the agent the context to verify the diagnosis and act on it. This keeps the webhook payload small and lets the agent pull only the evidence it needs.

Prerequisites​

  • A background agent with an HTTP endpoint that accepts POST requests with a JSON body, reachable from the cluster where the Causely Mediator runs.
  • The agent is connected to the Causely MCP server. See Causely MCP Server for connection details, and Advanced Authentication for credentials that don't require a browser, which is what a non-interactive agent needs.
  • Permission to manage notifications in Causely.

Set up the notification​

  1. Go to Settings → Notifications and click Create.

  2. Complete the configuration:

    FieldValue
    NameA descriptive name, for example background-agent
    TypeGeneric
    URLThe endpoint your agent listens on, for example https://agent.example.com/trigger
    TokenThe full Authorization header value your agent expects, for example Bearer <token>
  3. Choose the cluster or clusters that handle processing and delivery.

  4. Add filters so the agent is only triggered by the Issues you want it to handle.

  5. Click Create.

The token is sent verbatim as the Authorization header, so include the scheme keyword yourself. See Authentication for details. To define the destination with a Kubernetes secret or environment variables instead of the UI, see Mediator-based configuration.

Push to an A2A agent​

If your agent speaks the A2A protocol, the Causely Mediator can send each notification to it as an A2A message instead of a webhook. The agent receives a new task, so you don't need an HTTP handler or a relay in front of it.

The A2A destination is configured on the Mediator with a Kubernetes secret or environment variables. It isn't available in the Settings → Notifications UI.

Choose the endpoint​

The destination type is A2A. The scheme of the URL selects the A2A binding:

URLBinding
https://agent.example.com/a2aJSON-RPC over HTTP(S)
grpc://host:portgRPC, plaintext
grpcs://host:portgRPC over TLS

Optional query parameters on the URL change how the message is sent. The Mediator removes them before it calls the agent.

ParameterDescription
typesNotification types to send, comma-separated, for example ProblemDetected,ProblemUpdated. Use all for every type. The default is ProblemDetected, because every message starts agent work.
kagentAgentA kagent (1.0 or later) Agent to send to through the kagent controller's A2A gateway, written as <namespace>/<name>. Each notification starts a new kagent Session.
userIdThe x-user-id header sent to kagent. Defaults to causely-mediator. Sessions created by the Mediator are owned by this user.
a2aVersion1.0 or 0.3, for JSON-RPC agents. By default the Mediator speaks A2A 1.0, and switches to 0.3 for that endpoint if the agent answers "method not found". gRPC endpoints support 1.0 only.

If you set a token, it's sent as Authorization: Bearer <token>. A token that already starts with Bearer is sent unchanged. Leave it empty if the agent doesn't require authentication.

Kubernetes secret​

Create a secret labelled causely.ai/notif-config: A2A in the Mediator namespace. This example sends High and Critical Issues to a kagent Agent named causely-investigator in the kagent namespace:

apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: a2a-notification-config
namespace: causely
labels:
causely.ai/notif-config: A2A
stringData:
notif_config_name: causely-investigator
notif_config_type: A2A
notif_config_url: grpc://kagent-controller.kagent.svc.cluster.local:8083?kagentAgent=kagent/causely-investigator
notif_config_token: "<token>" # optional; omit if kagent runs without authentication
notif_config_objecttype: issue
notif_config_filters: '[{"field":"severity","operator":"in","value":["High","Critical"]}]'
notif_config_filters_enabled: "true"
notif_config_global: "false"

For a generic A2A agent, set notif_config_url to the agent's endpoint, for example https://agent.example.com/a2a, and leave out kagentAgent.

Set notif_config_objecttype to issue. The objectId in the message is then the Issue ID that the Causely MCP tools, such as get_issue_details, accept. With the default object type, defect, the objectId identifies the diagnosis rather than the Issue, and the MCP Issue tools don't accept it.

The Mediator reads notification secrets when it starts, so restart it after you create or change the secret.

Environment variables​

Set these on the Causely Mediator deployment. Replace <NAME> with your notification config name.

NOTIFICATION_<NAME>_TYPE=A2A
NOTIFICATION_<NAME>_URL=grpc://kagent-controller.kagent.svc.cluster.local:8083?kagentAgent=kagent/causely-investigator
NOTIFICATION_<NAME>_OBJECT_TYPE=issue
NOTIFICATION_<NAME>_FILTERS_ENABLED=true

Environment variable configs override secrets with the same name.

What the A2A agent receives​

Each message has the user role and starts with a short text prompt: what happened, the affected entity, the severity, the Causely ID, and a link to the Issue in Causely. The full notification payload follows:

  • A generic A2A agent receives the payload as a separate structured data part.
  • A kagent Agent receives the payload as a JSON block appended to the text, because kagent accepts a single text part.

The message metadata also carries causely.ai/objectId and causely.ai/notificationType.

Delivery and retries​

Delivery is asynchronous. The Mediator queues messages and asks the agent to return immediately, so the investigation isn't tied to the request. Transient errors are retried. When a kagent Agent or a new Session isn't ready yet, for example while its sandbox starts, the Mediator waits longer between attempts. Messages that still fail are logged as dropped notifications, like other destinations.

Retries are safe. The A2A message ID is derived from the notification and the destination, so a retry reaches the agent as the same request. kagent returns the task that the first attempt created instead of starting a second Session.

The Mediator doesn't follow the task after the agent accepts it, and it doesn't delete kagent Sessions. Clean up finished Sessions on the kagent side.

Notifications queued before the destination existed

Notifications are queued for the Mediator until a destination fetches them. When you add the first destination, or restart the Mediator, it receives every notification that is still queued, including Issues that have since cleared. Each one that passes the filters starts an investigation. Start with narrow filters and a read-only agent, so a backlog doesn't turn into a burst of investigations into problems that are already gone.

Control what wakes the agent​

Every notification that reaches your agent can start an investigation, and every investigation consumes agent time and LLM tokens. Filter on the Causely side so the agent only receives Issues it should act on.

For example, forward only High and Critical Issues:

notif_config_filters: '[{"field":"severity","operator":"in","value":["High","Critical"]}]'
notif_config_filters_enabled: "true"

You can also filter by cluster, namespace, entity type, or whether the Issue impacts an SLO. See Filters for the full list of fields and operators.

Start in a read-only mode

When you first connect an agent, have it investigate and report without making changes. Switch to automated remediation once you have confirmed that the diagnoses and the agent's conclusions match your expectations.

What the agent receives​

The request is an HTTP POST with Content-Type: application/json. The fields most useful to an agent are:

  • type: ProblemDetected when the Issue is detected, or ProblemCleared when it resolves.
  • objectId: The identifier of the Issue, which the agent can pass to MCP tools to retrieve its full details.- name and severity: What Causely found and how serious it is.
  • entity: The affected entity, with its id, name, and type.
  • labels: Cluster, namespace, and workload context.
  • description: A summary of the diagnosis.

See Notification Payload for a complete example and field reference.

Write the agent's handler​

Your agent's handler should:

  1. Authenticate the request. Reject calls that don't carry the expected Authorization header.
  2. Acknowledge quickly. Return a 2xx response immediately and run the investigation asynchronously.
  3. Ignore ProblemCleared events, or use them to close out an investigation in progress.
  4. De-duplicate on objectId, so a repeated notification for the same Issue doesn't start a second investigation.
  5. Investigate through MCP. Use the Causely MCP tools to retrieve the Issue, its root cause, supporting evidence, and affected services before deciding what to do. Treat the diagnosis in the payload as the starting point and verify it against live evidence.

Examples​

The causely-oss/background-agents repository contains runnable examples of agents that are triggered by Causely and use the MCP server to investigate:

  • causely-background-agent: A standalone reference agent that receives Causely's webhook push, investigates with the Causely MCP tools, and either opens a pull request with a fix or recommends a remediation. It starts in an observe mode that never makes changes.
  • open-inspect: Connects Open-Inspect to the Causely MCP server so its background investigations cite root cause and log evidence in the pull requests they open.
  • aws-devops-agent: Wakes the AWS DevOps Agent with a Causely notification through a signed-webhook relay. The agent calls back into the Causely MCP server for the causal chain.
  • claude-managed-agents: A Claude Managed Agent investigating a live Kubernetes cluster through remote MCP servers.

Learn more​