Skip to content

fix(plan): repeat Q&A and draft decisions inline in each plan prompt - #488

Closed
Master-Norna wants to merge 1 commit into
umputun:masterfrom
Master-Norna:fix/plan-session-history-inline
Closed

Master-Norna wants to merge 1 commit into
umputun:masterfrom
Master-Norna:fix/plan-session-history-inline

Conversation

@Master-Norna

Copy link
Copy Markdown
Contributor

Summary

Plan mode is the one place where the progress file carries control flow: the questions, the answers and the DRAFT REVIEW: … decision (with the revise feedback) reach the executor only through that file, and the prompt tells it to read them from there. The logger opens the file once and appends to it for the whole run (pkg/progress/progress.go), so an executor behind a shared filesystem can keep reading a snapshot taken before the append — the setup in #438 (executor in a Docker Sandbox, workspace on virtiofs) has the agent re-ask the same question on every iteration and never see the draft decision.

As you noted in #438, open/close per write would need a sidecar lock because the flock on that file is the active-session signal, so plan mode now carries the exchange with it as well.

Fix

planSession in pkg/processor/phase/plan_creation.go keeps what the run already knows: each question with its answer, each draft review with its feedback. runIteration appends a SESSION HISTORY block to the plan prompt when the session has entries. The block is empty on the first iteration, so the first prompt stays byte-identical to master, and PREVIOUS DRAFT FEEDBACK is untouched.

The block uses the same lines the progress file records (QUESTION:, ANSWER:, DRAFT REVIEW:, FEEDBACK:), so the template can treat it as an alternative source: the accept / revise / reject decision points in pkg/config/defaults/prompts/make_plan.txt now read "the progress file or the SESSION HISTORY block", and the Q&A instruction says the exchange is repeated inline from the second iteration on. CLAUDE.md gets the matching line under plan mode.

Validation

  • Four new tests in pkg/processor/phase/plan_creation_test.go, all four red on master (03ad9da) and green with the change: Q&A reaches the next prompt, an accepted draft is visible in the next prompt, a revise's feedback is visible in the next prompt, and a three-iteration run keeps one copy of each entry with the question before its answer.
  • The FEEDBACK: assertion is not trivially satisfied: dropping the feedback branch from addDraftDecision leaves the block in place and still turns that test red.
  • go test ./pkg/processor/... ./pkg/config/: the processor packages pass; pkg/config fails the same two permission-denied tests it fails on master.
  • go test ./...: the failure set matches master exactly — the same 22 environment-specific tests (Windows permission and symlink cases, codex CLI lookups, worktree tests).
  • golangci-lint run ./... (v2.13.0, repo config): 0 issues. gofmt, go vet: clean.

Agent Yan assisted participation

…mputun#438)

Plan mode is where the progress file carries control flow: the questions, the
answers and the draft decision (with the revise feedback) reach the executor
only through that file, and the prompt tells it to read them from there. The
logger opens the file once and appends to it for the whole run, so an executor
behind a shared filesystem can keep reading a snapshot taken before the append
(umputun#438): the agent re-asks the same question on every iteration
and never sees the draft decision.

Opening and closing the file per write would need a sidecar lock, since the
flock on that file is the active-session signal, so plan mode now carries the
exchange with it as well.

Each plan iteration prompt gets a SESSION HISTORY block with the questions,
answers and draft reviews accumulated in this run, including the feedback of a
revise. The block is empty on the first iteration, so the first prompt is
byte-identical to before, and PREVIOUS DRAFT FEEDBACK is left as it was. The
prompt template takes the block as an alternative source for the accept, revise
and reject decisions.

Co-Authored-By: Agent-Yan <352840372+Agent-Yan@users.noreply.github.com>
@umputun

umputun commented Nov 26, 2026

Copy link
Copy Markdown
Owner

closing this one. Docker Sandboxes fixed the held-fd problem in sbx v0.45.0 (docker/sbx-releases#488, closed 2026-10-04), so the condition I set in #438 for taking the inline workaround never happened. The supported ralphex-dk.sh path never had the problem either.

the implementation follows what I sketched in #438, and the sketch itself had a gap. After accept, the next session gets DRAFT REVIEW: accept inline, but the draft text still reaches it only through the progress file (it gets there as executor output). With a frozen file the session is told to write the accepted plan without having it, so it can write a plan rebuilt from the Q&A instead of the one the user accepted. If this ever comes back, the latest reviewed draft has to travel inline too.

@umputun umputun closed this Nov 26, 2026
umputun added a commit that referenced this pull request Nov 26, 2026
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.

2 participants