@@ -139,14 +139,18 @@ func (cmd *AgentWorkerCMD) Run(ctx *cliContext.Context) error {
139139
140140 // Subscribe to MCP tool execution requests (load-balanced across workers).
141141 // The frontend routes model-level MCP tool calls here via NATS request-reply.
142- natsClient .QueueSubscribeReply (messaging .SubjectMCPToolExecute , messaging .QueueAgentWorkers , func (data []byte , reply func ([]byte )) {
142+ if _ , err := natsClient .QueueSubscribeReply (messaging .SubjectMCPToolExecute , messaging .QueueAgentWorkers , func (data []byte , reply func ([]byte )) {
143143 handleMCPToolRequest (data , reply )
144- })
144+ }); err != nil {
145+ return fmt .Errorf ("subscribing to %s: %w" , messaging .SubjectMCPToolExecute , err )
146+ }
145147
146148 // Subscribe to MCP discovery requests (load-balanced across workers).
147- natsClient .QueueSubscribeReply (messaging .SubjectMCPDiscovery , messaging .QueueAgentWorkers , func (data []byte , reply func ([]byte )) {
149+ if _ , err := natsClient .QueueSubscribeReply (messaging .SubjectMCPDiscovery , messaging .QueueAgentWorkers , func (data []byte , reply func ([]byte )) {
148150 handleMCPDiscoveryRequest (data , reply )
149- })
151+ }); err != nil {
152+ return fmt .Errorf ("subscribing to %s: %w" , messaging .SubjectMCPDiscovery , err )
153+ }
150154
151155 // Subscribe to MCP CI job execution (load-balanced across agent workers).
152156 // In distributed mode, MCP CI jobs are routed here because the frontend
@@ -157,21 +161,25 @@ func (cmd *AgentWorkerCMD) Run(ctx *cliContext.Context) error {
157161 }
158162 mcpCIJobTimeout = cmp .Or (mcpCIJobTimeout , config .DefaultMCPCIJobTimeout )
159163
160- natsClient .QueueSubscribe (messaging .SubjectMCPCIJobsNew , messaging .QueueWorkers , func (data []byte ) {
164+ if _ , err := natsClient .QueueSubscribe (messaging .SubjectMCPCIJobsNew , messaging .QueueWorkers , func (data []byte ) {
161165 handleMCPCIJob (shutdownCtx , data , apiURL , cmd .APIToken , natsClient , mcpCIJobTimeout )
162- })
166+ }); err != nil {
167+ return fmt .Errorf ("subscribing to %s: %w" , messaging .SubjectMCPCIJobsNew , err )
168+ }
163169
164170 // Subscribe to backend stop events to clean up cached MCP sessions.
165171 // In the main application this is done via ml.OnModelUnload, but the agent
166172 // worker has no model loader — we listen for the NATS stop event instead.
167- natsClient .Subscribe (messaging .SubjectNodeBackendStop (nodeID ), func (data []byte ) {
173+ if _ , err := natsClient .Subscribe (messaging .SubjectNodeBackendStop (nodeID ), func (data []byte ) {
168174 var req struct {
169175 Backend string `json:"backend"`
170176 }
171177 if json .Unmarshal (data , & req ) == nil && req .Backend != "" {
172178 mcpTools .CloseMCPSessions (req .Backend )
173179 }
174- })
180+ }); err != nil {
181+ return fmt .Errorf ("subscribing to %s: %w" , messaging .SubjectNodeBackendStop (nodeID ), err )
182+ }
175183
176184 xlog .Info ("Agent worker ready, waiting for jobs" , "subject" , cmd .Subject , "queue" , cmd .Queue )
177185
0 commit comments