fix: isUnstableAgent checks default model instead of resolved model, crashing visual-engineering and writing categories#2297
Conversation
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes two logical bugs (incorrect model check and polling race condition) with comprehensive test coverage, ensuring user overrides are respected without regressions.
…crashing visual-engineering and writing categories - Remove categoryConfigModel from isUnstableAgent check; only evaluate the resolved actualModel (post user-override) for unstable model names - Add null guard in unstable-agent-task polling loop: treat undefined getTask() result as task-completed instead of polling until timeout - Add 7 tests covering override scenarios and race condition Fixes code-yeongyu#2287
be28b0c to
acb257a
Compare
Analysis: Relationship Between #2293 and #2297I've done a deep dive into both PRs and the related issue (#2287). These PRs are solving overlapping problems and should be combined. The Core IssueBoth PRs address why tasks "disappear" causing "Task not found" errors, but they approach it differently:
PR #2297's Bug 2 Has an Edge CaseThe fix treats if (!currentTask) {
completedDuringMonitoring = true // Assumes success
break
}However, during the polling window (10 min),
So if a task errors and gets cleaned up before the polling loop sees it, this fix would incorrectly report success. PR #2293 Fixes This Root CausePR #2293's Bug #2 fix addresses this directly:
With this fix, error paths also have a 10-minute query window, so the polling loop can observe Recommendation: Combine These PRsKeep from #2297:
Keep from #2293:
Consider removing from #2297:
if (!currentTask) {
// Task cleaned up - verify it wasn't an error
const statusResult = await client.session.status()
const sessionStatus = statusResult[sessionID]
if (sessionStatus?.type === "error") {
terminalStatus = { status: "error", error: sessionStatus.message }
} else {
completedDuringMonitoring = true
}
break
}Summary#2293 is the more complete fix. Combining it with #2297's |
…), complements code-yeongyu#2293 lifecycle fix
|
Closing in favor of #2293, which now includes both fixes. Bug 1 (isUnstableAgent fix): Cherry-picked into #2293 — Bug 2 (polling null guard): No longer needed. #2293's See acamq's analysis in the #2297 review comments for the rationale behind combining these PRs. |
…), complements code-yeongyu#2293 lifecycle fix
…), complements code-yeongyu#2293 lifecycle fix
…), complements code-yeongyu#2293 lifecycle fix
…), complements code-yeongyu#2293 lifecycle fix
Summary
Fixes #2287 —
visual-engineeringandwritingtask categories always crash with "Task not found" regardless of user model configuration.Root Cause
Two bugs in
src/tools/delegate-task/:1.
category-resolver.ts—isUnstableAgentchecks hardcoded default model instead of resolved modelvisual-engineeringdefaults togoogle/gemini-3.1-pro→ contains "gemini" → always unstablewritingdefaults tokimi-for-coding/k2p5→ contains "kimi" → always unstableanthropic/claude-sonnet-4-6don't help becausecategoryConfigModelstill checks the default2.
unstable-agent-task.ts— race condition in polling loopmanager.getTask(task.id)returnsundefinedwhen task completes and gets cleaned up before the polling loop catches it. The code falls through and keeps polling until timeout → "Task not found".Fix
Bug 1: Only check
actualModel(the resolved, post-override model) for unstable model names. RemovecategoryConfigModelfrom the check entirely.Bug 2: Add null guard — when
getTask()returnsundefined, treat as task-completed instead of continuing to poll.Behavior Matrix
isUnstableAgentgoogle/gemini-3.1-pro(no override)true✅anthropic/claude-sonnet-4-6false✅ (wastrue❌)kimi-for-coding/k2p5(no override)true✅is_unstable_agent: trueexplicit configtrue✅anthropic/claude-haiku-4-5false✅Tests
category-resolver.test.tscovering all override scenariosunstable-agent-task.test.tsfor the race conditionSummary by cubic
Fixes #2287 by stopping crashes in visual-engineering and writing tasks. Detection now uses the resolved model only, the polling loop treats cleaned-up tasks as completed, and tests cover overrides and the race condition.
Written for commit acb257a. Summary will update on new commits.