Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
Cortex XDR

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.

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 and Agentic Assistant role-based access control.

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 . 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.

    Tip

    • Make your prompts detailed.

    • Input arguments should include a name, type, whether it is required, and optionally a default value.

    • Mention if you expect the output in a specific format, such as a table, JSON, or plain text.

    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"

      Note

      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.

    • "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 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 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."

    Note

    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.

  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 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.

      Note

      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.

Last updated

Was this helpful?