MCPcopy Create free account
hub / github.com/astercloud/aster / ResumeAgent

Method ResumeAgent

server/handlers/pool.go:151–212  ·  view source on GitHub ↗

ResumeAgent resumes an agent from storage

(c *gin.Context)

Source from the content-addressed store, hash-verified

149
150// ResumeAgent resumes an agent from storage
151func (h *PoolHandler) ResumeAgent(c *gin.Context) {
152 id := c.Param("id")
153
154 var req struct {
155 TemplateID string `json:"template_id" binding:"required"`
156 ModelConfig *types.ModelConfig `json:"model_config"`
157 Sandbox *types.SandboxConfig `json:"sandbox"`
158 Middlewares []string `json:"middlewares"`
159 MiddlewareCfg map[string]map[string]any `json:"middleware_config"`
160 }
161
162 if err := c.ShouldBindJSON(&req); err != nil {
163 c.JSON(http.StatusBadRequest, gin.H{
164 "success": false,
165 "error": gin.H{
166 "code": "bad_request",
167 "message": err.Error(),
168 },
169 })
170 return
171 }
172
173 ctx := c.Request.Context()
174
175 // Create agent config
176 config := &types.AgentConfig{
177 TemplateID: req.TemplateID,
178 ModelConfig: req.ModelConfig,
179 Sandbox: req.Sandbox,
180 Middlewares: req.Middlewares,
181 MiddlewareConfig: req.MiddlewareCfg,
182 }
183
184 // Resume agent
185 ag, err := h.pool.Resume(ctx, id, config)
186 if err != nil {
187 logging.Error(ctx, "pool.resume.error", map[string]any{
188 "agent_id": id,
189 "error": err.Error(),
190 })
191 c.JSON(http.StatusInternalServerError, gin.H{
192 "success": false,
193 "error": gin.H{
194 "code": "internal_error",
195 "message": "Failed to resume agent: " + err.Error(),
196 },
197 })
198 return
199 }
200
201 logging.Info(ctx, "pool.agent.resumed", map[string]any{
202 "agent_id": ag.ID(),
203 })
204
205 c.JSON(http.StatusOK, gin.H{
206 "success": true,
207 "data": gin.H{
208 "agent_id": ag.ID(),

Callers

nothing calls this directly

Calls 8

ErrorFunction · 0.92
InfoFunction · 0.92
JSONMethod · 0.80
ErrorMethod · 0.65
ContextMethod · 0.65
ResumeMethod · 0.65
IDMethod · 0.65
StatusMethod · 0.45

Tested by

no test coverage detected