Skip to content

Conversation

@Ipriyankrajai
Copy link

Problem

When a user switches models at runtime using /model, subtasks spawned via the Task tool ignored the runtime selection and used the agent's configured model from config instead. Fixes #6928

For example:

  1. User switches to a cheaper model (e.g., GLM 4.7)
  2. User runs a command that spawns a subtask
  3. Subtask uses the expensive model from agent config (e.g., github-copilot/claude-sonnet-4.5)

This caused unexpected usage of premium API requests.

Root Cause

In task.ts, the model priority was:

const model = agent.model ?? { modelID: msg.info.modelID, ... }

Agent config model took priority over the parent session's runtime selection.

Fix

Always use the parent session's model (stored in msg.info.modelID), which reflects the user's runtime selection:

const model = { modelID: msg.info.modelID, providerID: msg.info.providerID }

The model is then passed explicitly to SessionPrompt.prompt(), ensuring the subtask respects the user's choice.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Duplicate PR Detection Results

No duplicates found

The searches returned only the PR itself (#6937), indicating there are no other open PRs addressing the same issue.

Searches performed:

  • "task model initialization runtime session"
  • "model switching subtask agent config"
  • "6928 task model priority"
  • "runtime model selection SessionPrompt"

This appears to be the only PR addressing the task model initialization issue where subtasks were ignoring runtime model selection (#6928).

@Ipriyankrajai
Copy link
Author

@thdxr Can you review this solution?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subtask commands do not inherit model

1 participant