MCPcopy Create free account
hub / github.com/compozy/agh / AgentTaskFail

Method AgentTaskFail

internal/api/core/agent_tasks.go:262–299  ·  view source on GitHub ↗

AgentTaskFail fails one claimed task run after token verification.

(c *gin.Context)

Source from the content-addressed store, hash-verified

260
261// AgentTaskFail fails one claimed task run after token verification.
262func (h *BaseHandlers) AgentTaskFail(c *gin.Context) {
263 manager, caller, runID, ok := h.agentTaskLeaseMutationSetup(c, agentTaskActionFail)
264 if !ok {
265 return
266 }
267
268 var req contract.AgentTaskFailRequest
269 if err := c.ShouldBindJSON(&req); err != nil {
270 h.respondError(
271 c,
272 http.StatusBadRequest,
273 NewTaskValidationError(fmt.Errorf("%s: decode agent task fail request: %w", h.transportName(), err)),
274 )
275 return
276 }
277
278 failure, err := failTaskRunFromRequest(contract.FailTaskRunRequest(req))
279 if err != nil {
280 h.respondError(c, statusForAgentTaskError(err), err)
281 return
282 }
283 handle, err := h.lookupAgentTaskLease(c.Request.Context(), manager, caller, runID)
284 if err != nil {
285 h.respondError(c, statusForAgentTaskError(err), err)
286 return
287 }
288 run, err := manager.FailRunLease(c.Request.Context(), taskpkg.LeaseFailure{
289 RunID: runID,
290 ClaimToken: handle.ClaimToken,
291 Failure: failure,
292 }, caller.Actor)
293 if err != nil {
294 h.respondError(c, statusForAgentTaskError(err), err)
295 return
296 }
297
298 c.JSON(http.StatusOK, contract.AgentTaskLeaseResponse{Lease: AgentTaskLeasePayloadFromRun(run, nil)})
299}
300
301func (h *BaseHandlers) agentTaskLeaseMutationSetup(
302 c *gin.Context,

Callers

nothing calls this directly

Calls 10

respondErrorMethod · 0.95
transportNameMethod · 0.95
lookupAgentTaskLeaseMethod · 0.95
FailTaskRunRequestStruct · 0.92
NewTaskValidationErrorFunction · 0.85
statusForAgentTaskErrorFunction · 0.85
failTaskRunFromRequestFunction · 0.70
FailRunLeaseMethod · 0.65

Tested by

no test coverage detected