Skip to content

Commit 737863e

Browse files
authored
fix: scope per-file review sessions to runId, use sessions.create() (#31971)
1 parent 6e97b1c commit 737863e

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

.flue/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Workflows are invoked in **accepted mode** via `admitWorkflow` (`lib/poll-run.ts
5858

5959
- One named harness over the shell-sandbox Workspace (`connectors/cloudflare-shell.ts`), then one **detached session per changed file**, run with bounded concurrency (`withConcurrency`).
6060
- **Each session is deleted in a `finally` as soon as its file finishes** (`session.delete()`), so peak heap is bounded to ~concurrency live sessions instead of growing with the file count. This is what fixed the specialist DO OOM.
61+
- **Per-file sessions must be run-scoped and created fresh.** Specialist DOs are reused across workflow runs. If a run is hard-evicted before `finally` runs, its named sessions survive in the DO's SQLite. To prevent a new run from resuming stale session history from a prior run: (1) include `runId` in every session name (e.g. `` `${runId}:sg:${index}` ``), and (2) acquire sessions via `harness.sessions.create(name)` (throws if already exists) rather than `harness.session(name)` (silent get-or-create). The `create()` API makes any unexpected name collision loud rather than silently wrong.
6162
- Caps: both fan-outs review at most **20** files (largest-diff-first) at **concurrency 5**. A single file's failure is caught and degraded to an empty result — it never aborts the pool. Per-file results are merged and deduped by finding id.
6263
- **Code review** reviews _all_ changed text files (excluding lockfiles, `dist`/`skills`/`node_modules`, `.wrangler`, `src/assets`, and binary/image types). It emits `critical`/`warning`/`suggestion` severities with `CR-` ids and gives the model GitHub-API-backed tools (`read_repo_file` pinned to the PR head SHA, `search_repo`) so it can read full post-change file content for context — the diff patch alone is staged, but correctness review needs the surrounding code. The token stays in trusted code; only tool results cross into the sandbox. The repo's root `AGENTS.md` is fetched from the **PR base ref** (trusted, not head) and injected as agent `instructions`.
6364
- **Style guide** reviews only `src/content/(docs|partials|changelog)/**.mdx`, emits `warning`/`suggestion` only, and uses the bundled `style-guide-review` skill and its reference tree.

.flue/lib/code-review-inproc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export async function runCodeReviewInProcess(
325325

326326
const result = await reviewSingleFile({
327327
harness,
328-
sessionName: `cr:${index}`,
328+
sessionName: `${runId}:cr:${index}`,
329329
pullRequest,
330330
filename: file.filename,
331331
addedLines,
@@ -401,7 +401,7 @@ async function reviewSingleFile({
401401
prNumber: number;
402402
runId: string;
403403
}): Promise<CodeReviewResult> {
404-
const session = await harness.session(sessionName);
404+
const session = await harness.sessions.create(sessionName);
405405

406406
// Bound the per-file session so one wedged file cannot hold a concurrency
407407
// slot for the orchestrator's whole poll. On timeout we ABORT the operation

.flue/lib/style-guide-inproc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export async function runStyleGuideReviewInProcess(
204204

205205
const result = await reviewSingleFile({
206206
harness,
207-
sessionName: `sg:${index}`,
207+
sessionName: `${runId}:sg:${index}`,
208208
pullRequest,
209209
diffDir,
210210
filename,
@@ -271,7 +271,7 @@ async function reviewSingleFile({
271271
filename: string;
272272
fileTimeoutMs: number;
273273
}): Promise<StyleGuideResult> {
274-
const session = await harness.session(sessionName);
274+
const session = await harness.sessions.create(sessionName);
275275

276276
// Bound the per-file session so one wedged file cannot hold a concurrency
277277
// slot for the orchestrator's whole poll. On timeout we ABORT the operation

0 commit comments

Comments
 (0)