fix(delegate-task): prevent infinite loop when both category and subagent_type provided#2934
Closed
guazi04 wants to merge 1 commit intocode-yeongyu:devfrom
Closed
fix(delegate-task): prevent infinite loop when both category and subagent_type provided#2934guazi04 wants to merge 1 commit intocode-yeongyu:devfrom
guazi04 wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
…gent_type provided
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 4/5
- This PR is likely safe to merge, with a small behavior mismatch in
src/tools/delegate-task/tools.tsrather than a clear breakage. - In
src/tools/delegate-task/tools.ts, the tool description says passing both parameters should error, but the implementation now ignoressubagent_type; this can confuse callers and lead to unexpected task-routing behavior. - The issue is moderate (5/10) but high-confidence, so it’s worth aligning docs and runtime behavior soon to avoid subtle regressions.
- Pay close attention to
src/tools/delegate-task/tools.ts- parameter-conflict handling no longer matches the documented error behavior.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tools/delegate-task/tools.ts">
<violation number="1" location="src/tools/delegate-task/tools.ts:79">
P2: Tool description claims both parameters cause an error, but implementation now silently ignores `subagent_type` when both are present.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| - subagent_type: For direct agent invocation (explore, librarian, oracle, etc.) | ||
|
|
||
| **DO NOT provide both.** category and subagent_type are mutually exclusive. | ||
| **DO NOT provide both.** Providing both will cause an error. |
There was a problem hiding this comment.
P2: Tool description claims both parameters cause an error, but implementation now silently ignores subagent_type when both are present.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/delegate-task/tools.ts, line 79:
<comment>Tool description claims both parameters cause an error, but implementation now silently ignores `subagent_type` when both are present.</comment>
<file context>
@@ -73,13 +73,13 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
- subagent_type: For direct agent invocation (explore, librarian, oracle, etc.)
- **DO NOT provide both.** category and subagent_type are mutually exclusive.
+ **DO NOT provide both.** Providing both will cause an error.
- load_skills: ALWAYS REQUIRED. Pass [] if no skills needed, or ["skill-1", "skill-2"] for category tasks.
</file context>
Owner
Owner
|
Duplicate — going with #2939 |
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.
Problem
When models pass both
categoryandsubagent_typeto thetask()tool, the current code throws an error. Models then retry with the same parameters, creating an infinite loop that wastes tokens and blocks execution.Root cause
categorywithsisyphus-juniorand pass both parametersReproduction
Any model (especially GPT series) delegating a quick task:
Changes
1. Tool description cleanup
2. Defensive behavior restored
throw new Error(...)→log() + args.subagent_type = undefinedsubagent_type, continue withcategory3. Test updated
rejects.toThrow("mutually exclusive")with successful resolution + log assertionVerification
bun run typecheck: ✅ passbun test src/tools/delegate-task/: 234 pass, 0 failSummary by cubic
Prevents infinite retry loops in the
task()tool by ignoringsubagent_typewhencategoryis also provided, logging a warning, and continuing withcategory. Cleans up the tool description to reduce confusion and updates tests.categoryandsubagent_typeare passed, log a warning and dropsubagent_type; proceed withcategory.Written for commit ef0ed6d. Summary will update on new commits.