SDK Wire Protocol
Status: Current — the authoritative specification of the current wire protocol, followed jointly by the main repo, the Agent, and every SDK.
This document defines the wire protocol conventions on top of Croupier's current shared session runtime, to be followed jointly by the main repository, the Agent, and the per-language SDKs.
Document positioning
This document describes:
- framing
- headers
- request/response multiplexing rules
subprotocolidentification- the boundary between the protobuf protocol layer and the JSON payload layer
This document no longer treats the historical gRPC or the legacy messaging pattern as the standard baseline.
shared session runtime
The two internal links share one transport runtime:
Agent <-> ServerSDK <-> Agent
The shared capabilities include at least:
tcp- optional
tls 4-byte frame length + 8-byte croupier header + protobuf body- bidirectional request/response on a single connection
- multiplexing of multiple in-flight requests
- heartbeat
- reconnect
- drain
- backpressure
This shared foundation is the shared session runtime.
subprotocol
subprotocol here is not personalization configuration; it means "application-layer subprotocols that run on the same session runtime but differ in handshake and business semantics".
The main repository currently has two core subprotocols:
sdk-agent subprotocol- the first frame must be
ProviderConnectRequest tlsis not enabled by default; the Agent side can enable local-gateway TLS via thetls:section ofagent.yaml(TLS sits under the framing, the frame format is unchanged, and SDKs need a TLS dial option to connect)- targets the provider session
- the first frame must be
agent-server subprotocol- the first frame must be
RegisterRequest tlsis enabled by default- targets the agent session
- the first frame must be
v1 first-frame identification rules
v1 does not introduce a separate Magic; the first application-layer message identifies the subprotocol directly.
Why:
- the listen-port boundary is already explicit, so no multi-protocol probing is needed
Version + MsgIDis enough to tell whether the first frame is legal- once framing is corrupted, the safest policy is to disconnect and reconnect rather than keep guessing at boundaries in a broken stream
Rules:
- read the complete first frame according to
FrameLength - parse the 8-byte header
- validate
Version - use
MsgIDto check whether the first frame fits the current listen boundary - parse the protobuf body
- if any condition fails, close the connection immediately
Frame format
+--------------+------------------+-----------+
| FrameLength | Croupier Header | Body |
| 4 bytes | 8 bytes | N bytes |
+--------------+------------------+-----------+Constraints:
FrameLengthis an unsigned 32-bit big-endian integerFrameLengthis the total length of the followingHeader + Body- single-frame length must be bounded by both sides' maximum-frame configuration
- framing only frames; it does no business protocol detection
Header format
The current unified 8-byte header:
+---------+------------+-----------------+
| Version | MsgID | RequestID |
| 1 byte | 3 bytes | 4 bytes |
+---------+------------+-----------------+Constraints:
Version: currently0x01(the accepted window is[MinSupportedVersion, Version1]; see Version policy below)MsgID: 24-bit unsigned, big-endianRequestID: 32-bit unsigned, big-endianBody: protobuf-encoded
Version policy
The wire protocol uses a version window rather than a single fixed byte, so a server upgrade does not force every long-running game process to redeploy at the same moment.
- Current version:
0x01(protocol.Version1). - Oldest accepted version:
0x01(protocol.MinSupportedVersion). This is the N-1 compatibility floor; whenVersion1is bumped, keep the previous value here during the transition window. - A frame whose
Versionis outside[MinSupportedVersion, Version1]is rejected per-request: the receiver answers with anInvokeResponsewhose payload is{"error":"unsupported protocol version: N","supportedVersions":[...]}and keeps the session alive. It does not disconnect the whole connection. - Only request frames (
IsRequest) get a rejection response; unsupported response/event frames are skipped because there is no request to answer. protocol.IsSupportedVersion/protocol.SupportedVersionsexpose the window to bothinternal/transport/tcp(Agent/Server inbound) and the Go SDK transport, keeping both sides on the same rule.
N-1 compatibility and deprecation schedule
The compatibility window is deliberately narrow but real: a peer running the previous wire version (N-1) keeps working while the platform deploys N.
Boundary — the window is inbound-only. Each side writes outbound frames with its own current version (protocol.Version1), and the v1 wire has no handshake to negotiate a common version. A mixed session therefore works in one direction only: the N-side accepts and answers N-1 requests, but its responses (written as N) fall outside the N-1 peer's window and are dropped there — including rejection responses, which are also written with the local current version. Until a negotiation handshake exists, bumping the wire version requires game-side SDKs to roll at least in step with the server; the window buys graceful per-request rejection with supportedVersions diagnostics on the inbound path, not transparent mixed-version operation.
| Transition | Policy |
|---|---|
Version1 bump to N | Set MinSupportedVersion = N-1; keep the old version accepted for one release cycle |
| During the N-1 window | Inbound: unsupported frames are rejected per-request and the session stays alive (supportedVersions tells the peer the exact window). Outbound: frames are always written with the local current version, so an N-1 peer cannot read N-side responses — see the boundary above |
| Deprecation (end of window) | Remove the old version from the window; peers on it then receive per-request rejections |
| Deprecation schedule | Current: no deprecation yet (MinSupportedVersion == Version1); N-1 policy applies to the next version bump and is documented here at that time |
Request-response rules
Unified rules:
- odd
MsgIDs mean request - even
MsgIDs mean response - responses must echo the original request's
RequestID - each initiator maintains its own incrementing
RequestIDcounter - multiple concurrent in-flight requests are allowed on one connection
Notes:
responseMsgID = requestMsgID + 1remains the default convention- one-way event messages like
TaskEventare not part of the standard request/response pairing
Synchronous call timeout: the metadata timeoutMs convention
The caller's declared budget for one synchronous call (milliseconds, decimal string), placed in the invoke request's metadata map and propagated end to end; each hop applies min(its own configured cap, the declared value) (the natural min semantics of a Go context deadline):
| Layer | Behavior |
|---|---|
| HTTP API | request-body timeoutMs (optional) → injected into metadata["timeoutMs"] |
| Server dispatch | requestTimeoutBudget: clamp [1000, 60000], tightens the ctx; the global default 15s serves only as a ceiling |
| Agent | providerCallDeadline: clamp [1000, the Agent's configured cap], min'd with the default (agent.invokeTimeoutMs, default 15000) |
- Garbage values / missing → each hop falls back to its own default, no error (zero intrusion)
- A hard ceiling of 60s on the synchronous channel: longer operations belong in async tasks (the event-stream semantics)
- Semantic correction: the Agent's old hardcoded 10s sat inverted against the Server's 15s default; now aligned and configurable
Overload feedback and backpressure status
Layered by connection role, the current implementation status (the dual lanes have landed; see next section):
| Path | Mechanism | Backpressure semantics |
|---|---|---|
Server → Agent/Provider (transport/tcp/server.go) | Dual-lane bounded dispatch (CR-FIX-09): business lane = bounded worker pool capped by MaxInflightRequests, control lane = dedicated queue + one worker | Fail-fast: a full business queue answers an inline busy error frame (Invoke only); control frames are never rejected; the per-request deadline bounds slow handlers |
SDK → Agent (per-language SDK inbound; the Go baseline tcp_client.go) | A bounded worker pool (default NumCPU, queue workers×4) + a Go control lane | Fail-fast: when the business queue is full, an inbound queue full, retry on another instance error frame returns immediately returned to the caller verbatim; nothing accumulates in memory. Busy is terminal — no automatic cross-instance retry (see the delivery-semantics matrix below) |
Agent↔Server, Agent↔Provider (transport/tcp/mux_conn.go) | Dual-lane bounded dispatch (dispatchInbound): a dedicated system-lane queue (64) + one worker; the business lane gets NumCPU workers + a bounded workers×4 queue | When the business lane fills, a busy error frame returns inline (peer failover); the control lane never rejects (when full it blocks the read loop = natural control-plane backpressure) |
Known boundaries:
- Explicit overload signal fields like
overloaded/retry_after_ms/too_many_inflighthave no wire messages yet; the only overload signal today is the error payload text when the business queue is full - The dual lanes have landed: Go (
MuxConn+ the Go SDK), Python (transport/tcp.py, a control-lane single worker that never rejects), JS (tcp_transport.ts, a control queue + a single-concurrency loop). Java (controlPool), C++ (control_pool_) and C# (_controlLimiter) landed the same never-reject control lane (2026-11), so all six SDKs now classify inbound into control/business lanes
The dual lanes: control-message priority
One structural premise of overload governance: control messages must not share a lane with business messages. When a business flood fills the shared queue, heartbeats get fail-fast rejected → the peer judges the session dead → overload escalates into a connection avalanche; a drain signal gets buried → graceful shutdown becomes impossible under overload.
Inbound dispatch is therefore classified into two lanes by explicit MsgID (protocol.IsControlRequest(), an explicit set rather than a raw byte prefix — within the 0x06 cluster family, Hello is control and ForwardInvoke is business):
| Lane | Messages | Queue semantics |
|---|---|---|
| System (control) | 0x01xx Register/Heartbeat, 0x05xx Provider session control (including Drain), 0x060101 ServerHello | A small dedicated queue, never rejected |
| Business | 0x03xx Invoke/Task, 0x04xx Ops/Metrics, 0x060103 ForwardInvoke | A bounded queue; when full, fail-fast returns an error frame to the caller (never an automatic instance switch) |
| Events | One-way frames like TaskEvent/MetricEvent | Inline in the read loop, not queued (status quo kept) |
Behavioral guarantees:
- When the business lane is saturated, heartbeats/drain/register still get through — session liveness and draining are unaffected by business overload
- The system lane is itself bounded (so the control plane cannot be flooded), but its capacity is independent and it never returns reject to the peer
- The fail-fast reject semantics apply only to business requests; the
retry on another instancewording is unchanged
Implementation locations: MuxConn.dispatchInbound (internal/transport/tcp/mux_conn.go, Config DispatchWorkers/BusinessQLen/ControlQLen, defaults NumCPU / workers×4 / 64) and the Go SDK's handleInboundRequest (sdks/go/pkg/croupier/transport/tcp_client.go, ctrlInbox capacity 64 + one worker). Tests: mux_conn_dual_lane_test.go, dual_lane_test.go.
Delivery semantics matrix
Per message class: the delivery guarantee the platform makes today, the idempotency key, and what happens under backpressure. The dispatch layer (internal/platform/dispatch) is the only place that decides whether a failure may be retried on another instance, and its rule is deliberate and narrow: failover only on errAgentUnreachable — delivery provably did not reach the previous candidate (no session, forward also failed). Any response that completed a protocol round trip — including busy rejections and application error payloads — is returned to the caller verbatim, with no automatic cross-instance retry.
The reason is non-idempotency safety: a busy rejection after delivery ("this instance is saturated") is not the same event as "the instance is unreachable". Silently re-sending a mutating Ops command to the next candidate would be an implicit-duplicate execution entry point — the command may already have started on the first instance. Whether a retry is safe is therefore the caller's decision, made with the caller's own idempotency story. The busy text retry on another instance is advice to that caller, not a description of platform behavior.
| Message class | Wire messages | Delivery semantics | Idempotency key | Under business-queue saturation |
|---|---|---|---|---|
| Control (session) | Register / Heartbeat / ProviderConnect / Drain, ServerHello | Idempotent by design; periodic re-send is the mechanism (at-least-once safe) | Peer identity + message kind; no user payload | Never rejected — dedicated control lane |
| Function invoke | InvokeRequest | At-most-once per dispatch attempt; no automatic cross-instance retry | Caller-supplied metadata["idempotencyKey"] is propagated end to end; the platform does not dedupe — contract authors own replay safety | Busy error frame returned verbatim to the caller |
| Async task start | StartTaskRequest | At-most-once delivery per candidate (failover only when delivery provably did not reach the previous candidate); each attempt gets its own task_runs row and failed attempts are marked failed | Server-generated taskId per attempt; a caller metadata["taskId"] marks a drain-safe continuation | Empty-body response frame returned verbatim; no cross-instance retry |
| Task cancel | CancelTaskRequest | Best-effort at-most-once, routed to the owning agent only (never re-picked) | taskId | Empty-body response frame; the outcome is authoritative from the owning agent only |
| Task events | TaskEvent | At-least-once reads: the server event store assigns per-task ordering; consumers replay via StreamTaskAfterSeq and dedupe by it | Server-side per-task sequence (afterSeq), not a wire field | n/a (server-side event store, not an inbound queue) |
| Ops / mutating commands | Ops-role functions dispatched as invoke/task requests (capture/synthetics/devops) | Default at-most-once; high-risk operations additionally pass the platform approval workflow (two-person rule) before dispatch is reached | Approval record + taskId | Same as invoke/task: busy never auto-fails over |
Known boundaries (stated, not hidden):
- The wire has no platform-level dedup:
metadata["idempotencyKey"]is a propagation convention. Exactly-once business effects still require game-side receipts/deduplication as a separate contract TaskEventordering is a server-side store sequence, not a wire field; the one-way frame carries noseq, so event consumers must rely onStreamTaskAfterSeqreplay rather than in-frame ordering- Busy and handler-error responses are encoded per-RPC (AUD-002): Invoke carries
{"error":...}inInvokeResponse.payload; RPCs with a failure channel (Success/Message/Error/GetTaskResult.State) get a typed failure with the message; RPCs whose wire response type has no failure channel (ListProcesses/ListServices/ListCronJobs/GetSupervisorLog/GetSystemInfo/StartTask/Heartbeat/Register) cannot express the error and return an empty body — the transport logs the real error and the caller sees the zero value. The error text is always JSON-encoded with the standard encoder, so quotes/backslashes/newlines in the error never break the document. Explicitoverloaded/retry_after_mswire fields remain undefined - Regression tests pinning the busy-never-fails-over rule:
internal/platform/dispatch/dispatcher_delivery_semantics_test.go
Provider handshake auth
The SDK → Agent ProviderConnectRequest carries an auth token in its metadata map under the reserved key authToken. The Agent consumes the key for handshake auth and never stores it in session metadata (it cannot leak onto the SDK distribution page); user-declared authToken entries are dropped as reserved keys.
- SDK side: every language's client config exposes
authToken; when set, the connect frame carriesmetadata["authToken"](trimmed). All six SDKs do this identically. - Agent side:
agent.providerAuth.require+agent.providerAuth.tokenin the agent config.require=false(the default) ignores the token entirely — handshakes behave exactly as before.require=truerejects handshakes with a missing or mismatched token: the connection is closed and no session is registered (fail-closed).require=truewith an empty token is invalid config and fails at startup — otherwise every handshake would be rejected. - The token comparison is constant-time, and enforcement runs on both connect paths (the TCP local gateway and the mux-path handler), before any session registration.
Tests: agent enforcement in internal/agent/provider_auth_test.go; per-SDK send-side tests in each SDK's suite.
drain semantics
drain is session-level graceful traffic removal, not an immediate-disconnect semantic.
Unified definition:
- no new business requests are assigned to the session
- in-flight requests may keep completing within the grace period
- the connection closes or the session invalidates only after the drain completes or the grace expires
Minimal behavioral constraints:
- the session enters the
drainingstate - arriving requests are rejected, rerouted, or answered with an explicit
draining/retry_after_ms - in-flight requests may continue executing
- heartbeats continue
- once the grace expires, remaining requests may be force-closed
Boundary notes:
drainis not ordinary backpressuredraindoes not mean canceling every in-flight request- during
drain, session-governance control messages can still be exchanged
Implementation status (ARCH-016, 2026-10-30):
- The Agent implements the
drainingstate onProviderSession(agents/sidecar/provider_session.go):Draining/SetDraining/Inflight/AddInflight.callProvider(internal/agent/local_handler.go) skips draining sessions for new business requests and rejects with an explicitprovider <id> is draining (retry after <N>ms)when the targeted session or all function-matching sessions drain. Task continuations (aStartTaskaccepted before drain) are still routed to their draining provider — drain must not cut off work already assigned. - The shared
LocalHandler.DrainProviderSessionmarks targets draining, removes their agentlocal instances (legacy address-dial no longer routes), and waits for in-flight to reach zero or the grace to expire; theProviderDrainResponseACK is returned only after that point.gracedefaults todefaultDrainGrace(30s) and is overridden byretry_after_ms. - The Server routing gate:
reg.AgentSession.Drainingis set/cleared byopsNodeDrain/opsNodeUndrainviaSetAgentDraining;Dispatcher.agentCanInvokereturns false for a draining agent, so new requests are no longer assigned to the node.UpsertAgentcarriesDrainingover across session refresh (heartbeat/reconnect does not silently un-drain). - Undrain is expressed with the
ProviderDrainRequest.reasonsentinel__undrain__(protocol.ProviderDrainReasonUndrain), sent byopsNodeUndrainand honored by both drain paths.
Known boundaries (honest):
- Force-close after the grace expires (constraint 5) is not implemented: remaining requests are not cancelled; a still-running task converges via the ARCH-015 D3
unknown/terminal-event path, and the drain ACK is returned at grace expiry. - Undrain clears the
drainingflag but does not repopulate the agentlocal instance table; a drained provider's legacy address-dial routing resumes only after the provider re-registers or heartbeats its functions. - The
reason == "__undrain__"sentinel is used because the system protoc (3.21.12) produces bad gencode and no 34.x protoc is available; a dedicatedundrainproto field is a follow-up when protoc 34.x is available.
Message families
0x01xx Agent Session Control
The session control messages of the agent-server subprotocol; the current proto names are still:
RegisterRequestRegisterResponseHeartbeatRequestHeartbeatResponseRegisterCapabilitiesRequestRegisterCapabilitiesResponse
Semantically this group should already be read as "agent session connect/register", not the historical callback model.
The agent-server subprotocol should also carry session-level drain capability:
- the
Servercan put a specificAgent sessionintodraining - the
Dispatcherno longer assigns new requests to that session - in-flight requests keep completing within the grace period
- the connection closes or the session is removed only after the drain completes
0x02xx Client / Result query
Reserved for SDK-visible control messages such as client registration and job-result queries.
0x03xx Invocation / Task
For synchronous calls, async tasks, and cancellation:
InvokeRequestInvokeResponseStartTaskRequestStartTaskResponseStreamTaskRequestTaskEventCancelTaskRequestCancelTaskResponse
0x04xx Ops / Telemetry
The message family for system info, metrics, and operational control.
0x05xx Provider Session
The provider session control messages of the sdk-agent subprotocol:
| MsgID | Name | Notes |
|---|---|---|
0x050101 | ProviderConnectRequest | Establish a provider session |
0x050102 | ProviderConnectResponse | Return session_id, negotiation results, and warnings |
0x050103 | ProviderHeartbeatRequest | Provider heartbeat |
0x050104 | ProviderHeartbeatResponse | Heartbeat response |
0x050105 | ProviderDrainRequest | The Agent puts the provider session into draining |
0x050106 | ProviderDrainResponse | The provider acknowledges entering drain |
ProviderConnectResponse field semantics:
session_id: the provider session identifier, reused by later heartbeats and invokesaccepted_capabilities: the capability list the Agent acceptedwarnings: a non-blocking list of warning strings. Two current sources — scope-drift detection (when the provider-reportedgame_id/envdisagrees with the Agent configuration,game_id mismatch/env mismatchis written, easing diagnosis of scope misconfiguration when multiple services share an Agent), and instance-metadata reserved-key conflicts (next section; writesmetadata key %q is reserved and dropped)
Instance metadata: ProviderConnectRequest.metadata
At registration a provider may attach user-defined multi-KV instance metadata to the first frame (e.g. serverId, pod), used by the SDK version distribution page and metadata-based instance search (the REST endpoint GET /api/v1/providers/sdk-stats?metaKey=&metaValue=).
The data path:
SDK 配置(Go InstanceMetadata / JS providerMetadata)
→ ProviderConnectRequest.metadata(map<string,string>, field 13)
→ Agent 合并:保留键冲突丢弃 + warnings 告警;空键跳过
→ agentlocal.Instance.Metadata
→ AgentProcess.metadata(field 11)随 RegisterRequest 上报 server
→ registry ProviderSession / ProviderSessionSnapshot
→ sdk-stats REST API(服务端子串过滤)→ web SDK 版本分布页The sdk-stats instance detail (SdkInstanceItem) exposes both firstSeenUnix (registration time, #44; server-normalized: falls back to lastSeenUnix when no observation exists) and lastSeenUnix. firstSeenUnix has process-window semantics — registry sessions are in-memory, so they re-accumulate from zero after session expiry or a server restart (consistent with the runtime-sources boundary below).
Rules:
- Reserved keys:
sdkLanguage/sdkVersion/sdkName/protocol_version/gameId/envare platform-fixed fields (the Agent derives them from the request's fixed fields). When user metadata collides, the Agent drops the key and writes a warning — it must not overwrite platform semantics; empty keys are skipped - Observation only, never routing: metadata is used only for display/search/diagnostics; load balancing and function routing must not read it (matching the proto comment "observability only, never routing")
- Older SDKs that never send the field are fully compatible; when unconfigured, an empty map is not sent on the wire (nil/omitted on both Go/JS)
Storage and query design conclusions (persisted; landed in #11):
- Online provider sessions are ephemeral in-memory data (kept alive by heartbeat TTLs); instance metadata is additionally persisted in an EAV table (migration 0034,
provider_metadata):(game_id, env, service_id, meta_key, meta_value)+UNIQUE(game_id, env, service_id, meta_key)+INDEX(meta_key, meta_value)— portable across the sqlite/mysql/postgres dialects, dependent on no JSON query extensions. It refreshes wholesale after every successful agent registration (upsert current values + delete rows for services that vanished this round; an unchanged duplicate registration skips the write amplification), and session-expiry cleanup deletes the corresponding rows; the table's row set follows the registered sessions, so dropdown options and aggregate queries still have a source after a restart - The aggregate query =
GET /api/v1/providers/meta-options(scoped group): the server returns distinct keys → value sets (including per-value instance counts, values sorted by count descending) for the current game scope, with a 30s in-process cache invalidated on registration — the filter dropdown's options are server-provided (#2); the frontend must not derive them from the (already-filtered) list data - Search = the server applies an in-memory linear filter over the snapshot (
metaKey/metaValuesubstrings, case-insensitive; a value condition matches both the key name and the wholek=vpair) + frontend instance-keyword matching; the scale (instances per agent session) is far below anything that needs an index - DB-less (in-memory registry) degradation: with no database, aggregation computes on the fly from the online session snapshot and is lost on restart — see the deployment-shape differences
Historical aliases such as RegisterLocalRequest, RegisterLocalResponse, and HeartbeatLocalRequest belong to compatibility semantics only and should not appear in new design documents.
The semantics of ProviderDrainRequest / Response should unify as:
- the
Agentno longer assigns new requests to that provider session - the provider keeps completing the in-flight requests it has received
- the provider's
ProviderDrainResponsemeans only "the drain state was accepted" - the actual connection close happens after the drain completes or the grace expires
0x04012D..0x040135 Devops session relay (AGENT-002)
Interactive devops terminal sessions (SSH today) proxied panel → server → devops agent. Downlink requests travel the agent's bidirectional control connection (MuxConn); uplink output/end frames are one-way event frames (IsEvent set, reqID 0 — no response frame):
| MsgID | Name | Direction | Notes |
|---|---|---|---|
0x04012D | DevopsSessionOpenRequest | server→agent | operator is the server-authenticated identity (audit truth) |
0x04012E | DevopsSessionOpenResponse | agent→server | ok=false + error carries the honest refusal reason |
0x04012F | DevopsSessionInputRequest | server→agent | keystrokes; refusal busy = agent input queue full |
0x040130 | DevopsSessionInputResponse | agent→server | ok=false + error="busy" maps to REST 429 session_busy |
0x040131 | DevopsSessionResizeRequest | server→agent | pty window change (cols × rows) |
0x040132 | DevopsSessionResizeResponse | agent→server | — |
0x040133 | DevopsSessionCloseRequest | server→agent | panel-initiated close, reason is audit-recorded |
0x040134 | DevopsSessionCloseResponse | agent→server | — |
0x040135 | DevopsSessionEvent | agent→server | one-way event: kind=output chunks (≤ CastChunk) or kind=end |
Contract invariants:
- Truth stays on the agent: allowlist admission, audit-first gate, asciicast archiving, and input backpressure all run in the agent-side Broker/Hub chain; the relay adds no second source of truth.
operatorin the open request is filled by the server from its authenticated session and the agent audit chain records it verbatim — clients never self-report identity kind=endoutcomes:closed(clean close),eof/error(channel teardown),cast-broken(archive failure — the session still ran), andagent_disconnected(synthesized server-side on control-plane loss)- Control loss = session-plane down: when the control connection drops, the agent closes all live sessions (
OnConnClosed) and the server collapses that agent's proxied sessions symmetrically — a panel without an auditable channel does not keep interactive sessions alive. After a reconnect the panel must open a fresh session; sessions never survive across connections - Server-side fanout is bounded: a replay ring (last 256 events) plus per-consumer bounded queues; a consumer that cannot keep up is evicted (stream ends with an
overflowend frame) — the session, its archive, and other consumers are unaffected
Business payload rules
Two layers must be clearly distinguished:
- the protocol message layer
- protobuf
- for session, routing, capability negotiation, and job control
- the business payload layer
- UTF-8 JSON by default
- generally carried in
bytes payload
The v1 default rules:
InvokeRequest.payloadis JSON bytesInvokeResponse.payloadis JSON bytesTaskEvent.payloadis JSON bytes- SDK users do not need to define a
.protofirst to integrate - SDKs should provide automatic native-object ↔ JSON bytes encoding/decoding by default
Field layering rules
Which layer a field belongs to is not judged by "does it look like a business field" but by "who needs to understand it".
Rules:
- Fields the Agent must understand, route, govern, or negotiate go in the protobuf protocol layer
- Fields consumed only by the concrete business function go in the JSON payload layer
- Hiding platform control fields inside the JSON payload and asking the Agent to guess is forbidden
Typical protobuf fields:
function_idsession_ididempotency_keytraceId- W3C trace propagation is detailed in
docs/architecture/sdk-otel-propagation.md(SDKs propagate only, never export)
- W3C trace propagation is detailed in
gameIdenvtimeoutMs- capability-negotiation, rate-limiting, retry, and audit-related fields
Typical JSON payload fields:
player_idban_reasondurationguild_iditem_count
Schema rules
inputSchema / outputSchema (proto field names input_schema / output_schema) describe, on the default path, the JSON Schema of the JSON payload.
Rules:
- schemas are an optional enhancement
- functions still register and invoke without schemas
- schemas mainly serve validation, documentation, UI generation, and debugging hints
- v1 does not negotiate multiple payload codecs
Compatibility rules
- An unsupported
Versionis rejected per-request and the session is kept alive (see Version policy) - A first frame that does not fit the
subprotocoldisconnects immediately - An undecodable protobuf body disconnects immediately
- Once disconnected, the old
session_idmust invalidate immediately - After reconnecting, a new session must be established; never assume the old session recovered automatically
Explicitly deprecated legacy concepts
The following must no longer serve as the basis of new protocol implementations:
LocalControlServiceas the main semantic entry pointRegisterLocalRequestas the main semantic entry pointrpc_addr- an SDK-side local listen server
- the
Server -> Agentcallback model - the claim that "the legacy message envelope over TCP equals a separate TCP transport"
