-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: track spawned profile ID to correctly attribute rate limit errors #1994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,7 @@ export class AgentProcessManager { | |
|
|
||
| private setupProcessEnvironment( | ||
| extraEnv: Record<string, string> | ||
| ): NodeJS.ProcessEnv { | ||
| ): { env: NodeJS.ProcessEnv; profileId: string; profileName: string } { | ||
| // Get best available Claude profile environment (automatically handles rate limits) | ||
| const profileResult = getBestAvailableProfileEnv(); | ||
| const profileEnv = profileResult.env; | ||
|
|
@@ -253,7 +253,7 @@ export class AgentProcessManager { | |
| apiKeyPrefix: mergedEnv.ANTHROPIC_API_KEY?.substring(0, 8) || '(not set)', | ||
| }); | ||
|
|
||
| return mergedEnv; | ||
| return { env: mergedEnv, profileId: profileResult.profileId, profileName: profileResult.profileName }; | ||
| } | ||
|
|
||
| private handleProcessFailure( | ||
|
|
@@ -263,7 +263,8 @@ export class AgentProcessManager { | |
| ): boolean { | ||
| console.log('[AgentProcess] Checking for rate limit in output (last 500 chars):', allOutput.slice(-500)); | ||
|
|
||
| const rateLimitDetection = detectRateLimit(allOutput); | ||
| const profileAssignment = this.state.getTaskProfileAssignment(taskId); | ||
| const rateLimitDetection = detectRateLimit(allOutput, profileAssignment?.profileId); | ||
| console.log('[AgentProcess] Rate limit detection result:', { | ||
| isRateLimited: rateLimitDetection.isRateLimited, | ||
| resetTime: rateLimitDetection.resetTime, | ||
|
|
@@ -549,7 +550,8 @@ export class AgentProcessManager { | |
| spawnId | ||
| }); | ||
|
|
||
| const env = this.setupProcessEnvironment(extraEnv); | ||
| const { env, profileId: spawnedProfileId, profileName: spawnedProfileName } = this.setupProcessEnvironment(extraEnv); | ||
| this.state.assignProfileToTask(taskId, spawnedProfileId, spawnedProfileName, 'proactive'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The call to Suggested FixMove the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| // Get active API profile environment variables | ||
| let apiProfileEnv: Record<string, string> = {}; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
handleProcessFailuremethod is currently only invoked from the deprecatedspawnProcessmethod. However,spawnWorkerProcess(line 838) is the primary execution path for autonomous AI tasks and it does not appear to utilize this rate limit detection and attribution logic. To fully address the issue described in the PR, the worker-based execution path should also be updated to track and attribute rate limits correctly.