feat(runtime): generic task tool + semaphore + nesting guard (#454) - #459
Merged
Conversation
…454) Add a general-purpose `task` sub-agent tool the model can dispatch with a runtime prompt to fan out work in one message. Generalize SubAgentTool with an optional argument-schema override and a shared concurrency semaphore (acquired/released in executeGoroutine), then wire the tool into run.SetupEnv with a child RunConfig factory reusing the resolved provider stream/model. - task schema: {description?, prompt} with prompt required; parallel exec mode - semaphore: default 4, PIGO_MAX_SUBAGENTS override (invalid/absent -> 4, floor 1) - nesting guard: BuiltinToolsExcept builds the child registry without "task" - child failure surfaces as a tool error; existing subagent tests unchanged No progress events are emitted here; SubAgentProgressEvent lands in #455. Refs #454
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements node #454 of the subagent-orchestration graph: a generic
tasktool that lets the model dispatch general-purpose sub-agents with a runtime prompt, enabling single-message fan-out.internal/runtime/task.go:NewTaskTool(factory, sem)builds a generic SubAgentTool spec (generic system prompt,{description?, prompt}schema, parallel exec mode).MaxSubagents()/NewSubagentSemaphore()resolve the concurrency cap (default 4,PIGO_MAX_SUBAGENTSoverride, invalid/absent -> 4, floor 1).SubAgentTool(subagent.go): optionalSchemaoverride + sharedSemsemaphore acquired/released inexecuteGoroutine(blocks/queues when full, ctx-cancel aware, released via defer). Existing prompt-only specs and all existing subagent tests are unaffected.run.SetupEnv(internal/cli/run/run.go) with a child RunConfig factory reusing the resolved provider stream/model and an env-resolved credential store.BuiltinToolsExcept(cwd, disabled, "task")builds the child registry withouttask(nesting guard: depth capped at 1).Progress reporting is intentionally NOT included here —
SubAgentProgressEventdoes not yet exist on master (parallel node #453) and is added on top in #455.Test plan
go build ./...,go vet ./...,go test ./...all passtask(BuiltinToolsExcept)orchestration_test.go/subagent_process_test.gostill green (no regression)Closes #454