Skip to main content
Trinity
Guides/Creating and Managing Agents

Creating and Managing Agents

Everything you need to create, manage, and interact with Trinity agents: templates, lifecycle control, chat, terminal, files, logs, and configuration.

Creating Agents

Agents are created from templates or from scratch. Each agent runs as an isolated Docker container with its own filesystem, credentials, and MCP server configuration.

Template Sources

GitHub Template — A repository in github:Org/repo format. Supports branch selection with github:Org/repo@branch. Private repos require a GitHub PAT.
Admin-Configured Templates — GitHub repos configured by an admin in Settings. Metadata is fetched from each repo's template.yaml via the GitHub API and cached for 10 minutes. These appear as cards on the Templates page.
Local Templates — Auto-discovered from the config/agent-templates/ directory.
From Scratch — Creates a minimal agent with a default CLAUDE.md.

Template Structure

Every template follows a standard layout:

FilePurpose
template.yamlAgent metadata: display_name, description, resources, credentials, runtime
CLAUDE.mdAgent instructions and system prompt
.mcp.json.templateMCP config template with ${VAR} placeholders for credential injection
.env.exampleExample credentials file listing required environment variables

Runtime options: claude-code (default) or gemini-cli, set via runtime.type in template.yaml.

Template selection page showing available agent templates as cards

Creation Flow

When you create an agent, Trinity performs these steps in order:

1

Template is cloned (GitHub) or copied (local/from-scratch).

2

base_image is validated against the allowlist. Only trinity-agent-base:* is permitted by default.

3

A Docker container is built from the base image.

4

Template files are copied into /home/developer/ inside the container.

5

Credential requirements are extracted from .mcp.json.template.

6

If API subscriptions exist, one is auto-assigned via round-robin (fewest agents first).

7

The agent starts automatically and is labeled for fleet management.

Creating via UI

1

Click Create Agent on the Dashboard or Agents page.

2

Select a template source. GitHub templates display as cards with metadata from template.yaml.

3

Enter an agent name (lowercase, hyphens only).

4

Click Create.

Create agent dialog showing name input and template selection

Creating via API and MCP

REST API:

POST /api/agents
Content-Type: application/json
Authorization: Bearer <token>

{
  "name": "my-agent",
  "template": "github:Org/repo@branch"
}

MCP tool:

create_agent(name="my-agent", template="github:Org/repo@branch")

What Agents Inherit

The CLAUDE.md from the template as their system prompt
MCP server configuration from .mcp.json.template, with placeholders resolved at runtime
Any files in the template repository, copied to /home/developer/

Limitations

Agent names must be unique, lowercase, with hyphens allowed. No spaces or special characters.
The base_image must match the configured allowlist. Requests for blocked images return HTTP 403.
Private GitHub repositories require a GitHub PAT to be configured before use as a template source.
Template metadata from GitHub is cached for 10 minutes. Changes to template.yaml may not appear immediately.

Managing Agents

Control the lifecycle, health, and resources of your Trinity agents through the UI, API, or MCP tools.

Start and Stop

Toggle an agent between Running and Stopped using the switch on the Dashboard, Agents page, or Agent Detail page. A loading spinner displays during state transitions.

API: POST /api/agents/{name}/start and POST /api/agents/{name}/stop

MCP: start_agent(name) and stop_agent(name)

Rename

Click the pencil icon next to the agent name on the Agent Detail page to edit inline. Renaming is atomic: it updates the database, renames the Docker container, and broadcasts the change via WebSocket. System agents cannot be renamed. Only owners and admins have permission.

API: PUT /api/agents/{name}/rename with body {"new_name": "new-name"}

Delete

Use the Delete button on the Agent Detail page. A confirmation dialog is required. Deletion cleans up the container, network, sharing records, schedules, activities, and event subscriptions.

Health and Status

The agent header displays status (Running/Stopped), CPU and memory usage, network I/O, and uptime. Telemetry auto-refreshes every 10 seconds. Fleet-wide monitoring is available at GET /api/monitoring/fleet-health. Health levels: healthy, degraded, unhealthy, critical, unknown.

Resource Allocation

Configure per-agent memory and CPU limits in the Config tab. Execution timeout is configurable per agent (range: 60–7200 seconds, default: 900 seconds / 15 minutes).

Listing

The Agents page shows horizontal row tiles with success rate bars. Filter by name, status, or tags. The Dashboard offers a network graph view and a timeline view.

Agent detail tasks tab showing execution history

Agent Chat

The Chat tab in Agent Detail provides a bubble UI for conversing with agents, with persistent history and real-time status updates.

Key Concepts

Chat Session — A conversation thread stored in the database. Each agent can have multiple sessions.
Dynamic Thinking Status — Real-time labels showing what the agent is doing (e.g., “Reading files...”, “Running tests...”). Maps tool names to human-readable labels with 500ms anti-flicker.
Playbook Autocomplete — Type / in the chat input to trigger a dropdown of available playbooks with ghost text showing command syntax and argument hints.
Continue as Chat — Resume a completed or failed execution as an interactive chat, preserving the full context via Claude Code's --resume flag.

How It Works

1

Open an agent's detail page and click the Chat tab.

2

Select an existing session or click New Chat.

3

Type a message and press Enter. The status label updates in real-time.

4

The response appears as a chat bubble with cost and token tracking.

Voice Chat

Click the microphone button to start a voice session. Audio streams bidirectionally through the backend WebSocket proxy to Gemini 2.5 Flash Native Audio (~280ms latency). Transcripts are auto-saved to the chat session with source="voice" markers. Requires GEMINI_API_KEY configured on the platform.

Session Management

Sessions persist across container restarts. Context window tracking shows token usage (e.g., “45.5K / 200K”). Session cost tracking shows cumulative cost across the conversation.

Agent chat interface with message bubbles and real-time status

Chat API Endpoints

EndpointMethodDescription
/api/agents/{name}/chatPOSTSend chat message
/api/agents/{name}/chat/sessionsGETList all sessions
/api/agents/{name}/chat/sessions/{id}GETGet session with messages
/api/agents/{name}/chat/sessions/{id}/closePOSTClose session

Agent Terminal

Browser-based xterm.js terminal providing direct access to the agent's Claude Code TUI, with mode switching between Claude, Gemini, and Bash.

1

Open the agent detail page and click the Terminal tab.

2

The terminal connects via WebSocket to the agent container's PTY.

3

A mode toggle in the header switches between Claude (Claude Code interactive mode), Gemini (Gemini CLI, requires GEMINI_API_KEY), and Bash (raw shell access).

4

The terminal supports resize and adapts to the browser window dimensions.

SSH Access

Generate ephemeral SSH credentials via the API or MCP. ED25519 keys with configurable TTL. SSH ports: 2222–2262 (incrementing per agent). API: POST /api/agents/{name}/ssh-access. MCP: get_agent_ssh_access(name).

Agent Files

Two-panel file manager in the Agent Detail Files tab for browsing, previewing, and editing agent workspace files.

1

Open the agent detail page and click the Files tab.

2

The left panel displays a file tree with search; the right panel shows a preview of the selected file.

3

Supported previews: images, video, audio, PDF, and text files.

4

Click the edit button on any text file to modify and save inline. Delete files directly with protected path warnings for critical files.

5

Toggle Show hidden files to reveal dotfiles. The agent workspace root is /home/developer/.

Agent file browser showing two-panel layout with file tree and preview

Content Folder Convention

The content/ directory is gitignored by default. Use it for large generated assets such as images, audio, and video.

Shared Folders

Agents can expose their workspace folder for other agents to mount as a collaboration mechanism. Configure in the agent's Sharing tab using the Expose and Consume toggles. Permission-gated: only permitted agents can mount a shared folder.

Shared folder configuration with Expose and Consume toggles

Logs and Telemetry

Container Logs

Open the agent detail page and click the Logs tab. A fixed-height scrollable container displays Docker container stdout/stderr. Logs auto-refresh with smart auto-scroll: new content scrolls to the bottom automatically, but scrolling stops if you scroll up manually.

Live Telemetry

The agent header bar displays live resource metrics: CPU usage, memory (MB), network I/O (bytes in/out), and uptime. Metrics auto-refresh every 10 seconds.

Centralized Logging via Vector

All container logs are captured by the Vector log aggregator and written to structured JSON files:

Platform logs: /data/logs/platform.json

Agent logs: /data/logs/agents.json

OpenTelemetry

Claude Code agents export OTel metrics including cost, token usage, and productivity. These metrics are available on the Dashboard.

Agent Configuration

Per-agent settings for autonomy, read-only mode, resources, capabilities, execution timeout, and runtime.

Autonomy Mode

Master toggle that enables or disables all scheduled operations for an agent. Toggle from the Dashboard, Agents page, or Agent Detail view. When disabled, all schedules for that agent are paused.

Read-Only Mode

Prevents modification of source files (*.py, *.js, etc.) inside the agent container. Uses PreToolUse hooks to intercept Write, Edit, and NotebookEdit tool calls. Allowed patterns: output/*, content/* (generated files are permitted).

Execution Timeout

Configurable time limit for agent executions. Range: 60–7200 seconds (default: 900 seconds / 15 minutes). Applies to all trigger methods: task, chat, schedule, MCP, and paid endpoints.

Per-Agent API Key

Toggle between the platform API key and your own Claude subscription in the Terminal tab. The agent container is recreated when this setting changes.

Model Selection

Choose the Claude model used for tasks and scheduled executions. Available models: Opus 4.5/4.6, Sonnet 4.5/4.6, Haiku 4.5. Custom model input is supported. The model_used field is recorded in the execution audit trail.

Agent info panel showing slash commands, capabilities, and configuration