Agent runtime

This page follows one prompt from the chat box to a reviewed diff. It shows where context comes from, how IZ Code talks to each agent, who decides what an agent may do, and why a session outlives the window it started in.

From prompt to diff#

One turn, from your prompt to a reviewed diff
flowchart TD
  p(["Your prompt, mentions, files"]) --> ahp["Agent Host (AHP): session and chat state"]
  ahp --> rt["Agent runtime in the Rust core"]
  rt --> ctx["Context Engine: first-turn context"]
  rt --> perm["Permission engine: allow, ask, deny"]
  rt --> tools["IZ Code tools over MCP"]
  rt -- "ACP over stdio" --> cli["Agent CLI"]
  cli --> model["Model provider"]
  cli -- "tool calls stream back" --> d(["Diffs you review"])
1Context

The Context Engine assembles project instructions, Git state, MCP servers and tool guides.

2Agent

The prompt goes to the agent's own CLI over ACP.

3Tools

Every tool call passes the permission engine and Workspace Trust.

4Diff

Edits arrive as before/after pairs you can review, stage or revert.

Context: the same starting point for every agent#

Before the first turn of a session, the Context Engine in the core builds one context pack. Each part comes from its own provider:

SourceWhat it adds
Project instructionsAGENTS.md, CLAUDE.md or .izcode/instructions.md (first match wins)
Git stateCurrent branch and changed or untracked files
MCP serversServers from .vscode/mcp.json and ~/.izcode/mcp.json, plus memory providers
Workspace foldersA note on each root when you work in a multi-root workspace
Tool guidesShort guides for the code index, browser, Git and Run and Debug tools, only when those tools are switched on
Agent MemoryPersona, scene index and wiki summary, when memory injection is on

The pack has a token budget. When it is too large, the engine trims from the end: optional parts first, then the list of changed files, then the tail of the instructions.

There are two ways to deliver the pack. An agent that accepts extra system-prompt text (Claude does) gets it there. Every other agent gets it as a preamble in front of your first message. Agents that already read CLAUDE.md or Git state themselves can declare that, so the same text is not sent twice.

@ mentions (files, tasks, wiki pages, skills, terminals and more) are resolved when you pick them and sent with that message, not with the session. You can see and switch off every source in Settings → Context Builder, which also shows the exact message an agent would receive. See Context Builder.

The agent: a CLI spoken to over ACP#

IZ Code does not call models itself. Each agent is an extension that starts the agent's own command-line program and registers it with the core. The core talks to it over the Agent Client Protocol (ACP): it opens a session, sends prompts, streams the agent's messages, thoughts and tool calls, and cancels a turn. A cancel goes straight to the agent, not to the back of a queue, so it stops the turn that is running.

Because agents are extensions, you install, update or remove them from the Extensions view, and each one signs in with its own account. Models and modes come from the agent; IZ Code shows what the agent reports. See Choose an agent and Bring your own agent.

Tools and permissions#

Agents act through tools. Some are the agent's own; others come from IZ Code through an MCP server the core gives every session: reading and editing files, running commands, the code index, memory, Git, the integrated browser, Run and Debug, and databases. All of them go through the same decision path:

  1. Session rules. A workflow step or a background task can carry its own fixed policy, such as read-only.
  2. Permission mode. izcode.agent.permissionMode sets the global default. deny is a ceiling that nothing below can loosen.
  3. Chat mode. The mode you pick in the agent's picker (for example, accept edits or bypass) decides whether edits and commands are asked about.
  4. Plan mode. In /plan, edits, deletes and commands are refused, not asked.
  5. Unattended sessions. A background task with no one watching is refused instead of waiting.
  6. Untrusted content. After a session reads untrusted content, outbound commands, new sites and third-party MCP tools are always asked about.
  7. Workspace Trust. Edits and commands in a folder you have not trusted are refused, even in an allow-all mode.

When IZ Code has to ask, the prompt appears inline in chat with Allow, Allow for this session and Deny. A session grant covers that kind of action for the rest of the session, for example npm run … or all file edits; risky programs such as rm, curl or shells are only granted for the exact command line. Agents never receive "always allow" from IZ Code, so no stale rule is written into an agent's own settings. See Permissions and tools.

Diffs and changesets#

File edits come back as before/after pairs stored by the Agent Host, so a diff still opens after a restart. In a Git repository the host also offers changesets:

  • Uncommitted changes and Branch changes for the whole session, with stage and revert per file or for everything.
  • Per turn. At the start and end of each turn the host snapshots the working tree as a Git tree, without touching your index or refs. You can see what one turn changed, or compare two turns.

Agent Host Protocol#

Chat in IZ Code is a client of the Agent Host Protocol (AHP), which the core serves. AHP keeps the state of every session and chat in one place and sends changes to each connected client. ACP faces the agent; AHP faces the UI.

AHP faces the UI, ACP faces the agent
flowchart LR
  w1["Chat window 1"] --> ahp["AHP: loopback WebSocket, token"]
  w2["Chat window 2"] --> ahp
  ext["External client"] --> ahp
  ahp --> host["Agent Host"]
  host -- "ACP" --> agents["Agents"]

What this gives you:

  • Several windows, one session. Two windows can watch and drive the same chat; a turn sent from one streams live in the other.
  • Forks and side chats. /fork or a side chat copies the history up to a turn into a new chat, for the same or another agent. ACP has no native fork, so the new chat receives the earlier conversation as context.
  • External clients. Settings → Agent Host can open a second listener for AHP clients outside IZ Code. It is off by default, listens on loopback only, uses port 47620 and requires a token.

Sessions survive the window#

Sessions belong to the core, not to a window. Closing a window does not stop an agent that is still working, and reopening the folder shows the session again.

Across an app restart:

  • Each finished turn is saved to a local SQLite database, so the chat history is there immediately.
  • The agent process itself is resumed (ACP session/load) only when you send the next message.
  • A turn that was running when the app quit shows as interrupted, with the part already received. The agent can still continue the session.

On an SSH host, peer or cloud workspace, the agent runtime runs on that machine, so closing IZ Code on your laptop does not stop it. See Remote and cloud.

Subagents and background work#

Agents can start subagents and long-running commands. IZ Code shows both the same way for every agent:

  • Subagent block. The tool call that starts a subagent appears as its own block, and you can open the subagent's chat in a tab. It is read-only.
  • Background work. A shell command started in the background, or a subagent still running after the turn ended, is listed on the chat with a Stop button.
  • Agent Map. A dialog that draws the tree of agents and subagents with duration, context tokens and status.

Agents report subagents in different ways, so IZ Code reads each one: Claude's subagent markers, standard ACP child sessions (Codex), plugin hooks, or the tool call alone when the agent says nothing more. Any agent can also start another agent, including a different one, through IZ Code's own spawn tool. Spawning a subagent never asks for permission unless your permission mode is deny, and nesting depth is limited. Token counts per subagent appear only when the agent reports them. See Subagents and background tasks.

Settings#

SettingValuesDefault
izcode.agent.permissionModedefault, ask, autoAllow, denydefault
izcode.ahp.server.enabledtrue, falsefalse
izcode.ahp.server.portPort number47620
Last updated: December 1, 2026Was this page helpful?