---
question: How do I check that an agent is published and answers?
kind: task
via_web: available
via_cli: available
via_python: available
via_api: available
via_config: na
ref_web: Settings › Agents
ref_cli: abi dev logs
ref_python: FakeListChatModel
ref_api: POST /api/chat/complete
next:
  - /capabilities/build/agents/chat-with-an-agent
  - /capabilities/build/agents/edit-prompt-and-model
---

# Test an agent

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

## Web UI

### Check that it is published

In the workspace, open Settings › Agents. A module agent shows its module id under its name, and is on while its module is `READY`. A row that is off, or missing, means the module is not running or does not publish the agent.

### Chat with it

Open **Chat** and pick it in the agent picker: see [Chat with an agent](/capabilities/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 is published

```bash
abi dev status            # services and dev modules, with their pids
abi dev logs research -f  # "... READY: registered in discovery, serving Research"
```

The module logs `READY` once discovery registered it, and, until then, a warning every 15 seconds with its discovery status. The System app's **Modules** tab shows the same. An agent you declared but did not bind in `on_initialized` is not published.

### Run the module's tests

```bash
uv run --with pytest pytest src/research
```

`abi chat` and `abi agent list` do not reach a module's agents: they show the agents the engine loads itself. Chat with a module agent in Nexus or through the REST API.

## Python

### Write the test

Build the agent with a fake chat model, from the constants of the file `abi new agent` wrote. It needs no engine:

```python title="src/research/agents/ReviewerAgent_test.py"
import asyncio

from langchain_core.language_models.fake_chat_models import FakeListChatModel
from naas_abi_sdk.agents import AgentConfiguration, IntentAgent

from research.agents.ReviewerAgent import DESCRIPTION, NAME, SYSTEM_PROMPT


def build(*answers: str) -> IntentAgent:
    return IntentAgent(
        name=NAME,
        description=DESCRIPTION,
        chat_model=FakeListChatModel(responses=list(answers)),
        configuration=AgentConfiguration(system_prompt=SYSTEM_PROMPT),
        enable_default_intents=False,  # no embedding model in the test
        markdown_pretty_display=False,  # one model call per answer
    )


def test_reviewer_is_built():
    assert build("ok").name == "Reviewer"


def test_reviewer_answers():
    agent = build("Looks good.")
    assert asyncio.run(agent.invoke("Review this.")) == "Looks good."
```

### Run it

```bash
uv run --with pytest pytest src/research/agents/ReviewerAgent_test.py
```

Without `memory`, the agent keeps its threads in memory, so the test needs no Document Service. The fake model does not call tools: to test a tool, call its function directly, or test the workflow behind it. Intents need an embedding model: pass one that returns fixed vectors to test them.

## REST API

### Send a test prompt

Once the module is `READY`, find the agent's id with `GET /api/agents/?workspace_id=<id>`, then send it a prompt through the Nexus chat API:

```http
POST /api/chat/complete
```

The body holds `workspace_id`, `message` and `agent`, the agent's id. Auth: a Nexus session with access to the workspace. It returns the whole answer; `POST /api/chat/stream` streams it. See [Chat with an agent](/capabilities/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](/capabilities/build/models/choose-the-default-model).
