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

Method autonomyClaimNext

internal/daemon/native_tools.go:3346–3378  ·  view source on GitHub ↗
(
	ctx context.Context,
	scope toolspkg.Scope,
	req toolspkg.CallRequest,
)

Source from the content-addressed store, hash-verified

3344}
3345
3346func (n *daemonNativeTools) autonomyClaimNext(
3347 ctx context.Context,
3348 scope toolspkg.Scope,
3349 req toolspkg.CallRequest,
3350) (toolspkg.ToolResult, error) {
3351 var input autonomyClaimNextInput
3352 if err := decodeNativeInput(req, &input); err != nil {
3353 return toolspkg.ToolResult{}, err
3354 }
3355 actor, sessionID, err := autonomyActorContext(req.ToolID, scope)
3356 if err != nil {
3357 return toolspkg.ToolResult{}, err
3358 }
3359 criteria, err := input.criteria(scope, sessionID)
3360 if err != nil {
3361 return toolspkg.ToolResult{}, nativeAutonomyToolError(req.ToolID, err)
3362 }
3363 result, err := n.deps.Tasks.ClaimNextRun(ctx, criteria, actor)
3364 if err != nil {
3365 if errors.Is(err, taskpkg.ErrNoClaimableRun) {
3366 return structuredResult(map[string]any{nativeToolsClaimedKey: false}, "no claimable task runs")
3367 }
3368 return toolspkg.ToolResult{}, nativeAutonomyToolError(req.ToolID, err)
3369 }
3370 if result == nil {
3371 return toolspkg.ToolResult{}, errors.New("daemon: task-run claim returned an empty result")
3372 }
3373 payload := core.AgentTaskClaimPayloadFromResult(result)
3374 return structuredResult(
3375 map[string]any{nativeToolsClaimedKey: true, "claim": payload},
3376 fmt.Sprintf("claimed %s", payload.Lease.RunID),
3377 )
3378}
3379
3380func (n *daemonNativeTools) autonomyHeartbeat(
3381 ctx context.Context,

Callers

nothing calls this directly

Calls 8

criteriaMethod · 0.95
decodeNativeInputFunction · 0.85
autonomyActorContextFunction · 0.85
nativeAutonomyToolErrorFunction · 0.85
structuredResultFunction · 0.85
ClaimNextRunMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected