-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): make goal evaluation lifecycle-safe #6681
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
Changes from all commits
89af831
70f92f8
e16b9f7
72604c7
e81d7de
6129633
af93b40
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| export interface ActiveGoal { | ||
| condition: string; | ||
| iterations: number; | ||
| deferredEvaluations?: number; | ||
| setAt: number; | ||
| tokensAtStart: number; | ||
| lastReason?: string; | ||
|
|
@@ -32,6 +33,7 @@ export function activeGoalEquals( | |
| function stableActiveGoalKey(goal: ActiveGoal): string { | ||
| const comparable: Record<string, unknown> = {}; | ||
| for (const key of Object.keys(goal).sort() as Array<keyof ActiveGoal>) { | ||
| if (key === 'deferredEvaluations') continue; | ||
| const value = goal[key]; | ||
| if (value !== undefined) { | ||
| comparable[key] = value; | ||
|
|
@@ -63,12 +65,32 @@ export function recordGoalIteration( | |
| const updated: ActiveGoal = { | ||
| ...current, | ||
| iterations: current.iterations + 1, | ||
| deferredEvaluations: 0, | ||
|
Collaborator
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. [Critical] The deferral mechanism becomes a one-shot: once it fires and the judge errors, it never re-engages. Fix: reset — qwen3.7-max via Qwen Code /review |
||
| lastReason, | ||
| }; | ||
| store.set(sessionId, updated); | ||
| return updated; | ||
| } | ||
|
|
||
| export function recordGoalDeferral(sessionId: string): ActiveGoal | undefined { | ||
| const current = store.get(sessionId); | ||
| if (!current) return undefined; | ||
| const updated: ActiveGoal = { | ||
| ...current, | ||
| deferredEvaluations: (current.deferredEvaluations ?? 0) + 1, | ||
| }; | ||
| store.set(sessionId, updated); | ||
| return updated; | ||
| } | ||
|
|
||
| export function resetGoalDeferrals(sessionId: string): ActiveGoal | undefined { | ||
| const current = store.get(sessionId); | ||
| if (!current || current.deferredEvaluations === 0) return current; | ||
| const updated: ActiveGoal = { ...current, deferredEvaluations: 0 }; | ||
| store.set(sessionId, updated); | ||
| return updated; | ||
| } | ||
|
|
||
| /** | ||
| * Test-only escape hatch — production code must scope by sessionId. | ||
| */ | ||
|
|
||
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.
[Critical]
stableActiveGoalKey(line ~33) usesObject.keys(goal)to serialize all defined fields for equality comparison. This newdeferredEvaluationsfield changes on everyrecordGoalDeferralcall (up to 50 times per cycle), makingactiveGoalEqualsreturnfalseeach time. Downstream consumers —client.ts:maybeEmitActiveGoalChange(called from 5 sites in the turn loop) anduseGeminiStream.ts— then emit spuriousActiveGoalstream events and trigger redundant React re-renders. The UI never displaysdeferredEvaluations, so every event is wasted work.Fix: exclude
deferredEvaluationsfromstableActiveGoalKey(it is internal bookkeeping, not user-visible state), or switch to an explicit allowlist of fields:— qwen3.7-max via Qwen Code /review