Skip to content
Agent Types

Agent Types

Core request/response types and message structures for agent execution. Serves as the data model layer between the orchestrator and the container runner.

Package: internal/agent

Types

AgentRequest

Input sent to the agent runner.

FieldTypeDescription
SessionIDstringPersistent session ID for resuming context
ForkSessionboolFork session on first thread message (thread isolation)
Messages[]AgentMessageConversation history (oldest-first)
SystemPromptstringCustom system prompt override
ChannelIDstringChat channel or thread ID
AuthorIDstringID of user who triggered the request
DirPathstringWorking directory for the container
ParentDirPathstringParent working directory (for worktree containers)
PlanModeboolEnable plan mode
PromptstringCurrent user prompt
OnTurnfunc(string)Callback for each assistant text turn during streaming
OnToolUsefunc(name, input string)Callback for each tool invocation
OnActivityfunc(activity, detail string)Callback for model detection and system events

AgentMessage

Single message in conversation history.

FieldTypeDescription
Rolestring"user" or "assistant"
ContentstringMessage text

AgentResponse

Output returned by the agent runner.

FieldTypeDescription
ResponsestringFinal text response
SessionIDstringUpdated session ID for resuming next turn
ErrorstringError message if run failed
DurationMsintTotal execution time
NumTurnsintNumber of assistant turns
StopReasonstringWhy the agent stopped (e.g. "end_turn")
ModelstringModel used (e.g. "claude-opus-4-6")

BuildPrompt

AgentRequest.BuildPrompt() returns the effective prompt for the request:

  • Session resume with prompt — returns only the new Prompt (avoids redundancy)
  • Session resume with messages — returns only the last message’s content
  • No session — returns all messages formatted as "role: content\n"

Callback-Driven Streaming

All callbacks are optional (nil-safe):

  • OnTurn — fired on each assistant text turn (used for streaming to chat)
  • OnToolUse — fired on each tool invocation (e.g. Bash, Read, Edit)
  • OnActivity — fired for model detection and subagent progress

Usage

ConsumerPurpose
internal/container/runner.goExecutes agent in Docker via Runner.Run(*AgentRequest) → *AgentResponse
internal/orchestrator/orchestrator.goBuilds requests from message history, executes with streaming
internal/orchestrator/executor.goExecutes scheduled tasks, creates threads on first turn

Related docs