---
url: https://bishop.agentdeployment.co/how-it-works.md
description: The pieces of Bishop, what happens during a turn, and what it keeps on disk.
---

# How It Works

Bishop is an agent gateway: one process that runs one agent and connects it to the places people already talk.

## The pieces

* **Agent.** A directory with an agent in it, run by a harness. Bishop doesn't decide what the agent does or knows. Its own configuration does, like `CLAUDE.md` and `.claude/settings.json`.
* **Harness.** The software that runs the agent: Claude Code through the Claude Agent SDK, or Codex through OpenAI's Codex SDK. One Bishop runs one of them. See [Harness and Model](/running/harness).
* **Interface.** A place people talk to the agent from: [Slack](/interfaces/slack), [email](/interfaces/email) or [Microsoft Teams](/interfaces/teams). Bishop runs every interface its [config](/reference/config) has a block for, in the same process.
* **Thread.** One conversation: a Slack thread or DM, an email thread, a Teams chat or channel thread.
* **Turn.** One exchange inside a thread. Messages arrive, the agent works, and an answer goes back.
* **Session.** The agent's memory of a thread. Bishop records which session belongs to which thread, and hands it back on the next message so the conversation picks up where it left off, including after a restart.
* **Schedule.** A prompt that runs on a clock instead of on a message. See [Scheduled Prompts](/running/schedules).

## A turn

1. A message arrives on an interface. Bishop checks the sender's [permission level](/running/access) and refuses the message if it's deny, or below the level the thread already runs at. A new thread takes the lower of the sender's level and the channel's.
2. Bishop finds the thread's session, or starts one, and hands the agent the message along with who sent it and where the conversation is. The agent runs with what the thread's level allows.
3. The agent works in its directory, or in the thread's own [worktree](/running/worktrees). Slack and Teams show the work as it happens. Email sends one reply when the turn is over.
4. Files people attached reach the agent as paths on disk, and files the agent sends go back as attachments. See [Files](/running/files).

Two threads are two independent conversations, even with the same person.

## What Bishop keeps

Everything is in Bishop's own directory, the one you run it from:

```
.bishop/config.json    configuration
.env                   credentials
bishop.db              threads, sessions, schedules, transcripts, permission levels
.bishop/threads/       one directory per thread: shared files, scratch files, harness state
.bishop/plugins/       the agent's plugins, installed once for every thread
.bishop/agents/        agents cloned from a git URL
.bishop/backups/       database copies taken before a migration
```

Each thread's directory holds the files people shared in it, a scratch directory where the agent writes the files it makes, and the harness's own state for that thread, including the session transcript it resumes from. A thread can't resume without its transcript. When the harness authenticates with a login (`claude login` or `codex login`) rather than an environment variable, threads keep their transcripts under the home directory of the user Bishop runs as instead, and so does any thread that started before thread directories. Threads from before keep their shared files in `.bishop/files/`. Bishop [collects](/deploying/cleanup) what old threads leave behind.

## What Bishop serves

Slack and Gmail need outbound access only: Slack holds a socket open and Gmail polls. Teams POSTs every message to an HTTPS endpoint, so Bishop serves one when Teams runs. Bishop also serves the agent its own tools, like scheduling a prompt and sending a file, on a loopback port with a credential that lasts one turn. Every port binds loopback. Nothing is reachable from off the machine unless you put a tunnel in front of it.
