---
question: How do I chat an agent from the terminal?
kind: task
via_web: available
via_cli: available
via_python: available
via_api: available
via_config: na
ref_web: Edit Agent
ref_cli: abi agent list
ref_python: FakeListChatModel
ref_api: POST /agents/{agent_name}/completion
next:
  - /capabilities/build/agents/chat-with-an-agent
  - /capabilities/build/agents/edit-prompt-and-model
---

# Test an agent

Check that the engine loaded the agent, then talk to it. A unit test can build it with a fake model, so it runs without a key or a network call.

## Web UI

### Check that it loaded

In the workspace, open Settings › Agents. An engine agent shows its Python module path under its name. Click the row: **Edit Agent** lists its **Intents** and **Subagents**, and **Service Metadata** shows its **Class**, **Status** and **Model**.

### Chat with it

Turn it on, open **Chat**, and pick it in the agent picker: see [Chat with an agent](/user-guide/build/agents/chat-with-an-agent?via=web). Start a **New Chat** for each scenario, so earlier messages do not steer the answer.

![Chat with a question typed in the message box](/abi/Screenshot_Chat_Agent.png)

*A question typed in the message box, ready to send. Auto routes it to the workspace's default agent.*

## CLI

### Check that it loaded

```bash
abi agent list
```

It loads the engine and prints each module with its agent classes. An agent missing from the table was not loaded: check that its file sits directly under `agents/` and that its module is listed under `modules:`.

### Chat with it

```bash
abi chat my_module ReviewerAgent
```

Type `/reset` between scenarios to start a new thread. Tool calls print as they happen; set `LOG_LEVEL=DEBUG` for the engine's logs too. The transcript is saved under `storage/datastore/interfaces/terminal_agent/`.

## Python

### Write the test

Put it next to the agent, in a file whose name ends in `test.py`, such as `ReviewerAgent_test.py`: the engine skips those when it loads `agents/`. `with_model_registry_override` hands `New()` a registry whose default chat model is a fake that returns canned answers. This test runs as is against the agent `abi new agent Reviewer` scaffolds:

```python title="agents/ReviewerAgent_test.py"
from langchain_core.language_models.fake_chat_models import FakeListChatModel
from naas_abi_core.engine.context import with_model_registry_override
from naas_abi_core.models.Model import ChatModel
from naas_abi_core.services.model_registry.ModelRegistryService import ModelRegistryService

from my_module.agents.ReviewerAgent import ReviewerAgent


def fake_registry(*answers: str) -> ModelRegistryService:
    registry = ModelRegistryService(default_chat_model="fake")
    registry.register(
        "fake",
        ChatModel(model_id="fake", provider="fake", model=FakeListChatModel(responses=list(answers))),
    )
    return registry


def test_reviewer_is_built():
    with with_model_registry_override(fake_registry("ok")):
        agent = ReviewerAgent.New()
    assert agent.name == "Reviewer"
    assert "[TOOLS]" not in agent.configuration.system_prompt


def test_reviewer_answers():
    with with_model_registry_override(fake_registry("Looks good.")):
        agent = ReviewerAgent.New()
        assert agent.invoke("Review this.") == "Looks good."
```

### Run it

```bash
uv run pytest src/my_module/agents/ReviewerAgent_test.py
```

The override only replaces the model registry. An agent whose `New()` reads its module's configuration (`ABIModule.get_instance()`) needs the engine loaded, so test it with `abi run script` or through its REST route instead. The fake model does not call tools: to test a tool, call its function directly, or test the workflow behind it.

## REST API

### Send a test prompt

Once the engine runs, call the agent's route with a fresh `thread_id`:

```bash
curl -X POST "http://localhost:9879/agents/Reviewer/completion" \
  -H "Authorization: Bearer $ABI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "What can you do?", "thread_id": 101}'
```

A 404 means the engine did not load the agent, or its name differs: `{agent_name}` is the agent's `name` with characters other than letters, digits, `_` and `-` replaced by `_`. The Swagger page at `/docs` lists every agent route. See [Chat with an agent](/user-guide/build/agents/chat-with-an-agent?via=api).

## Config

Not applicable. `config.yaml` holds no tests. It sets the model the agent runs on in a live test: see [Choose the default model](/user-guide/build/models/choose-the-default-model).
