fix: fix: architect should resume session when processing answers on an accepted sprint PR (#436) #449

Merged
dev-qwen merged 1 commit from fix/issue-436 into main 2026-04-08 19:43:48 +00:00
Collaborator

Fixes #436

Changes

Fixes #436 ## Changes
dev-qwen added 1 commit 2026-04-08 19:30:38 +00:00
fix: fix: architect should resume session when processing answers on an accepted sprint PR (#436)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
c8f1bc5c6b
When the architect processes human answers to design questions (answer_parsing step),
it now resumes the session from the research/questions run instead of starting fresh.
This preserves Claude's deep codebase understanding from the research phase, ensuring
sub-issues include specific file references and implementation details.

Changes:
- architect-run.sh: Added detect_questions_phase() to check if PR is in questions phase
  (has `## Design forks` section and question comments). If so, resume the session
  from SID_FILE to preserve context.
- formulas/run-architect.toml: Documented session resumption behavior in answer_parsing step.

Session is only preserved when PR is in questions-awaiting-answers phase. Fresh sessions
are started for new pitches (no stale context from old sprints).
Collaborator

AI Review

Critical Bug: Empty RESUME_MODE Breaks agent_run (Regression)

critical architect-run.sh:192: The call agent_run "$RESUME_MODE" --worktree "$WORKTREE" "$PROMPT" is broken when RESUME_MODE is empty — which is the common case (non-questions-phase runs, or questions-phase with no SID_FILE).

When RESUME_MODE="", bash expands this to agent_run "" --worktree .... Inside agent_run (lib/agent-sdk.sh:35), the arg-parse loop is while [[ "${1:-}" == --* ]]. An empty string fails that test, so the loop never runs. Then local prompt="${1:-}" captures "" as the prompt, and --worktree / $WORKTREE / $PROMPT at positions $2–$4 are silently ignored. Claude is invoked with an empty prompt (-p "") and run_dir=$(pwd) instead of the worktree.

This is a regression: the pre-PR call was agent_run --worktree "$WORKTREE" "$PROMPT" which worked correctly.

Fix: use a bash array instead of a string variable:

RESUME_ARGS=()
if detect_questions_phase && [ -f "$SID_FILE" ]; then
  RESUME_SESSION=$(cat "$SID_FILE")
  RESUME_ARGS=(--resume "$RESUME_SESSION")
  log "Resuming session..."
fi
agent_run "${RESUME_ARGS[@]}" --worktree "$WORKTREE" "$PROMPT"

Medium Bug: Question Detection Regex Can Never Match

bug architect-run.sh:162: The grep pattern '"body"[^"]*Q[0-9]+:' cannot match Q-prefixed questions inside JSON-quoted values.

For JSON like {"body":"Q1: What approach..."}, matching proceeds: "body" matches the key, [^"]* matches only the : separator (stops at the opening " of the value), and Q[0-9]+: then needs to match " — it never can. The detection always returns 1, so RESUME_MODE is permanently empty and Bug 1 is hit on every run.

Fix: pipe through jq to extract the body text before grepping:

if ! printf '%s' "$comments" | jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'; then

Verdict

REQUEST_CHANGES — Two bugs: empty RESUME_MODE string breaks agent_run on every non-questions-phase run (regression), and the grep regex cannot match Q-patterns inside JSON string values (detection always fails)


Reviewed at c8f1bc5 | AGENTS.md

## AI Review <!-- reviewed: c8f1bc5c6b8e0221feb746e41c980170b49b0f8e --> ### Critical Bug: Empty RESUME_MODE Breaks agent_run (Regression) **critical** `architect-run.sh:192`: The call `agent_run "$RESUME_MODE" --worktree "$WORKTREE" "$PROMPT"` is broken when `RESUME_MODE` is empty — which is the **common case** (non-questions-phase runs, or questions-phase with no SID_FILE). When `RESUME_MODE=""`, bash expands this to `agent_run "" --worktree ...`. Inside `agent_run` (lib/agent-sdk.sh:35), the arg-parse loop is `while [[ "${1:-}" == --* ]]`. An empty string fails that test, so the loop never runs. Then `local prompt="${1:-}"` captures `""` as the prompt, and `--worktree` / `$WORKTREE` / `$PROMPT` at positions $2–$4 are silently ignored. Claude is invoked with an empty prompt (`-p ""`) and `run_dir=$(pwd)` instead of the worktree. This is a regression: the pre-PR call was `agent_run --worktree "$WORKTREE" "$PROMPT"` which worked correctly. Fix: use a bash array instead of a string variable: ```bash RESUME_ARGS=() if detect_questions_phase && [ -f "$SID_FILE" ]; then RESUME_SESSION=$(cat "$SID_FILE") RESUME_ARGS=(--resume "$RESUME_SESSION") log "Resuming session..." fi agent_run "${RESUME_ARGS[@]}" --worktree "$WORKTREE" "$PROMPT" ``` ### Medium Bug: Question Detection Regex Can Never Match **bug** `architect-run.sh:162`: The grep pattern `'"body"[^"]*Q[0-9]+:'` cannot match Q-prefixed questions inside JSON-quoted values. For JSON like `{"body":"Q1: What approach..."}`, matching proceeds: `"body"` matches the key, `[^"]*` matches only the `:` separator (stops at the opening `"` of the value), and `Q[0-9]+:` then needs to match `"` — it never can. The detection always returns 1, so `RESUME_MODE` is permanently empty and Bug 1 is hit on every run. Fix: pipe through jq to extract the body text before grepping: ```bash if ! printf '%s' "$comments" | jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'; then ``` ### Verdict **REQUEST_CHANGES** — Two bugs: empty RESUME_MODE string breaks agent_run on every non-questions-phase run (regression), and the grep regex cannot match Q-patterns inside JSON string values (detection always fails) --- *Reviewed at `c8f1bc5` | [AGENTS.md](AGENTS.md)*
review-bot requested changes 2026-04-08 19:34:14 +00:00
Dismissed
review-bot left a comment
Collaborator

AI Review: REQUEST_CHANGES — Two bugs: empty RESUME_MODE string breaks agent_run on every non-questions-phase run (regression), and the grep regex cannot match Q-patterns inside JSON string values (detection always fails)

AI Review: **REQUEST_CHANGES** — Two bugs: empty RESUME_MODE string breaks agent_run on every non-questions-phase run (regression), and the grep regex cannot match Q-patterns inside JSON string values (detection always fails)
dev-qwen force-pushed fix/issue-436 from c8f1bc5c6b to 25433eaf67 2026-04-08 19:37:41 +00:00 Compare
Collaborator

AI Re-review (round 2)

Previous Findings

  • Empty RESUME_MODE breaks agent_run → FIXED: Changed to RESUME_ARGS=() array with agent_run "${RESUME_ARGS[@]}". Correct approach.
  • grep regex can't match inside JSON string values → FIXED: Now uses jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'. Correct.

New Issues

  • minor architect-run.sh:184: detect_questions_phase is called a second time in the elif branch, doubling the API calls (3 curl requests × 2) on the non-questions-phase path. Not a bug — logic is correct — but a simple boolean capture (if detect_questions_phase; then _in_phase=1; fi) would avoid the redundancy. Not blocking.

Verdict

APPROVE — Both previous findings fixed: array-based RESUME_ARGS and jq-based comment body extraction


Reviewed at 25433ea | Previous: c8f1bc5 | AGENTS.md

## AI Re-review (round 2) <!-- reviewed: 25433eaf6783f0278e93499a25cf85a125cc59b9 --> ### Previous Findings - **Empty RESUME_MODE breaks agent_run** → FIXED: Changed to `RESUME_ARGS=()` array with `agent_run "${RESUME_ARGS[@]}"`. Correct approach. - **grep regex can't match inside JSON string values** → FIXED: Now uses `jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'`. Correct. ### New Issues - **minor** `architect-run.sh:184`: `detect_questions_phase` is called a second time in the `elif` branch, doubling the API calls (3 curl requests × 2) on the non-questions-phase path. Not a bug — logic is correct — but a simple boolean capture (`if detect_questions_phase; then _in_phase=1; fi`) would avoid the redundancy. Not blocking. ### Verdict **APPROVE** — Both previous findings fixed: array-based RESUME_ARGS and jq-based comment body extraction --- *Reviewed at `25433ea` | Previous: `c8f1bc5` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-08 19:43:13 +00:00
review-bot left a comment
Collaborator

AI Re-review (round 2): APPROVE — Both previous findings fixed: array-based RESUME_ARGS and jq-based comment body extraction

AI Re-review (round 2): **APPROVE** — Both previous findings fixed: array-based RESUME_ARGS and jq-based comment body extraction
dev-qwen merged commit dd07047635 into main 2026-04-08 19:43:48 +00:00
dev-qwen deleted branch fix/issue-436 2026-04-08 19:43:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#449
No description provided.