Skip to content

fix(delegate-task): inherit the parent model for unconfigured tasks#2738

Open
0xYiliu wants to merge 3 commits intocode-yeongyu:devfrom
0xYiliu:feat/inherit-parent-model-for-unconfigured-subagents
Open

fix(delegate-task): inherit the parent model for unconfigured tasks#2738
0xYiliu wants to merge 3 commits intocode-yeongyu:devfrom
0xYiliu:feat/inherit-parent-model-for-unconfigured-subagents

Conversation

@0xYiliu
Copy link
Copy Markdown

@0xYiliu 0xYiliu commented Mar 21, 2026

Summary

  • make delegated tasks inherit the parent session current model when no explicit subagent/category model is configured
  • keep explicit agent/category model overrides higher priority than inherited models
  • add delegate-task regression coverage for subagent and category inheritance behavior

Why

Delegated tasks already capture the parent session model, but unconfigured subagents/categories still fall back to built-in defaults instead of following the parents current effective model. That makes runtime model selection inconsistent whenever users switch the main orchestrator model.

Behavior

  • explicit user-configured delegated model still wins
  • otherwise use the inherited parent session model
  • otherwise continue through the existing built-in default and fallback chain

Validation

  • bun test src/tools/delegate-task/model-inheritance.test.ts
  • bun test src/tools/delegate-task/tools.test.ts

Related

Fixes #2737


Summary by cubic

Delegated tasks inherit the parent session model when no subagent/category model is set, and unstable-model supervision is enforced for both category and direct subagent_type calls. Explicit agent/category overrides still win. Fixes #2737.

  • Bug Fixes

    • Precedence: user override > inherited > category/agent default > system fallback; applied to category and subagent paths, with modelInfo marking inherited.
    • Restored and centralized unstable-model supervision; actualModel/isUnstableAgent propagate from subagent routing and a common guard runs when run_in_background=false.
    • Model resolution: inherited model checked first with provider-hinted fuzzy match; cold-cache uses inherited when availability is empty; tests cover category/subagent inheritance, explicit override wins, and direct unstable subagents.
  • Refactors

    • Centralized guard in tools.ts; resolveSubagentExecution now accepts inheritedModel and returns actualModel/isUnstableAgent.
    • Adopted helpers (flattenToFallbackModelStrings, agentCategoryModel, fuzzyMatchModel); removed an unused routing helper.

Written for commit acc52eb. Summary will update on new commits.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 21, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Confidence score: 3/5

  • There is a concrete regression risk in src/tools/delegate-task/tools.ts: the unstable-agent safeguard can be bypassed for subagents because isUnstableAgent only runs when args.category is set, while routing now allows inheriting models via resolveTaskRouting.
  • Given the high confidence (9/10) and user-facing impact (unstable models may be selected despite mitigation), this sits above a minor issue and justifies a moderate merge-risk score.
  • Pay close attention to src/tools/delegate-task/tools.ts - ensure unstable-agent checks are applied consistently for subagent routing paths, including inherited parent-session models.
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:201">
P1: Unstable agent mitigation bypassed for subagents. The `isUnstableAgent` check is guarded by `if (args.category)`, but subagents can now inherit unstable models from the parent session via the new `resolveTaskRouting` logic. When `args.category` is undefined (subagent task) but the inherited model is unstable (e.g., o1-preview) and `run_in_background=false`, the task will bypass the unstable agent check and proceed to `executeSyncTask`, which will likely fail since unstable models lack streaming support. The unstable agent check should apply to all tasks regardless of whether they use category or subagent_type.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@0xYiliu
Copy link
Copy Markdown
Author

0xYiliu commented Mar 21, 2026

I have read the CLA Document and I hereby sign the CLA

0xYiliu added 2 commits March 22, 2026 07:03
Why:
- delegated tasks captured the parent model but still fell back to built-in agent/category defaults when no explicit model override existed
- this made runtime model selection inconsistent for users who switch the main orchestrator model

What:
- insert inherited parent model ahead of built-in delegate defaults in delegate-task model resolution
- keep explicit agent/category model overrides higher priority than inherited models
- add regression coverage for subagent and category inheritance behavior

Impact:
- unconfigured delegated tasks now follow the parent session model more consistently
- explicitly configured delegated tasks keep their existing behavior

Refs: code-yeongyu#2737
Why:
- inherited subagent models can now resolve to unstable providers such as gemini or minimax
- the previous guard only forced supervised execution for category-based delegation, which left inherited subagent paths unsafeguarded

What:
- carry actualModel and unstable-agent detection through subagent routing results
- apply the unstable-model supervision path for delegated tasks regardless of whether they use category or subagent_type
- add regression coverage for inherited unstable subagent models

Impact:
- delegated subagents keep the same runtime safety behavior as category-based tasks when they inherit unstable models
- explicit model precedence remains unchanged
@0xYiliu 0xYiliu force-pushed the feat/inherit-parent-model-for-unconfigured-subagents branch from 5ada402 to 70d58f9 Compare March 21, 2026 23:04
@0xYiliu
Copy link
Copy Markdown
Author

0xYiliu commented Mar 21, 2026

recheck

@code-yeongyu
Copy link
Copy Markdown
Owner

This PR has merge conflicts with the recently merged #2892 (category-resolver.ts cold-cache fix). Could you rebase on the latest dev branch? The model inheritance approach is approved — parent model fallback for unconfigured tasks is the right behavior. Just needs a clean rebase to resolve the conflict. Thanks!

@0xYiliu
Copy link
Copy Markdown
Author

0xYiliu commented Mar 28, 2026

I have read the CLA Document and I hereby sign the CLA

Why:
- the PR branch needed to sync with upstream/dev, but the previous merge commit used an unsigned author identity and blocked CLA
- the upstream sync also dropped direct unstable subagent supervision and left an unused routing helper behind

What:
- re-sync the branch with upstream/dev using the signed noreply identity
- preserve inherited-model behavior across category and subagent routing while restoring supervised execution for direct unstable subagents
- remove the unused task-routing-resolver and keep the regression coverage for the repaired path

Impact:
- the PR keeps the upstream sync, remains mergeable against dev, and no longer depends on an unsigned merge commit
- direct unstable subagents regain monitored execution and the delegate-task tree stays clean
@0xYiliu 0xYiliu force-pushed the feat/inherit-parent-model-for-unconfigured-subagents branch from 33d226e to acc52eb Compare March 28, 2026 16:13
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 4 files (changes from recent commits).

Auto-approved: Implements model inheritance for delegated tasks with clear precedence (User > Inherited > Default). Includes new regression tests and centralizes unstable model supervision.

@0xYiliu
Copy link
Copy Markdown
Author

0xYiliu commented Mar 28, 2026

@code-yeongyu Sorry for the late reply, and thank you for confirming that the model inheritance approach is the right direction. I had assumed this issue was no longer needed, so I did not follow up quickly enough. I've now rebased the branch onto the latest dev, resolved the conflict from #2892, restored the unstable-subagent supervision path that regressed during the sync, removed the leftover dead routing helper, and re-ran the relevant tests and build locally. Thanks again for the guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug-fix PR: Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delegated tasks should inherit the parent model when no explicit model is configured

2 participants