fix(background-agent): cap recursive subagent spawning#2379
Open
code-yeongyu wants to merge 7 commits intodevfrom
Open
fix(background-agent): cap recursive subagent spawning#2379code-yeongyu wants to merge 7 commits intodevfrom
code-yeongyu wants to merge 7 commits intodevfrom
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
There was a problem hiding this comment.
1 issue found across 11 files
Confidence score: 3/5
- There is a concrete medium-high risk in
src/features/background-agent/subagent-spawn-limits.ts: session retrieval errors are not explicitly handled, which can allow spawn-limit checks to be bypassed during transient failures. - The severity (7/10) with high confidence (9/10) suggests real user-facing impact under error conditions, so this is not just a cosmetic or housekeeping concern.
- Pay close attention to
src/features/background-agent/subagent-spawn-limits.ts- ensure session-fetch failures fail closed so spawn limits are still enforced.
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/features/background-agent/subagent-spawn-limits.ts">
<violation number="1" location="src/features/background-agent/subagent-spawn-limits.ts:41">
P1: Explicitly handle session retrieval errors to prevent bypassing spawn limits during transient failures.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| path: { id: currentSessionID }, | ||
| }).catch(() => null) | ||
|
|
||
| const nextParentSessionID = session?.data?.parentID |
There was a problem hiding this comment.
P1: Explicitly handle session retrieval errors to prevent bypassing spawn limits during transient failures.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/features/background-agent/subagent-spawn-limits.ts, line 41:
<comment>Explicitly handle session retrieval errors to prevent bypassing spawn limits during transient failures.</comment>
<file context>
@@ -0,0 +1,79 @@
+ path: { id: currentSessionID },
+ }).catch(() => null)
+
+ const nextParentSessionID = session?.data?.parentID
+ if (!nextParentSessionID) {
+ rootSessionID = currentSessionID
</file context>
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
background_task.maxDepthandbackground_task.maxDescendantslimits, plus the regenerated schema outputBackgroundManagertaskandcall_omo_agentspawns once nested subagent depth exceeds the configured limitTesting
bun testbun run typecheckbun run buildSummary by cubic
Caps recursive subagent spawning by enforcing configurable max depth and per-root descendant limits in BackgroundManager. Addresses Linear #2330 by blocking runaway nested spawns and returning clear, user-facing errors.
Written for commit 7874669. Summary will update on new commits.