Repository navigation
Description
Summary
An External Agent instance (binding.kind = external-application) connected over ASDP gRPC is marked unhealthy by the control plane roughly 45-55 seconds after connecting, even though it is sending Heartbeat messages every 15s exactly as designed and the connection is never actually dropped. Once marked unhealthy, the scheduler's available() check (internal/scheduler/scheduler.go) never selects that instance again, so AgentTasks assigned to it stay in queued forever — the outbox event just keeps retrying with "policy runtime candidate 0 is unavailable" and never delivers.
This affects every External Agent built with agentscope-extensions-controlplane (Java SDK) that doesn't otherwise have an active session reporting state — i.e. exactly the common "freshly registered, idle, waiting for the platform to dispatch the first task" situation.
Root cause
internal/controller/control_outbox_dispatcher.godispatches a queuedAgentTaskviaScheduler.DispatchTask→dispatchTask→selectCandidate/selectOrderedCandidate→Resolver.available(ctx, task, candidate).- For
DataPlaneExternalApplicationbindings,available()(internal/scheduler/scheduler.go) only returnstrueifinstance.Health == controlmodel.RuntimeHealthHealthy. Healthis maintained byRuntimeControlSweeper(cmd/service-controlplane/main.go, flag-runtime-offline-timeout, default 45s), which marks an instance unhealthy oncelast_seen_atis older than that timeout.last_seen_atis only refreshed by specific upstream ASDP message handlers ininternal/asdp/service.go'sConnect()receive loop (handleSessionReport,handleExecutionAttempt,handleEventReport,handleContextReport,handleInventoryReport,handleConversationTurnReport).- The
Upstream_Heartbeatcase in that same switch (around line 173) does not call into any of those handlers or otherwise touch the runtime registry — it only echoes aDownstream_Heartbeatack back to the client:
case *Upstream_Heartbeat:
if err := conn.Send(&Downstream{
Payload: &Downstream_Heartbeat{Heartbeat: &Heartbeat{Timestamp: p.Heartbeat.Timestamp}},
}); err != nil {
logger.V(1).Info("heartbeat response failed", "instance", meta.InstanceKey)
}- The Java SDK's
GrpcTransport(agentscope-extensions-controlplane) sends exactly thisHeartbeatmessage every 15s (HEARTBEAT_INTERVAL_MS = 15_000L) and nothing else while the instance is idle with no active sessions — there is no other upstream report type to send until a session/task actually exists. So for a freshly-registered, idle External Agent,last_seen_atis set once at connect time and never refreshed again, and the sweeper reliably flips it tounhealthy~45s later.
Reproduction
- Register a Java External Agent via
agentscope-extensions-controlplane'sControlPlane.newBridge(...)withstartGrpc(true),enableEvents(true), pointingcontrolPlaneat the control plane's ASDP gRPC address. - Confirm the handshake: control-plane logs show
"asdp-connect" "handshake accepted"and"asdp" "data plane connected". - Query
rt.agent_instancesfor thatagent_id/binding_idrepeatedly over the next ~60s:select instance_key, health, last_seen_at, generation, updated_at from rt.agent_instances where agent_id = '<agent-id>';
last_seen_atstays pinned to the connect timestamp;healthflips from whatever it started as tounhealthy~45-55s after connect, and never recovers. - Create an Issue directly assigned to that Agent (
POST /api/v1/issueswithassigneeType: "agent"). The resultingAgentTaskstaysstatus: "queued"indefinitely. - Check
rt.control_outboxfor theagent-task.queued.v1event on that task:select event_type, attempts, last_error from rt.control_outbox where aggregate_id = '<task-id>';
last_errorreads"control event delivery deferred: policy runtime candidate 0 is unavailable", withattemptsclimbing indefinitely.
Reproduced this 3 times across independent connections (generations 3, 4, 5 in our test), each time the instance went unhealthy 48-54 seconds after connecting — consistent with the 45s runtime-offline-timeout plus sweep-interval slop, and consistent with "last_seen_at never updated after connect."
Confirmed with FINE-level java.util.logging enabled on the SDK side that the client never logs a reconnect/stream-error during this window — the gRPC stream stays up the whole time from the client's perspective. The problem is entirely server-side: heartbeats arrive and are acked, but are never recorded as a liveness signal.
Expected behavior
Receiving an Upstream_Heartbeat should refresh the instance's last_seen_at (and implicitly keep/restore health = healthy), the same way the other upstream report types do — a heartbeat's entire purpose is to prove liveness to exactly this kind of staleness check.
Suggested fix
In internal/asdp/service.go, the case *Upstream_Heartbeat: branch should call the same kind of liveness-refresh the other handlers use (e.g. whatever HeartbeatAgentInstance/last_seen_at update path handleSessionReport etc. ultimately reach), in addition to sending the ack.
Environment
agentscope-serviceBETA1 Docker Compose deployment (as-controlplane:2.1.0-BETA1), ASDP gRPC exposed from the container on its existing internal port (:15010).- Client:
agentscope-extensions-controlplane:2.1.0-BETA1(Java), registered as anexternal-applicationbinding, SDK version0.1.0.
Activity