# Background Agents

A background agent works on a prompt without you. It runs on a schedule, or whenever a search returns results, and saves what it finds as a chat you can read and continue later - for example, a morning summary of overnight authentication failures, or a first-pass triage of every notable an alert raises.

Background agents leverage Splunk's own scheduler and alerting: each one is a saved search with the **Lynx AI Background Agent** alert action. The agent runs on the Search Head, as the owner of the saved search and with their Splunk permissions, using the same tools, skills and connectors as the interactive chat.

## Requirements

- The [Lynx AI Runtime Add-on](<https://docs.trylynx.ai/installation/index.md#runtime-add-on>) must be installed on the Search Head, matching its platform. Background agents are supported on Linux and Windows x86\_64 Search Heads.
- Token authentication must be enabled on the Search Head, under **Settings \> Tokens** in Splunk Web. Each run authenticates with a short-lived token of its own (see [Security](<#security>)).
- Users need the [`lynx-ai-background`](<https://docs.trylynx.ai/usage/permissions/index.md#background-role>) role to create and run background agents.
- The Lynx AI backend must also be reachable from the **Search Head**, not only from users' browsers. See [Connectivity](<#connectivity>).

## Creating a Background Agent

1. Navigate to **Background Agents** in the Lynx AI Agent app's navigation bar.
2. Click **Add background agent**.
3. Fill in the following fields:

   - **Name** - The name of the saved search. It cannot be changed after the background agent is saved.
   - **Prompt** - The task the background agent works on. It cannot ask you anything, so say what to look at and what to report.
   - **Model** - The model the background agent runs on. **Default** uses your [default model](<https://docs.trylynx.ai/usage/settings/index.md#model>). If the chosen model is no longer available, runs fall back to your default model until you choose another one.
   - **Schedule** - A cron schedule in the Search Head's time zone, for example `0 6 * * *` for every day at 06:00.
   - **Search** *(optional)* - An SPL search that decides whether the background agent runs, along with its **Search time range**. With a search, the background agent runs only when it returns results, and receives them with the prompt. Without one, it runs on every schedule.
   - **Allow connector write access** - See [Connectors](<#connectors>) below.
4. Click **Save**.

Use the **Enabled** switch of a background agent to pause it without deleting it, and the remove button to delete it entirely.

Click the **Run now** button next to a saved background agent to run its search immediately. As on a schedule, the background agent only starts if the search returns results.

### Using Splunk's Alert Editor

The **Lynx AI Background Agent** action can also be added to any alert from Splunk's own alert editor, with the same **Prompt**, **Model**, **Reasoning** and **Connector write access** settings. Such alerts are listed on the **Background Agents** page as well, and the bell button next to a background agent opens it in the alert editor.

The **Background Agents** page only manages the fields above. Trigger conditions, throttling, and other alert actions are left as they are set in the alert editor - use it to fine-tune when a background agent runs.

> [!NOTE]
>
> Background agents created from the **Background Agents** page are private saved searches in the Lynx AI Agent app that trigger once per run when the search returns any results. Removing one deletes the saved search. Removing an alert that lives in another app only removes the background agent action from it.

### Configuring from Files

A background agent can also be defined in `savedsearches.conf`, like any other alert. For example:

```ini
[Overnight authentication failures]
search = index=security sourcetype=linux_secure "Failed password" | stats count by user, src
dispatch.earliest_time = -24h@h
dispatch.latest_time = now
cron_schedule = 0 6 * * *
enableSched = 1
alert_type = number of events
alert_comparator = greater than
alert_threshold = 0
alert.digest_mode = 1
actions = lynx_ai_background_agent
action.lynx_ai_background_agent = 1
action.lynx_ai_background_agent.param.prompt = Summarize the failed logins from last night. Call out any user or source that stands out, and suggest next steps.
```

See [savedsearches.conf](<https://docs.trylynx.ai/advanced/config-spec/savedsearches.conf/index.md>) and [alert\_actions.conf](<https://docs.trylynx.ai/advanced/config-spec/alert_actions.conf/index.md>) for every parameter of the action.

> [!WARNING]
>
> The saved search must be owned by a user. Searches owned by `nobody` are refused.

## Results

Each run is saved as a new chat in its owner's [chat history](<https://docs.trylynx.ai/usage/chat-history/index.md>), marked with a clock icon and the name of the background agent that started it. Open it to read what the agent found, and continue the conversation from there as with any other chat.

When the background agent was triggered by a search, the chat opens with the prompt followed by the search results, up to the first 100 results and the [result character limit](<https://docs.trylynx.ai/advanced/config-spec/ai.conf/index.md>).

A run that fails, or is stopped for running longer than the maximum run time, is saved too - with what it produced until then and a note explaining why it ended.

## Writing Good Prompts

A background agent works unattended: nobody is there to answer a question or confirm a choice. Where a request is ambiguous, it makes a reasonable assumption, states it in its response, and carries on.

- Say what to look at, what to look for, and what the result should look like - a summary, a table, a verdict.
- Use the search to select the data that matters, and the prompt to say what to do with it.
- Skills work normally in a background agent. A [skill](<https://docs.trylynx.ai/usage/skills/index.md>) is the best place for procedures shared by several background agents, such as a triage playbook.

## Limits

Admins set limits for all background agents from [Settings](<https://docs.trylynx.ai/usage/settings/index.md#agent-configuration>) page, or in the `[background]` stanza of [ai.conf](<https://docs.trylynx.ai/advanced/config-spec/ai.conf/index.md>):

| Setting | Default | Description |
| :--- | :--- | :--- |
| `max_runtime` - **Maximum run time** | `1800` | Seconds a background agent may work before it is stopped. What it produced until then is saved to its chat. |
| `max_concurrent_runs` - **Concurrent runs per user** | `2` | How many background agents one user may have running at the same time. A trigger while its owner is at the limit is skipped. |

## Security

Background agents follow the same [security model](<https://docs.trylynx.ai/usage/permissions/index.md>) as the interactive chat, with a few additions for working without a user present:

- **Owner's permissions.** A background agent runs as the owner of its saved search, and can only access what they can. [Risky commands](<https://docs.trylynx.ai/usage/permissions/index.md#risky-commands>) are blocked exactly as in the interactive chat.
- **Short-lived credentials.** Each run authenticates with its own Splunk authentication token for the owner, with the audience `lynx_ai_agent`. It expires two minutes after the maximum run time and is deleted as soon as the run ends. Deleting such a token from **Settings \> Tokens** in Splunk stops the run's access immediately.
- **Untrusted search results.** Search results can contain text written by third parties, such as log messages or email subjects. The agent treats them as data to analyze, never as instructions to follow.

### Connectors

Because nobody reviews what a background agent does before it acts, [connectors](<https://docs.trylynx.ai/usage/connectors/index.md>) are limited to tools the MCP server reports as read-only, whatever their configured risk level.

Turn on **Allow connector write access** to let a background agent use its owner's connectors at the risk level configured for them in [Settings](<https://docs.trylynx.ai/usage/settings/index.md#connectors>).

> [!WARNING]
>
> A background agent with connector write access acts on search results that can contain text written by anyone. Enable it only for background agents that need it, and keep the connectors' risk levels as low as the task allows.

## Connectivity

In normal chats, only users' browsers talk to the Lynx AI backend. Background agents call the backend from the Search Head itself, so if you want to use them, the backend server configured in [Settings](<https://docs.trylynx.ai/usage/settings/index.md#agent-configuration>) must be reachable from the Search Head as well.

If the Search Head reaches the internet through a proxy, set the standard `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY` environment variables for Splunk, for example in `$SPLUNK_HOME/etc/splunk-launch.conf`. Background agents honor them.

## Monitoring

Background runs are part of the [Activity Dashboard](<https://docs.trylynx.ai/advanced/activity/index.md>), which has a dedicated **Background Agents** section with the runs, outcomes, duration and tokens of every background agent, and the reason for any failure.

## Troubleshooting

If a background agent's chat doesn't show up:

- Check that the background agent is enabled, and that its search returns results for its time range.
- Check the trigger conditions and throttling of the alert in Splunk's alert editor.
- Check the **Background Run Failures** panel of the [Activity Dashboard](<https://docs.trylynx.ai/advanced/activity/index.md>). A trigger that didn't start a background agent - because the alert has no prompt, is owned by `nobody`, or its owner had reached the concurrent run limit - is listed there.
- If the Runtime Add-on is missing, the **Background Agents** page says so, and Splunk logs an error to `splunkd.log`:

  ```text
  index=_internal sourcetype=splunkd "ERROR lynx_ai_agent"
  ```
- If the run could not get its authentication token, for example because token authentication is disabled, a chat is still saved explaining why.
