Repository navigation
Conversation
|
/coder-agents-review |
|
Chat: Review posted | View chat Review history
deep-review v0.8.0 | Round 1 | Last posted: Round 1, 5 findings (4 Nit, 1 Note), COMMENT. Review Finding inventoryFindings
Round logRound 1Panel. 0 P0-P4, 4 Nit, 1 Note. Netero clean. Panel: Bisky, Hisoka, Pariston, Mafuuu, Mafu-san, Ging-Go, Meruem, Takumi, Komugi, Gon, Leorio, Kite. Reviewed against a5a4c49..7188a95. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
Clean, well-scoped refactoring. The named-return-plus-defer pattern eliminates ten manual cleanup() calls and makes future error paths safe by default. The mcpCleanup hoisting and the constant extraction are both straightforward improvements.
Five reviewers independently noticed that the cleanup restructuring incidentally fixes a latent resource leak: in the old code, if g2.Wait() returned an error (e.g. from ConvertMessagesWithFiles), cleanup() only called workspaceCtx.close() because the mcpCleanup chaining happened after the error check. Since errgroup.Wait() guarantees all goroutines complete before returning, mcpCleanup was set but never called. MCP connections leaked until context cancellation. The new code captures mcpCleanup by reference in the initial cleanup closure, fixing this for all error paths.
3 nits, 1 note. No blocking issues.
"'clean' is a chart note that says 'treated patient.' Treated how?" Leorio
This review was generated by Coder Agents.
🤖 This review was automatically generated with Coder Agents.
| // defaultChatMaxOutputTokens caps a model response when the model config | ||
| // does not set a provider-specific output limit. This keeps unbounded | ||
| // requests from accidentally exhausting large-context models. | ||
| defaultChatMaxOutputTokens int64 = 32_000 |
There was a problem hiding this comment.
Nit [CRF-1] The first sentence ("caps a model response when the model config does not set a provider-specific output limit") restates what the name + usage site already show: default = fallback, ChatMaxOutputTokens = caps tokens, and the callConfig.MaxOutputTokens == nil guard shows when it fires.
Downgraded from P2 because the sibling defaultAdvisorMaxOutputTokens follows the identical what-then-why pattern, so this matches local convention.
(Gon P2, downgraded to Nit by orchestrator)
🤖
| // defaultChatMaxOutputTokens caps a model response when the model config | ||
| // does not set a provider-specific output limit. This keeps unbounded | ||
| // requests from accidentally exhausting large-context models. | ||
| defaultChatMaxOutputTokens int64 = 32_000 |
There was a problem hiding this comment.
Nit [CRF-3] The adjacent defaultAdvisorMaxOutputTokens comment explains its value: "intentionally generous relative to the advisor's concise guidance remit so short plans are not truncated mid-reasoning." That tells you why 16,384 and not 8,192.
This constant says what it prevents but not why 32,000. Is it half a 64k context window? A provider default? Empirically determined? The next person tuning this value has no anchor.
(Leorio)
🤖
| // defaultChatMaxOutputTokens caps a model response when the model config | ||
| // does not set a provider-specific output limit. This keeps unbounded | ||
| // requests from accidentally exhausting large-context models. | ||
| defaultChatMaxOutputTokens int64 = 32_000 |
There was a problem hiding this comment.
Nit [CRF-4] Commit subject "clean generation preparer setup" is vague. "clean" doesn't convey what changed. Something like "centralize preparer error cleanup via named return" or "simplify preparer setup: extract token constant, defer cleanup" tells git log --oneline readers what happened.
(Leorio)
🤖
|
|
||
| if callConfig.MaxOutputTokens == nil { | ||
| maxOutputTokens := int64(32_000) | ||
| maxOutputTokens := defaultChatMaxOutputTokens |
There was a problem hiding this comment.
Nit [CRF-2] Go 1.26 supports new(expr) for constant expressions. This two-line address-of-local pattern:
maxOutputTokens := defaultChatMaxOutputTokens
callConfig.MaxOutputTokens = &maxOutputTokenscan be:
callConfig.MaxOutputTokens = new(defaultChatMaxOutputTokens)Verified: new(defaultChatMaxOutputTokens) produces *int64 with value 32000 under go 1.26.4. Minor, but removes a variable that exists solely to be addressable.
(Ging-Go)
🤖
| var mcpCleanup func() | ||
| cleanup := func() { | ||
| if mcpCleanup != nil { | ||
| mcpCleanup() | ||
| } | ||
| workspaceCtx.close() | ||
| } | ||
| defer func() { | ||
| if err != nil { | ||
| cleanup() | ||
| } | ||
| }() |
There was a problem hiding this comment.
Note [CRF-5] Five reviewers independently noticed this restructuring incidentally fixes a latent MCP connection leak.
In the old code, cleanup() at the g2.Wait() error return (base ~line 276) was just workspaceCtx.close(). The mcpCleanup chaining into cleanup happened after that error check (base ~line 280). Since errgroup.Wait() guarantees all goroutines complete before returning, the MCP goroutine had already set mcpCleanup, but it was never called on that error path. MCP connections leaked until context cancellation.
The new code captures mcpCleanup by reference from the start, so every error path (including the g2.Wait() path) correctly tears down MCP connections. Low practical impact (triggers only when ConvertMessagesWithFiles fails with active MCP configs), but the correctness improvement is real and worth noting in the PR description.
(Hisoka, Pariston, Meruem, Mafuuu, Kite)
🤖
Addresses deferred review feedback on
generation_preparer.gofrom PR #26109:This moves the default chat max output tokens to a documented constant, reuses the existing
errin advisor setup, and centralizes generation preparation cleanup behind the named return error path.Generated by Coder Agents.