---
question: "Where do I change an agent's prompt so it persists?"
kind: task
via_web: available
via_cli: na
via_python: available
via_api: available
via_config: available
ref_web: Edit Agent
ref_python: SYSTEM_PROMPT
ref_api: PATCH /api/agents/{id}
ref_config: default_chat_model
next:
  - /capabilities/build/models/choose-the-default-model
  - /capabilities/build/agents/chat-with-an-agent
  - /capabilities/build/agents/system_prompt_techniques
---

# Edit prompt & model

A module agent's prompt is the `SYSTEM_PROMPT` of its file, and its model is the `chat_model` its `create_agent` asks the engine for. A workspace agent's prompt and model are fields of its record. Nexus edits the record; it does not change what a module agent runs.

## Web UI

### Open the agent

In the workspace, open Settings › Agents and click the agent's row (or its **Edit** pencil). **Edit Agent** opens.

### Edit the prompt and the model

Change **System Prompt** and **Model ID**. For a workspace agent, **Model ID** is the provider's own model id, sent to its API unchanged, such as `google/gemma-4-26b-a4b-it` for OpenRouter. Settings › Models shows it in its **Model ID** column.

![Edit Agent for the SpaceX KAM Agent](/abi/Screenshot_Edit_Agent.png)

*Edit Agent: name, description and system prompt, with Enabled and Save at the top.*

### Save

Click **Save**. **Agent updated** confirms it.

For a workspace agent, both are used, through the provider on its record: see the note under [Set its model](/capabilities/build/agents/creating-an-agent#set-its-model). For a module agent, both fields are saved on the record, but the chat sends neither: the module runs the agent with its own prompt and model. Change those in the module, as in the Python and Config steps.

## CLI

Not applicable. No `abi` command edits an agent: edit its file, as in the Python steps.

## Python

### Edit the prompt

The prompt is `SYSTEM_PROMPT` in the agent's file, passed to `AgentConfiguration`:

```python title="agents/ReviewerAgent.py"
SYSTEM_PROMPT = """<role>
You are Reviewer, a careful reviewer.
</role>

<objective>
Help the user review their documents.
</objective>
"""
```

How to write one is [System prompt techniques](/capabilities/build/agents/system_prompt_techniques).

### Pick the model

The scaffold takes the engine's default chat model, or the canonical id passed as `chat_model`:

```python title="agents/ReviewerAgent.py"
chat = await registry.get_default_chat_model()            # the default
chat = await registry.get_chat_model("claude-sonnet-5")    # a given model
```

When two enabled provider modules register the same id, `get_chat_model("claude-sonnet-5", provider="anthropic")` prefers that provider. When that provider has not registered the id, the registry falls back to another provider's model, so the calls, their billing and the data go to that other vendor. The module that registers the id has to be enabled in the engine.

### Restart the module

The module builds the agent once, when it starts. Restart it (`abi dev down --service research`, then `abi dev up -d --service research`) to publish the change.

## REST API

### Update the record

```http
PATCH /api/agents/{id}
```

```json title="Request body"
{
  "system_prompt": "You are a careful reviewer.",
  "model": "google/gemma-4-26b-a4b-it"
}
```

The model goes in `model` (stored as the record's `model_id`): the provider's model id for a workspace agent. The call also takes `name`, `description`, `enabled` and `is_default`, and ignores the other fields. Auth: a Nexus session with access to the workspace. As in the Web UI, a module agent keeps the prompt and the model of its module.

## Config

### Change the default model

Agents that call `registry.get_default_chat_model()` run on `services.model_registry.default_chat_model`:

```yaml title="config.yaml"
services:
  model_registry:
    default_chat_model: "gemma-4-26b-a4b-it"
```

See [Choose the default model](/capabilities/build/models/choose-the-default-model).

### Give one agent its own model

The module that `abi new module` writes reads its chat model from the environment: `RESEARCH_CHAT_MODEL` for a module named `research` (`<NAME>_CHAT_MODEL`), into its `chat_model` configuration field. Under `abi dev up`, set it on the module's `dev.modules` entry:

```yaml title="config.yaml"
dev:
  modules:
    - name: research
      module: research
      identity: my_project.research
      env:
        RESEARCH_CHAT_MODEL: "gemma-4-26b-a4b-it"
```

In Docker Compose, add it to the module service's `environment`. The prompt is not a `config.yaml` key.
