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

An engine agent's prompt is its `system_prompt` class attribute, and its model is the `chat_model` its `New()` passes. A workspace agent's prompt and model are fields of its record. Nexus edits the record; for an engine agent, only its model there changes what the chat 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**. What **Model ID** takes depends on the agent:

- **Engine agent**: a canonical id from the model registry, such as `gemma-4-26b-a4b-it`. Settings › Models shows it in its **Canonical ID** column, which you add from **Columns**.
- **Workspace agent**: 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 an engine agent, the Nexus chat then runs the agent on that model. Its prompt stays the class's `system_prompt`: the field is saved on the record but the chat does not send it. For a workspace agent, both are used, through the provider on its record: see the note under [Set its model](/user-guide/build/agents/creating-an-agent#set-its-model).

## CLI

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

## Python

### Edit the prompt

The prompt is the `system_prompt` class attribute. The scaffold replaces `[TOOLS]` in it with the agent's tool list:

```python title="agents/ReviewerAgent.py"
class ReviewerAgent(Agent):
    system_prompt: str = """<role>
You are ReviewerAgent, a careful reviewer.
</role>

<tools>
[TOOLS]
</tools>
"""
```

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

### Pick the model

The scaffold takes the registry's default chat model. Name a canonical id to pin another one:

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

When two enabled 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.

### Restart the engine

The engine builds the agent once, at startup. Restart it (`abi dev down`, then `abi dev up -d`) to load 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`): a canonical id for an engine agent, the provider's model id for a workspace agent, as in the Web UI. 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, an engine agent keeps its class prompt in the chat.

## 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](/user-guide/build/models/choose-the-default-model).

### Give one agent its own model

A module can read an agent's model from its configuration. `naas_abi` does it for its agents:

```yaml title="config.yaml"
modules:
  - module: naas_abi
    enabled: true
    config:
      abi_agent_model: "gemma-4-26b-a4b-it"
      ontology_engineer_model: "gemma-4-26b-a4b-it"
```

For your own agent, declare a field on the module's `Configuration` and pass it to `registry.get_chat_model(...)` in `New()`. The prompt is not a `config.yaml` key.
