{"record":{"id":"fec34925374d0352","repo":"sipeed/picoclaw","slug":"w-all-d-slots-occupied-for-v","errorCode":null,"errorMessage":"%w: all %d slots occupied for %v","messagePattern":"%w: all (.+?) slots occupied for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/subturn.go","lineNumber":306,"sourceCode":"\t\t// Create a timeout context for semaphore acquisition\n\t\ttimeoutCtx, cancel := context.WithTimeout(ctx, rtCfg.concurrencyTimeout)\n\t\tdefer cancel()\n\n\t\tselect {\n\t\tcase parentTS.concurrencySem <- struct{}{}:\n\t\t\tsemAcquired = true\n\t\t\tdefer func() {\n\t\t\t\tif semAcquired {\n\t\t\t\t\t<-parentTS.concurrencySem\n\t\t\t\t}\n\t\t\t}()\n\t\tcase <-timeoutCtx.Done():\n\t\t\t// Check parent context first - if it was canceled, propagate that error\n\t\t\tif ctx.Err() != nil {\n\t\t\t\treturn nil, ctx.Err()\n\t\t\t}\n\t\t\t// Otherwise it's our timeout\n\t\t\treturn nil, fmt.Errorf(\"%w: all %d slots occupied for %v\",\n\t\t\t\tErrConcurrencyTimeout, rtCfg.maxConcurrent, rtCfg.concurrencyTimeout)\n\t\t}\n\t}\n\n\t// 1. Depth limit check\n\tif parentTS.depth >= rtCfg.maxDepth {\n\t\tlogger.WarnCF(\"subturn\", \"Depth limit exceeded\", map[string]any{\n\t\t\t\"parent_id\": parentTS.turnID,\n\t\t\t\"depth\":     parentTS.depth,\n\t\t\t\"max_depth\": rtCfg.maxDepth,\n\t\t})\n\t\treturn nil, ErrDepthLimitExceeded\n\t}\n\n\t// 2. Config validation: Model is required unless TargetAgentID is set\n\t//    (the target agent provides its own model).\n\tif cfg.Model == \"\" && cfg.TargetAgentID == \"\" {\n\t\treturn nil, ErrInvalidSubTurnConfig","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/subturn.go#L288-L324","documentation":"Sentinel wrap in spawnSubTurn's select: the parent turn's concurrency semaphore did not free a slot within rtCfg.concurrencyTimeout (and the parent ctx itself was not cancelled — that case propagates ctx.Err() instead). All MaxConcurrentSubTurns slots for the parent turn are occupied, so the child SubTurn is refused rather than queued indefinitely.","triggerScenarios":"Thrown at pkg/agent/subturn.go:306 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise the sub-turn concurrency limit in runtime config if the workload legitimately needs more parallel children","Increase concurrencyTimeout to outlast slow sibling sub-turns","Reduce fan-out: enqueue fewer simultaneous SubTurns per parent turn","Check for leaked slots (children that never release the semaphore) via metrics/tests"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}