Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Summary
When a background subagent is spawned via Task with an explicit model override (e.g. model: "grok-4.7-medium", run_in_background: true), its primary turn and any explicit Task(resume) turns correctly run on grok-4.7-medium.
However, if a background Shell (block_until_ms: 0) inside that subagent finishes or exits, the resulting BACKGROUND_TASK_COMPLETION follow-up turn ("Briefly inform the user about the task result...") drops the subagent’s modelId (grok-4.7-medium) and executes on grok-4.7-high-fast instead.
Steps to Reproduce
- From a parent agent session, invoke
Taskwithsubagent_type: "generalPurpose",model: "grok-4.7-medium",run_in_background: true. - Inside the subagent, run a background
Shellcommand (block_until_ms: 0) that finishes after the turn ends (or is terminated). - Observe
GetFilteredUsageEvents/ billing events for the subagent’sconversationId:- Initial subagent turn:
grok-4.7-medium - Automatic
BACKGROUND_TASK_COMPLETIONturn ("Briefly inform the user about the task result..."): billed asgrok-4.7-high-fast.
- Initial subagent turn:
Expected Behavior
A background wakeup turn on a session/subagent should always inherit that session’s lastTurnModel / hostedTaskSettings.modelId (preserveRequestedModel: true), matching buildHostOwnedWakeupRequest.
- Either include
lastTurnModel(modelId,modelDetails,requestedModel) in the$enqueueBackgroundWakeuppayload, or haveresolveRequestedModel(daemon.cjs:23830) fall back tosession.lastTurnModel/hostedTaskSettings.modelIdonBACKGROUND_TASK_COMPLETIONturns.
Operating System
MacOS
Version Information
- Cursor Version:
3.27.22(Commitb1aa50cb6db84fd3e8c808259cb172ea73425c10) - Component:
cursor-agent-host/cursor-agent-exec(Background Wakeup & Subagent Model Routing)
Additional Information
Root Cause (AI generated)
- Host-owned wakeup path explicitly preserves
lastTurnModel:
Inextensions/cursor-agent-host/dist/agent-host-daemon/dist/bin/daemon.cjs(L23585:110buildHostOwnedWakeupRequest&L23663:748startHostOwnedBackgroundWakeupTurn), the host copiesmodelId,modelDetails, andrequestedModelfromsession.lastTurnModeland callssendAction(..., { preserveRequestedModel: true }). - Default IDE Surface-owned wakeup path short-circuits this and drops model fields:
extensions/cursor-agent-host/dist/main.js(L8:10825288) hardcodessurfaceOwnsBackgroundWakeups: true, causingqueueHostOwnedBackgroundWakeup(daemon.cjs:23661:957) to return early.notifyBackgroundTaskCompletion(extensions/cursor-agent-exec/dist/main.jsL8:9396788) callsenqueueBackgroundWakeup({ conversationId: e.composerId, id: e.taskId, source: "shell", payload: e })via$enqueueBackgroundWakeup(extensionHostProcess.jsL182:3030156).- Neither the RPC envelope nor
payloadcarrieslastTurnModel(modelId/modelDetails/requestedModel), andhostedTaskSettings.modelId(daemon.cjs:23805:295) is never consulted during wakeup construction. As a result, the surface dispatches the subagent’s follow-up turn usinggrok-4.7-high-fastrather than the subagent’s lockedgrok-4.7-medium.
Does this stop you from using Cursor
No - Cursor works, but with this issue