> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-xdr/detect-investigate-and-respond-to-threats/investigate-and-respond-to-cases/automation/scripts/accelerate-script-development-using-the-automation-engineer-agent.md).

# Accelerate script development using the Automation Engineer agent

Use the Cortex XDR Automation Engineer agent to accelerate script development.

Use the Automation Engineer agent to create, edit, fix, and understand Python scripts by chatting in natural language.\
The Automation Engineer agent works in the **Agentic Assistant** pane of the script editor. Describe what you want in plain language. The agent creates or updates the script, and each change becomes a new revision you can review before you save it.\
You can ask the agent to:

* Create a script from a description of what it should do.
* Change an existing script, for example to add a check, an argument, or an output.
* Fix errors by pasting an error message from a test run.
* Explain a script, including system scripts and the script that is open.
* Improve a script by simplifying its logic, replacing deprecated commands, or adding input checks, error handling, comments, and debug logging.
* Ask the agent to explain a script's logic or how to run specific commands without the agent making any changes to the script itself.

The agent only uses commands that exist in your tenant. If a script needs a command from an integration that isn't installed, the agent either uses a generic alternative and says so, or tells you to add that part yourself. When you install or update a content pack, its scripts and commands become available to the agent right away.<br>

{% hint style="info" %}

### Note

The Automation Engineer agent is available with the Cortex Agentic Assistant for users with script editing permissions. For more information, see [Cortex Agentic Assistant permissions](https://cortex-docs.paloaltonetworks.com/cortex-xdr/reference-and-developer-docs/role-based-access-control/cortex-agentic-assistant-permissions.md) and [Agentic Assistant role-based access control](https://cortex-docs.paloaltonetworks.com/cortex-xdr/onboard-cortex-xdr/post-deployment-steps/configure-the-cortex-agentic-assistant/agentic-assistant-role-based-access-control.md).
{% endhint %}

### How to use the Automation Engineer agent

1. From the **Investigation & Response** → **Automation** → **Scripts** page, either choose an existing script or create a new script.

   **For a new script**

   1. Click **+ New Script**, give the script a name, and click **Save**.
   2. Click ![](https://2127116976-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcyIgISZgANJYkmLlnwdK%2Fuploads%2Fgit-blob-fd1434a746c90e1d3117d0202bc1887c7e33f172%2Fimage%20\(51\).png?alt=media). The **Agentic Assistant** pane opens with the Automation Engineer agent automatically selected.

   **For an existing script**

   1. In the **Scripts Library**, search for the script you want to use.
   2. Click **Edit**. The Agentic Assistant pane automatically opens with the Automation Engineer agent selected.\
      If a script is installed from a content pack, by default, the script is locked, which means that it is not editable. To edit a system script, you first need to duplicate it.

   If you are in the middle of a chat with a different agent, you are prompted to start a new chat with the Automation Engineer agent.

   If you start a chat with one script and switch to another script, you are prompted to start a new chat.
2. In the Agentic Assistant pane, enter a natural language prompt describing what you need the agent to do.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><h3>Tip</h3><ul><li>Make your prompts detailed.</li><li>Input arguments should include a name, type, whether it is required, and optionally a default value.</li><li>Mention if you expect the output in a specific format, such as a table, JSON, or plain text.</li></ul></div>

   For example:

   * "Explain what this script does."
   * "How do I run a command from a script and read its results?"
   * "I got this error: KeyError: 'userId'. fix it."
   * "Include explanations and inline comments in the script."
   * "Get all open issues from the last few days and build a table with each issue's ID, name and severity. Email the table to a given address.\
     Arguments: days (number, optional, default 3); email (string, required)\
     Output: IssuesSummary (string), a readable table of the issues"

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><h3>Note</h3><p>To send emails, you must have a mail integration installed. If the agent does not find one, it will inform you it cannot generate the email portion of your request.</p></div>
   * "Include contextual log messages in the script for debug logging."
   * "Include try/except blocks with informative error logs for error handling."
3. Click ![ai-script-prompt-go.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABJ0AAASdAHeZh94AAAAB3RJTUUH6QYFCCgXlZyfrQAAAa9JREFUWIXt1r9qwlAUBvAvNjaJIijEwYJIoEMy2kwtOAt9BPsQDn2BQvfSZ+jQ1dnFDpY6iaPdhCw6ZIj/YiRRO8UiGHuPGuuQb8y9l/y4OffkcgBWOMPE/hsQlAhGTQSjJoJRwwyTdA1ytQJBVcL0rMOzTowlREi6BknX4JkWRrUGps1OaLALAE9sMAnJUnEDmSzdYGU7WJgWVq53VBgHwi8p//a89fnSdjCuf2FSb2FpO6eH5V4ewcvpwPGl7WDW7mJUa8AzrYNgzJ8SAERVQfwqGzjOxXlcFnJIle/Ayxm4Rn/vHSTBFsPJus7+ig8UVQWeaWFB3EEazLTgGgNcXucRS4hMa/hsBslSEaKqABzgGgOmdaQa23ihnIagKRBUBZKuMUM904L5+g7X6O+cd7adn7nB+pF0DemH+52nc1vm3R6mnx3mpkyCCaoCuVohg4a1D8y/e6R1JFiqfMs8d9rsHNTPSLB4Ibdz/JgNlgQLqqswfknMsG3XHf+WMWt3jwYiw/js726d4trDDPPrZ1xvkU/YPtm784eds+38EYyaCEZNBKMmglETwaj5AcLUpYoXiOg8AAAAAElFTkSuQmCC) or Enter to submit the prompt.\
   The Agentic Assistant then displays the plan describes the steps the Automation Engineer agent took. It also shows a script preview card that includes the following details:

   * The script name.
   * The script revision number (#).
   * Script metadata: The number of lines, arguments, and outputs.
   * An expand icon that shows the new script code with the option to **Use this revision**.
   * A ![](https://2127116976-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcyIgISZgANJYkmLlnwdK%2Fuploads%2Fgit-blob-8e979d7c0d2f414812204b37985e79a6d0575dc0%2Fimage%20\(50\).png?alt=media) menu that includes **Use this revision** or **Copy code**.

   The first line of the generated script indicates it was generated by Cortex XDR, with the date and time of the latest update.
4. Refine the generated script as needed by describing the changes you want in a new prompt.\
   Each change creates a new revision of the script. Continue modifying and submitting prompts until the script works as intended.\
   For example, for a script that fetches all open issues from the last 3 days and generates a summary table with ID, name, and severity, modify the script as follows:\
   "Sort the table by severity, highest first, and only include issues with High or Critical severity. Keep the rest of the script the same."

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><h3>Note</h3><p>If you make manual edits in the script and don't save the changes, and then modify the script with the Automation Engineer agent, you are prompted to confirm that you're overwriting the manual edits.</p></div>
5. Choose a revision and save.\
   For a new script, click **Save Version**. For an existing script that was edited, click **Use this revision** and then **Save Version**.\
   You can access an earlier script revision by clicking ![three-dots-dark.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAjCAYAAAD17ghaAAAACXBIWXMAABJ0AAASdAHeZh94AAAAB3RJTUUH6QsCDQAEL/NOOgAAApxJREFUWIXtVzFrpEAYfXPIoOIMBq1clmUk2N2vuCK/5ur7CYH8lTTpUh6Brba9zkIJi1spBkdUjOAVYWVvV129y7Ep8irRb973+ObNN59ktVq1uCC+XDL5p4APIUCZGmgYBq6ursAYg6ZpUJS3pU3ToCxLSCmRpinyPH9fAaZpwnEcUEqRJAmiKEJRFGia5o1AUaDrOjjnuL6+Rl3X2O12eHl5mSSAjB1DIQQ454iiCHEcTyK0bRuLxQJZliEMw78ToCgKPM9DVVUIwxBtO69VEEIghICqqvB9v6tWH3pN6HkepJQIgmB2cgBo2xZBEEBKCc/zRmNPBAghUFUVttvt7MTH2G63qKoKQohpAkzTBOf87N7d3D1is9lgs9ng8e5mNDYMQ3DOYZrmeQGO4yCKorNltxntnimzR2PbtkUURXAcZ1yAYRiglE5ye33oqaY+Gx/HMSilMAzj5Ft3CpbLJQC8y973YYi/qwBjDFmW/ZfkAJBlGRhjJ+87AZqmoSiKSWRzTLhHURTQNG1YgKIoow3jEHNMuEfTNN390StgDuaacAydpL3C19fXs4vuv3/D/dxEAxXuKlCWJXRdn0k7HbquoyzLYQFSSnDOJ5Hd3D5g/bTG+mmNh9tpJuScQ0o5LCBNU1iWNYnMNhmoRkE1CmZOM6FlWUjTdFhAnueo6xq2fZ5wrglt20Zd173T0h/nYrfbYbVaIUmS0fvg/u4H4q8WKGokv36OJieEYLFY4Pn5uf/78UAihAAhBEEQjBJPheu6aNt28IY96QNhGEJV1a53/wuWyyVUVR293nsbke/7YIzBdV0QQmYnJoTAdV0wxuD7/njshxxKD3E8lmdZNjiWW5b1vmP5IS72Y7JHnuezyafg4v+GnwJ+AxX2QhQiVAHvAAAAAElFTkSuQmCC) and then **Use this revision** on the script preview card of the revision you want to use. Then click **Save Version**.
6. (Recommended) Validate your script.
   1. Click **Test**.
   2. In the **Arguments** section, provide values for any inputs your prompt requires. These inputs are used to simulate how the script will behave in a live playbook, or how the script registered as an Action and assigned to an Agent will run as part of an executed plan.

      You can add input values manually.
   3. Click **Run**.

      The scripts are executed in the Playground. Review the output generated by the script to validate its behavior and ensure it produces the expected results. The output is typically a text summary or another structured format that you have defined.

      <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><h3>Note</h3><p>If there is an error, you can copy the error message from the test result into the Agentic Assistant prompt and ask the Automation Engineer agent to correct the error.</p></div>

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-xdr/detect-investigate-and-respond-to-threats/investigate-and-respond-to-cases/automation/scripts/accelerate-script-development-using-the-automation-engineer-agent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
