monitorAgent monitors the agent process and handles cleanup
(clientCtx context.Context, agentCtx context.Context)
| 1148 | |
| 1149 | // monitorAgent monitors the agent process and handles cleanup |
| 1150 | func (a *AgentClient) monitorAgent(clientCtx context.Context, agentCtx context.Context) { |
| 1151 | select { |
| 1152 | case <-clientCtx.Done(): |
| 1153 | // Client context cancelled, stop the agent |
| 1154 | a.logger.Debug("Client context cancelled, stopping agent") |
| 1155 | a.stopAgent() |
| 1156 | case <-agentCtx.Done(): |
| 1157 | // Agent context cancelled or agent stopped |
| 1158 | if errors.Is(agentCtx.Err(), context.Canceled) { |
| 1159 | a.logger.Info("Agent was stopped intentionally") |
| 1160 | } else { |
| 1161 | a.logger.Error("Agent stopped unexpectedly, client operations may be affected", zap.String("next_step", "check agent logs for panic/oom, ensure required capabilities/permissions, or rerun with --debug and verify the agent binary is compatible with the CLI")) |
| 1162 | } |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | func (a *AgentClient) Setup(ctx context.Context, cmd string, opts models.SetupOptions) error { |
| 1167 | isDockerCmd := utils.IsDockerCmd(utils.CmdType(opts.CommandType)) |
no test coverage detected