fix(delegate-task): guard subagent prompt size against model context limits (fixes #951)#3432
fix(delegate-task): guard subagent prompt size against model context limits (fixes #951)#3432MoerAI wants to merge 3 commits intocode-yeongyu:devfrom
Conversation
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9da9119bc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| body: buildSubagentSessionCreateBody({ | ||
| parentSessionID: input.parentSessionID, | ||
| title: input.description, | ||
| permission: input.sessionPermission, | ||
| model: input.model, | ||
| }), |
There was a problem hiding this comment.
Move detached-session logic into the active background path
This change applies buildSubagentSessionCreateBody(...) only in spawner.startTask, but background delegations in production go through BackgroundManager.launch() (used by both src/tools/delegate-task/background-task.ts and src/tools/call-omo-agent/background-executor.ts), which calls BackgroundManager.startTask in src/features/background-agent/manager.ts and still unconditionally sets parentID. That means small-context background subagents still inherit the full parent transcript and can hit the same prompt/context overflow this commit is trying to prevent.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
1 issue found across 19 files
Confidence score: 3/5
- There is a concrete regression risk in
src/config/schema/ralph-loop.ts: changing the schema default fromcontinuetoresetwill silently alter runtime behavior whendefault_strategyis omitted. - Given the high confidence and user-facing impact of default behavior changes, this is more than a housekeeping tweak and introduces some merge risk.
- This can still be merged if intentional, but it should be validated against existing configs and release-noted to avoid surprises for current users.
- Pay close attention to
src/config/schema/ralph-loop.ts- default fallback behavior changed and may break implicit configuration expectations.
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/config/schema/ralph-loop.ts">
<violation number="1" location="src/config/schema/ralph-loop.ts:8">
P2: Changing the schema default from `continue` to `reset` silently changes behavior for configs that omit `default_strategy`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| /** Custom state file directory relative to project root (default: .opencode/) */ | ||
| state_dir: z.string().optional(), | ||
| default_strategy: z.enum(["reset", "continue"]).default("continue"), | ||
| default_strategy: z.enum(["reset", "continue"]).default("reset"), |
There was a problem hiding this comment.
P2: Changing the schema default from continue to reset silently changes behavior for configs that omit default_strategy.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/config/schema/ralph-loop.ts, line 8:
<comment>Changing the schema default from `continue` to `reset` silently changes behavior for configs that omit `default_strategy`.</comment>
<file context>
@@ -5,7 +5,7 @@ export const RalphLoopConfigSchema = z.object({
/** Custom state file directory relative to project root (default: .opencode/) */
state_dir: z.string().optional(),
- default_strategy: z.enum(["reset", "continue"]).default("continue"),
+ default_strategy: z.enum(["reset", "continue"]).default("reset"),
})
</file context>
| default_strategy: z.enum(["reset", "continue"]).default("reset"), | |
| + default_strategy: z.enum(["reset", "continue"]).default("continue"), |
Summary
Problem
Small local models were inheriting parent session context and still using a hardcoded 24k prompt budget. On 16k-context Ollama models this overflowed the available window, so prompts were truncated mid-instruction and subagents returned empty or corrupted results.
Fix
This change reads the resolved model context window from cached provider metadata and switches small-context subagents to isolated sessions so they stop inheriting the full parent conversation. It also caps injected system content to 50% of the detected context window and trims low-priority example-heavy blocks before falling back to hard truncation.
Changes
src/shared/subagent-context-window.tssrc/tools/delegate-task/prompt-builder.tssrc/tools/delegate-task/token-limiter.tssrc/tools/delegate-task/sync-session-creator.tssrc/tools/call-omo-agent/session-creator.tssrc/features/background-agent/spawner.tsFixes #951
Summary by cubic
Prevents subagent prompt overflow on small-context models by detaching sessions and capping system content, avoiding truncation and bad outputs on 16k models. Also defaults Ralph loop to start fresh sessions and improves plugin config file detection. Fixes #951.
Bug Fixes
call_omo_agent, and background spawner; new tests cover small-context behavior.Migration
ralph-loopnow defaults to "reset" strategy. Setdefault_strategy: "continue"in your loop config if you prefer the old behavior.Written for commit 9da9119. Summary will update on new commits.