forked from NeuralNomadsAI/CodeNomad
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Bug Report
Summary
When any subagent is launched via the Task tool, it consumes 1 premium request. This is unexpected behavior since subagents are internal operations that should not consume user's premium quota.
Expected Behavior
- Only the main agent's initial user prompt should consume 1 premium request
- Subagent launches and operations should NOT consume additional premium requests
Actual Behavior
- Every subagent launch consumes 1 premium request
- This causes quota exhaustion to occur significantly faster when using subagent-based features
Environment
- CodeNomad version: latest
- Platform: All (Electron app)
Steps to Reproduce
- Send a prompt to the main agent that will trigger a subagent
- Observe the premium request count increases by 1 for the main agent
- Observe the premium request count increases by ANOTHER 1 when the subagent is launched
- Total: 2+ premium requests instead of expected 1
Root Cause Analysis
Based on code review, there is already a fix in place in packages/ui/src/stores/message-v2/instance-store.ts:
function updateUsageWithInfo(info: MessageInfo | undefined) {
// ...
const session = state.sessions[info.sessionID]
if (session?.parentId != null) {
if (import.meta.env.DEV) {
console.log(`[Usage Debug] ⏭️ SKIPPING subagent session ${info.sessionID} - parentId: ${session.parentId}`)
}
return // Skip usage tracking for subagents
}
// Track usage for main sessions
}However, the issue may be that:
- The Task tool completion in the MAIN session might be generating an assistant message that IS tracked
- Or there's a timing issue where
session.parentIdis not yet populated when usage is tracked - Or the session hydration (
rebuildUsageStateFromInfos) is not properly filtering subagent messages
Relevant Files
packages/ui/src/stores/message-v2/instance-store.ts(lines 367-391)packages/server/src/workspaces/instance-events.ts(session cache with parentID)tasks/done/prd-subagent-premium-fix.md(PRD for the fix)
Investigation Needed
- Verify that
session.parentIdis being set correctly beforemessage.updatedevents - Check if tool completions in the main session are being incorrectly tracked
- Add debug logging to trace when and where premium requests are being counted
- Verify
rebuildUsageStateFromInfosis properly filtering during hydration
Priority
High - This affects all users and causes significant quota waste
Labels
bug, premium, subagent, priority:high
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels