# Edit an action

Edit an action when the agent picks it at the wrong time, fills its parameters wrongly, or when its request does not match what your API expects. An action has two editable parts: the JSDoc, which the model reads, and the code, which the browser runs.

## What to change

| Problem | Edit |
| --- | --- |
| The agent runs the action for the wrong request, or never runs it. | The JSDoc. Say what the action does and when to use it. |
| The agent sends a wrong value, or asks the user for something it could work out. | The JSDoc, in the `@param` line of that parameter. |
| The request fails or returns the wrong data. | The code. |

## Edit in the Actions tab

For a small change:

1. In the portal, go to [**Web Agents**](https://auth.faustine.ai/go?to=%2Fweb-assistants) and select your agent.
2. Select the **Actions** tab and select the action's row.
3. Change the text in the **JSDoc** editor or the **code** editor.
4. In the save bar, select **Save changes**.

**Back to actions** returns to the table. The save bar keeps counting your edits across actions until you save or select **Discard changes**.

![An action open in the Actions tab, with its description, the two switches, its parameters and the JSDoc editor.](https://docs.faustine.ai/images/web-agents/action-detail-light.png)

## Edit in the action editor

The action editor is a full page for one action, with a larger code editor and a Faustine AI panel.

To open it and make a change:

1. Open the action in the **Actions** tab and select **Open in editor**.
2. Select the **JSDoc** tab or the **Code** tab and edit.
3. Select **Save**, or press Cmd+S on a Mac. The server checks the code before it stores it, and the toolbar shows **Saved to the draft**.

The toolbar also has the **Enabled** and **Ask to confirm** switches. **Discard** drops what you have not saved.

### Ask Faustine AI for the change

To have the change written for you:

1. In the action editor, select **Faustine AI**.
2. Describe the change, such as `retry once on a 429` or `document every parameter`.
3. Read the change. Faustine AI has already written it to the draft, and the **Changed by Faustine AI** panel shows the new JSDoc and code next to the text in your editor.
4. Select **Apply** to take the change into the editor. To keep your own text, select **Discard** and then **Save**, which writes your text over the change in the draft.
5. Select **Save**.

Faustine AI reads the app's code before it answers, and it works on this action only. It needs the agent to have a published version. Save your own edits before you ask, because it works from the stored draft.

For a change that spans several actions, or touches authentication or navigation, use [the Advanced editor](https://docs.faustine.ai/web-agents/advanced-editor/).

## Check and publish

**Test** runs an action inside your app, through the page connected in debug mode, with the code that page loaded: the version deployed to its environment. To test a change, publish it, reload that page, and select **Test** in the editor or in the action's row. See [Turn an action on or off and test it](https://docs.faustine.ai/web-agents/test-an-action/).

Edits are saved to the draft. Your site gets them when you publish a version. See [Publish a version](https://docs.faustine.ai/web-agents/publish-a-version/).

> **Note:** A re-analysis writes every action again and overwrites the edits in the draft. An update keeps them. See [Keep the agent up to date](https://docs.faustine.ai/web-agents/keep-up-to-date/).

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| **Publish a first version of the assistant before editing it with Faustine.** | The agent has no published version. | Publish the draft, then open the Faustine AI panel again. |
| **You have unsaved changes.** appears in the Faustine AI panel | Faustine AI edits the stored draft, and your edits are not in it yet. | Select **Save**, then send your message. |
| **The action is no longer in the draft.** | The action was removed by an update or a re-analysis while the editor was open. | Go back to the **Actions** tab and open the action again. |
| **Save** reports an error | The code did not pass the server's check. The message names the problem. | Fix the code and save again. |

## Next steps

- [The Advanced editor](https://docs.faustine.ai/web-agents/advanced-editor/): change several actions from one conversation.
- [Turn an action on or off and test it](https://docs.faustine.ai/web-agents/test-an-action/): run the edited action.
- [Publish a version](https://docs.faustine.ai/web-agents/publish-a-version/): send the change to your site.
