﻿---
title: Agent messages fail when a pre-execution workflow is disabled in Elastic Agent Builder
description: Troubleshooting guide for the Agent Builder error "Workflow is disabled and cannot be executed", returned when an agent or space still uses that workflow.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/8440/explore-analyze/ai-features/agent-builder/troubleshooting/pre-execution-workflow-disabled
products:
  - Elastic Cloud Serverless
  - Elastic Documentation
  - Elastic Observability
  - Elastic Security
  - Elasticsearch
  - Kibana
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Generally available since 9.4
---

# Agent messages fail when a pre-execution workflow is disabled in Elastic Agent Builder
[Pre-execution workflows](/elastic/docs-content/pull/8440/explore-analyze/ai-features/agent-builder/agents-and-workflows#pre-execution-workflows) run after each user message, before the agent makes any calls to the large language model (LLM) in response. Disabling a workflow doesn't remove it from the agent or the space setting that uses it, so the agent keeps trying to run it.

## Symptoms

- Every message to an agent fails before the agent responds. You get no partial answer.
- The conversation shows a **Workflow Failed** error like this one:
  ```json
  The workflow "<workflow_id>" execution failed: Workflow '<workflow_id>' is disabled and cannot be executed.
  ```


## Diagnosis

You can assign a pre-execution workflow in two places: on an individual agent, and on the space. An agent runs the workflows from both, so check each one. If every agent in the space fails, the space setting is the likely source.
1. **Check the agent.** Run the following request from [Dev Tools](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/8440/explore-analyze/query-filter/tools/console) and check `configuration.workflow_ids`:
   ```json
   ```
   You can also check in the UI. Select **Manage components** at the bottom of the left sidebar to open the **Agents** list, select the failing agent, then go to **Settings** → **Pre-execution workflow**.
   On serverless, and on 9.5.3 and later, a disabled workflow appears in the **Workflows** selector as `<workflow name> (disabled)`.
   On 9.4.x, and on 9.5.0 through 9.5.2, disabled workflows don't appear in the selector, so it can look empty even though the API response lists a workflow ID. Use the API response to identify the workflow.
2. **Check the space setting.** Check this if the agent's `configuration.workflow_ids` is empty, or if every agent in the space fails. Run the following request and look for `agentBuilder:prePromptWorkflowIds`:
   ```json
   ```
   The response lists only settings that someone has explicitly set. If the key is absent, no space workflows are assigned.


## Resolution

Remove the workflow from the setting that uses it. To keep using the workflow, re-enable it instead.
<note>
  Removing a workflow from an agent requires a role that grants wildcard (`*`) Kibana privileges, such as the built-in `superuser` role. You can't grant this from the Kibana role management UI. Without it, the **Workflows** selector is read-only in the UI, and the API returns a `400` error with the message `Only administrators can configure pre-execution workflows.`Changing the space setting requires the `manage_advanced_settings` privilege instead, which you can grant through the **Advanced Settings** [feature privilege](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/8440/deploy-manage/users-roles/cluster-or-deployment-auth/kibana-privileges).
</note>


### Remove the workflow from an agent

1. Open the agent's **Settings** → **Pre-execution workflow** section.
2. Clear the disabled workflow from the **Workflows** selector, then save the agent.
   On 9.4.x, and on 9.5.0 through 9.5.2, the disabled workflow doesn't appear in the selector. Re-enable the workflow, clear it from the selector, save the agent, then disable the workflow again.

You can also update the agent through the API. The following request clears every pre-execution workflow from the agent:
```json

{
  "configuration": {
    "workflow_ids": []
  }
}
```

The update replaces only the keys you send, so the agent keeps its instructions, tools, skills, and other settings. To keep the agent's other pre-execution workflows, list their IDs instead of sending an empty array.

### Remove the workflow from the space setting

<applies-to>
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview since 9.4
</applies-to>

1. Go to **Stack Management** → **AI** → [**GenAI Settings**](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/8440/explore-analyze/ai-features/manage-access-to-ai-assistant).
2. In the **Agent Builder** section, find **Pre-execution workflow**.
3. Clear the workflow from the **Workflows** selector.
4. Select **Save changes**.

Agents run the space workflows whenever Elastic Workflows is turned on, even when the **Agent Builder** section is hidden. If the section doesn't appear, or if the disabled workflow isn't listed in the selector, clear the setting through the API instead. The setting is hidden from the **Advanced Settings** page, so the API is the only way to change it outside of **GenAI Settings**. The following request clears every pre-execution workflow assigned to the space:
```json

{
  "changes": {
    "agentBuilder:prePromptWorkflowIds": []
  }
}
```

To keep the other workflows, list their IDs instead of sending an empty array. This request applies to the current space, so run it in each space that needs it.

## Best practices

- Before you disable a workflow, remove it from any agent and from the space setting that uses it. Disabling it alone breaks those agents.
- Before you turn off the `agentBuilder:experimentalFeatures` advanced setting, clear the space setting. Assigned workflows keep running, but the **Agent Builder** section you'd use to change them disappears.


## Resources

- [Pre-execution workflows](/elastic/docs-content/pull/8440/explore-analyze/ai-features/agent-builder/agents-and-workflows#pre-execution-workflows)
- [Assign workflows to every agent in a space](/elastic/docs-content/pull/8440/explore-analyze/ai-features/agent-builder/agents-and-workflows#assign-pre-execution-workflows-to-a-space)
- [Turn a workflow on or off](/elastic/docs-content/pull/8440/explore-analyze/workflows/authoring-techniques/manage-workflows#workflow-enable-disable)

<tip>
  If you have an [Elastic subscription](https://www.elastic.co/pricing), then you can [contact Elastic support](/elastic/docs-content/pull/8440/troubleshoot#contact-us) for assistance.
</tip>