---
title: Agent
order: 4
description: The reasoning engine behind every workspace.
---

# Agent

The **agent** is the reasoning engine that reads your sources, picks tools,
and produces answers. Investibook runs it behind a pluggable **agent runtime**:
OpenCode and Claude use ACP, while Pi uses JSONL RPC.

## The agent loop

1. You send a message in chat.
2. The backend opens a runtime session and streams your message together with
   the workspace's sources.
3. The agent emits a sequence of events:
   - `text` — partial answer streamed back to you.
   - `thought` — internal reasoning (collapsible).
   - `tool` — tool / skill invocations and their results.
   - `complete` — the run is finished.
4. The UI renders each event as it arrives.

## Switch the runtime

Run `/agent pi` or `/agent opencode` in chat. The selection is saved for the
current workspace and takes effect on the next message.

## What the agent has access to

- **Sources** in the active workspace (Jira, cluster, files).
- **Built-in and enabled skills**.
- **MCP tools** — e.g. Clinic, Wait, DevOps connectors shown in the sources panel.
- **Screenshots and PromQL** — you can explicitly ask the agent to grab a
  Grafana screenshot or run a PromQL query.

## Why a separate process?

Keeping the agent in its own process means:

- It can be upgraded independently of the Investibook backend.
- The backend stays small and stateless.
- Local development can swap agent binaries (`opencode` ↔ `claude-code-acp` ↔ `pi`)
  without rebuilding anything.

See [How-to → Run Investibook locally](/docs/how-to/run-locally) for how to
configure the agent binary.
