[codex] Replace local chat delegation with backend snapshot answers#217
[codex] Replace local chat delegation with backend snapshot answers#217sergekh2 wants to merge 2 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0aef48c. Configure here.
| } | ||
| return { ok: true }; | ||
| ); | ||
| return result; |
There was a problem hiding this comment.
Concurrent delegated-work requests cause double LLM spend
Low Severity
There's a TOCTOU race between the SELECT that validates the delegation placeholder (checking isNotNull(delegation)) and the UPDATE that clears it. Two concurrent requests for the same delegation both pass validation, both call answerDelegatedWork (consuming LLM budget twice), and only the first UPDATE succeeds. The second UPDATE silently affects zero rows, and the code doesn't check the update result count, so the double-spend goes undetected.
Reviewed by Cursor Bugbot for commit 0aef48c. Configure here.


Summary
/api/chat/threads/:threadId/delegated-work, where the backend validates the placeholder/task/repo, calls Anthropic, and persists the final answer.Security posture
Validation
bun run typecheckinapps/desktopbun run typecheckinapps/serverbun run typecheckinpackages/sharedbun run testinapps/desktopbun run testinapps/serverbun run gen:db-schema:checkinapps/servergit diff --checkbun run lintinapps/desktoppassed with one existing warning inAgentRuntimeFields.tsxNote
Medium Risk
Changes the Ask delegation flow end-to-end (desktop IPC, shared API contracts, and new server route that validates repo visibility then calls Anthropic and writes chat history), so regressions could affect chat persistence/billing and access control. Snapshot data is bounded, but the new server-side composition path adds new validation and error-handling branches that need review.
Overview
Replaces Ask “delegation” from a desktop-run Claude Agent SDK to a bounded, metadata-only repo snapshot collected on desktop and summarized on the backend.
The desktop now collects a fixed
ChatWorkSnapshot(git branch/HEAD/status, changed files, diffstat, recent commits, and optionalgh pr list-based related PRs) and posts it to a newPOST /api/chat/threads/:threadId/delegated-workendpoint; the server validates the placeholder message/task and that the repo is visible to the caller, then calls Anthropic to compose the final answer, records LLM spend, and finalizes the stored chat turn.Updates shared types/contracts and UI copy to reflect snapshot-based answers, removes the old desktop
chatDelegateagent runner, and adds tests for snapshot collection and the new delegated-work route (including budget/error and repo/task mismatch defenses).Reviewed by Cursor Bugbot for commit 0aef48c. Bugbot is set up for automated code reviews on this repo. Configure here.