Skip to content

feat(coding-agent): refine.preview and pinned refine.run plan_id - #899

Open
nate-benhra wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
nate-benhra:feat/refine-preview
Open

feat(coding-agent): refine.preview and pinned refine.run plan_id#899
nate-benhra wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
nate-benhra:feat/refine-preview

Conversation

@nate-benhra

@nate-benhra nate-benhra commented Aug 8, 2026

Copy link
Copy Markdown

Adds a preview/approve flow for continual harness refinement (closes #684).

Commit 1 — refine.preview(): new kernel host request that runs the existing planning phase (_planRefine) and returns the proposed edits (plan_id, summary, rationale, expected outcome, per-edit action/kind/id/title/content/reason) without scheduling or applying anything. refine.status() now also reports the pending request content and cached preview ids. Preview waits for planning quiescence before claiming the refine abort-controller slot, so it never races a serialized background plan.

Commit 2 — refine.run(plan_id=...): applies exactly the previewed plan instead of re-planning. Previewed plans are cached on the session (cap 5) with branch-version validity, and are invalidated on branch change, abort, compaction, dispose, and any applied refinement. Pinning a plan while a serialized background plan is in flight re-stamps the pin after the standard invalidation bump, so an accepted pin survives to its turn-boundary apply. The serialized-refine path resolves a pinned plan through the existing background-plan rail; the existing baselineState conflict rejection guards state that changed between preview and apply.

Not covered here, intentionally: gating auto-refine or agent-initiated refine.run() through a preview. A natural follow-up is a refineProposalReviewer hook on AgentSessionConfig (the post-plan sibling of #201's pre-plan autoRefineReviewer) called between plan and apply; serializeRefinementPlan() and the held-plan apply added here are built to be reused by it. Happy to take that on if there's interest.

Validation:

  • npm run check
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/refinement.test.ts
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-refine-skill.test.ts
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-serialized-refine.test.ts
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-queue.test.ts
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/serialized-refine-config-integration.test.ts

Note

Add refine.preview endpoint and plan_id pinning to refine.run in coding agent

  • Introduces refine.preview host request handler in agent-session.ts that runs the refinement planning pass and returns a serialized plan without applying it, caching up to 5 previewed plans per branch.
  • Adds plan_id parameter to refine.run so a previously previewed plan can be applied exactly without re-planning; serialized mode short-circuits background planning when a pinned planId is present.
  • Adds a serializeRefinementPlan utility in refinement.ts that produces snake_case kernel-facing payloads for previewed plans.
  • Exposes the new refine.preview skill function in the Python skill layer via refine/__init__.py.
  • Risk: applying an unknown or branch-invalidated plan_id throws an error rather than falling back to re-planning.

Macroscope summarized 3dec9ad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show refine.run() diff before applying, not after

1 participant