automationobservabilityai August 18, 2026

Self-Healing Automation: What 'AI Reads the Logs and Fixes It' Actually Looks Like

Self-healing automation in practice: an AI assistant reads step-level run logs, finds a broken sync, patches the code and redeploys, with you approving the fix.

By vatech.io Team

At 6:40 a.m. your customer sync shows a red badge. The upstream API still returned HTTP 200, your credentials are valid, and nobody can say which records made it through. Before anyone can fix anything, someone has to reconstruct what happened.

Self-healing automation replaces that reconstruction with a conversation. You ask an AI assistant why the sync failed. It reads the run, finds the failing step, compares the error with the integration code, and proposes a patch. If you allow it, it also pushes and deploys the fix. This article walks through that sequence on one concrete incident, shows what the platform records that makes it possible, and covers the controls you should put around it.

“Self-healing” here does not mean unattended. It means the diagnosis and the first draft of the repair no longer cost an engineer an hour of log archaeology. A person still decides what ships.

Why “workflow failed” is not a diagnosis

A failure status tells you that you have an incident. It does not say whether the cause is an expired credential, a rate limit, a downstream outage, a mapping bug, or an upstream API that changed its response shape. Each needs a different fix. A blanket retry helps with a transient timeout. It does nothing for a field that moved inside a JSON object, and it can duplicate records if earlier steps already wrote data.

Integration platforms differ widely on this. Some keep detailed execution histories and replay tools. Others retain little, or leave you to connect an error to the code and payload yourself. When you evaluate a platform, the question is not whether it has a logs screen. It is whether one investigator, human or AI, can go from a specific run to the failing step, its input, and the deployed logic without rebuilding the workflow by hand.

For an AI assistant this decides everything. Given only the word “failed”, a model produces plausible theories and cannot tell which one occurred. Given the run evidence, it can cite a step and an error, read the code that raised it, and separate what it observed from what it infers. You can then check its claim against the same history.

What self-healing automation needs from step logs

Step-level observability breaks one execution into its component actions. For each run you can see which steps ran, their status and timing, and any errors or structured log entries. A successful fetch followed by a failed transformation points at a different problem than a failed fetch, and that distinction is what an assistant reasons over.

In HeadlessOps, the Runs API exposes this directly:

  • GET /api/runs lists runs with filters for status (PENDING, RUNNING, SUCCEEDED, FAILED, CANCELLED), integration, date range and a full-text search that covers error messages.
  • GET /api/runs/:runId returns the run with a stepLogs array.
  • GET /api/runs/:runId/steps returns the step events.
  • GET /api/runs/:runId/stream streams progress live over server-sent events, which you do not need for a completed run.

A run is marked FAILED when one or more steps fail without an error handler, so a handled error does not necessarily surface as a failed run. Keep that in mind when you ask “what failed last night”.

What you log yourself matters just as much. The TypeScript ctx API provides ctx.log(message, data?) for structured entries, and its stated best practice is to log the start and end of every step in a consistent step_name: event format. ctx.http is auto-instrumented, so each outbound call appears in the run logs with status and timing. A step’s return value becomes its output for downstream steps, which is separate from ctx.output, the integration-level response body.

Your logging design sets the ceiling on what an assistant can know. If a response body was neither passed on nor logged, the assistant cannot quote it, and it should say so instead of inventing one. Log enough context to diagnose a failure: field presence, counts, identifiers. Leave out tokens, authorization headers and unnecessary personal data. Do not assume sensitive fields are redacted for you.

A worked example: a nightly sync changes shape

The incident below is a synthetic illustration, not a customer case. Assume a scheduled integration with three steps:

  1. fetch_contacts requests a batch from an upstream service and returns the response body.
  2. normalize_contacts extracts the contact array and maps the fields.
  3. sync_contacts writes the normalized records to the destination.

The upstream service used to return this:

{ "contacts": [{ "id": "example-1", "name": "Example Contact" }] }

After an unannounced change, the same records arrive nested one level deeper:

{ "data": { "contacts": [{ "id": "example-1", "name": "Example Contact" }] } }

The request still succeeds. The old transformation reads input.response.contacts and calls .map on it. That field no longer exists, so the step throws before sync_contacts starts. Nothing is wrong with the destination, and rotating a credential would change nothing.

You ask your connected assistant:

Why did the customer sync fail last night? Show me the failing step and the evidence, without exposing secrets or personal data.

The assistant lists failed runs for that integration and time window, opens the matching run and reads its steps. A condensed answer looks like this:

Run: illustrative-run-001, FAILED
fetch_contacts: SUCCEEDED, HTTP 200, 420 ms
  output.response: {"data":{"contacts":[{"id":"example-1","name":"Example Contact"}]}}
normalize_contacts: FAILED, 8 ms
  input.response: {"data":{"contacts":[...]}}
  error: Cannot read properties of undefined (reading 'map')
sync_contacts: not reached

The layout and timings are illustrative, not a response schema. The point is the reasoning it supports. The fetch succeeded. The transformation expected contacts at the top level. Its input has data.contacts. That is a diagnosis tied to a specific step and payload, not a guess correlated with a recent API change. A careful assistant also flags what it has not verified, such as whether the supplier changed pagination or field semantics at the same time.

Ask the assistant to patch, then verify

Your next message sets both the outcome and the boundary:

Update the normalization step to accept both the old and new response shapes. Fail clearly on anything else. Test with synthetic fixtures, show me the diff, and do not run a production sync without my approval.

The assistant reads the integration’s existing files and makes a narrow change to the one step:

export async function run(input: Record<string, any>, ctx: StepContext) {
  ctx.log("normalize_contacts: start");

  const response = input.response;
  const contacts = Array.isArray(response?.contacts)
    ? response.contacts
    : response?.data?.contacts;

  if (!Array.isArray(contacts)) {
    ctx.log("normalize_contacts: invalid response shape", {
      hasTopLevelContacts: response?.contacts !== undefined,
      hasNestedContacts: response?.data?.contacts !== undefined,
    });
    throw new Error("Expected contacts array at response.contacts or response.data.contacts");
  }

  const normalized = contacts.map((contact: any) => ({
    id: contact.id,
    name: contact.name,
  }));
  ctx.log("normalize_contacts: done", { count: normalized.length });
  return { contacts: normalized };
}

Three details are worth reviewing. An empty array is a valid result, so “no contacts today” is not confused with a broken response. Any other shape fails loudly, which prevents a run that looks green while silently skipping every contact. And the failure branch logs which paths were present, so the next incident arrives with its own evidence. If both fields were arrays, this version prefers the old top-level one. Whether that precedence is right is a decision for you and the provider’s contract, not the assistant.

Before anything is deployed, run the step against synthetic fixtures with a stub context, no network and no destination writes:

FixtureExpected result
{ "contacts": [{ "id": "example-1", "name": "Example Contact" }] }One normalized contact
{ "data": { "contacts": [{ "id": "example-1", "name": "Example Contact" }] } }The same contact
{ "data": { "contacts": [] } }An empty output array
{ "data": { "contacts": "unexpected" } }A clear error, no success output

Passing these proves compatibility with the samples, not with every production payload. Add contract tests from approved, sanitized examples and read the supplier’s change notice. If a real payload contains personal data, handle it under your organization’s data controls instead of pasting it into an unrestricted chat.

What happens under the hood

The interface is natural language, but every step maps to a concrete platform operation exposed to the assistant through the MCP server:

  1. Find the run. The assistant lists runs filtered by integration, failed status and date range. Confirm the workspace and timezone when it interprets “last night”.
  2. Read the evidence. It fetches the run with its stepLogs, and the step events if it needs more detail, then reads the integration code to compare the recorded failure with the expected shape.
  3. Edit the integration. An integration is a versioned package: an integration.yaml manifest plus one TypeScript file per step. The assistant changes the relevant file and shows you the diff.
  4. Push and deploy. The push operation uploads the files and snapshots a versioned deployment. A push-and-run variant also triggers a run, so check exactly which operation you are authorizing.
  5. Test and observe. A manual run is POST /api/integrations/:name/runs, which returns a run ID. The assistant reads the resulting step evidence instead of assuming that a request means success.

The MCP connection lets the assistant operate the platform rather than tell you which buttons to click. It does not supply knowledge of an upstream contract that was never recorded, and it does not replace testing or approval.

This is also the practical difference between an AI-native platform and an AI action added to a visual canvas. A visual builder can make a stable process easy to inspect and hand over. An MCP-connected assistant can investigate and modify the underlying code through conversation. Judge either by its real logging, permissions and review process, not by the interface.

The guardrails that make repair safe

Because the assistant can change production logic, the controls around it matter as much as the model.

Least privilege. The Runs API reads require the VIEWER role, while triggering a run requires DEVELOPER. Give investigators read access to the runs they need and restrict who can push and deploy. Label-based access control lets you scope that by integration.

Secrets stay in the vault. Credentials are referenced by name in code and resolved at execution time, so the assistant can write an integration without ever seeing the secret value. That boundary only holds if no step prints a credential or copies it into an error message, so review logs and code for that. Step inputs and outputs can also carry sensitive business data and need their own access and retention rules. Our post on credential security for AI agents covers the model in more detail.

Separate diagnosis from action. An assistant can identify the cause correctly and still propose an incomplete fix, misread a business rule or target the wrong environment. For a load-bearing integration, require a diff review, synthetic tests, an approved staging run and a documented way to restore the previous deployment.

Treat replay as its own decision. In this example the destination step never ran. Other incidents fail after partial writes, and a retry can duplicate messages, repeat payments or create duplicate records. Check the run history and downstream state, establish idempotency or reconciliation, and identify the affected subset before replaying anything. Never infer that a failed run had no side effects.

Name the person who can authorize a replay and the conditions that require escalation. Record the diff and test evidence, so the next investigation starts from a history instead of a blank page.

From a 2 a.m. page to a conversation

The goal is not an assistant that fixes every incident alone. It is that the person closest to the business problem can ask a plain question, get evidence from a specific execution, and work through a tested change without starting from a generic failure badge. Operations owners can investigate without becoming TypeScript specialists, and IT’s role moves toward defining access, evidence and promotion rules. That is the same shift we describe in citizen developers and IT governance.

Some incidents will still need an engineer or a formal approval. The difference is what that person receives: a failing step, a defensible diagnosis and a proposed diff, instead of a mystery at 2 a.m. If you are evaluating automation platforms, test that directly. Give a candidate a sanitized failed run and ask it to name the step, show its evidence, and propose a reversible change with a test plan. The answer will tell you more than a feature list.