Перейти к основному содержимому

gRPC Contracts

The agent runtime exposes two gRPC services on each workspace pod. The orchestrator is the only client — user traffic never reaches the runtime directly.

AgentRuntime Service

Bidirectional streaming service for multi-turn agent conversations.

Converse RPC

rpc Converse(stream ConverseRequest) returns (stream ConverseEvent);

The orchestrator opens a bidi stream. Each ConverseRequest sends a user message; the runtime responds with a sequence of ConverseEvent messages ending with a DoneEvent.

ConverseRequest

FieldTypeRequiredDescription
session_idstringYesConversation correlation ID
messagestringYesUser message text
agent_idstringNoTarget a specific agent (empty = Manager routes)
system_promptstringNoOne-shot system prompt override
workspace_idstringFirst requestWorkspace identifier (reused from first request)
user_idstringFirst requestPlatform user identifier

ConverseEvent

A streaming event from the runtime. Exactly one variant is set per event.

VariantWhenFields
ChunkEventPartial text delta from agentagent_id, text
ThinkingEventReasoning step (extended thinking)agent_id, text
ToolCallEventTool invocation startingagent_id, tool, args_json, call_id
ToolResultEventTool invocation completedcall_id, result_json, error, error_message
DoneEventTurn complete (terminal)model, turns[]
UsageEventLLM token usage per callagent_id, model, prompt_tokens, completion_tokens, total_tokens, tool_use_prompt_tokens, thoughts_tokens, cached_tokens, call_sequence
Event ordering

The server emits zero or more ChunkEvent/ThinkingEvent/ToolCallEvent/ToolResultEvent events, followed by exactly one DoneEvent per input request. Multiple UsageEvents may be emitted per turn (one per LLM round-trip when tool calls happen).

DoneEvent Detail

FieldTypeDescription
modelstringLLM model used for this turn
turnsTurn[]Array of agent contributions

Turn

FieldTypeDescription
agent_idstringWhich agent produced this turn
textstringThe agent's response text

Memory Service

CRUD operations on workspace memory entries. This is a convenience facade — the actual data lives in the orchestrator's PostgreSQL database.

RPCs

RPCDescription
ListMemoriesQuery entries with optional category filter and pagination
CreateMemoryCreate or upsert a memory entry by key
DeleteMemoryDelete an entry by key

MemoryEntry

FieldTypeDescription
keystringStable identifier within (workspace, category)
contentstringMemory body text
categorystringPartition for grouping (e.g., "core", "daily", "conversation")
created_atTimestampCreation time
updated_atTimestampLast update time

ListMemoriesRequest

FieldTypeDescription
workspace_idstringRequired — workspace scope
categorystringOptional filter (empty = all)
limitint32Max entries (0 = server default 100)
offsetint32Pagination offset

CreateMemoryRequest

FieldTypeDescription
workspace_idstringRequired
keystringMemory key (upserts if exists)
contentstringMemory body
categorystringCategory tag

DeleteMemoryRequest

FieldTypeDescription
workspace_idstringRequired
keystringKey to delete

Authentication

Both services use the same HMAC bearer token in gRPC metadata:

  • Header: authorization: Bearer <token>
  • Token format: Base64URL-encoded payload + HMAC-SHA256 signature
  • Payload: Encodes user ID and workspace ID
  • Validation: Constant-time signature comparison on every RPC

Wire Rules

  • Bidi stream on an internal cluster port inside each workspace pod
  • Session correlation via session_id field, not a header
  • No field renumbers or deletions — proto evolution rules apply from day 1
  • Proto package: crawbl.agentruntime.v1

What's next: See the WebSocket Events for real-time client events, or the REST Endpoints for the HTTP API.