Compare commits

..

1 commit

Author SHA1 Message Date
Agent
c8f1bc5c6b 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
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).
2026-04-08 19:30:25 +00:00

View file

@ -155,12 +155,11 @@ detect_questions_phase() {
fi fi
# Check for question comments (Q1:, Q2:, etc.) # Check for question comments (Q1:, Q2:, etc.)
# Use jq to extract body text before grepping (handles JSON escaping properly)
local comments local comments
comments=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \ comments=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \
"${FORGE_API}/repos/${FORGE_OPS_REPO}/issues/${pr_number}/comments" 2>/dev/null) || return 1 "${FORGE_API}/repos/${FORGE_OPS_REPO}/issues/${pr_number}/comments" 2>/dev/null) || return 1
if ! printf '%s' "$comments" | jq -r '.[].body // empty' | grep -qE 'Q[0-9]+:'; then if ! printf '%s' "$comments" | grep -qE '"body"[^"]*Q[0-9]+:'; then
return 1 return 1
fi fi
@ -176,18 +175,21 @@ export CLAUDE_MODEL="sonnet"
# - If answers detected (PR in questions phase), resume prior session to preserve # - If answers detected (PR in questions phase), resume prior session to preserve
# codebase context from research/questions run # codebase context from research/questions run
# - Otherwise, start fresh (new pitch or PR not in questions phase) # - Otherwise, start fresh (new pitch or PR not in questions phase)
RESUME_ARGS=() RESUME_MODE=""
if detect_questions_phase && [ -f "$SID_FILE" ]; then if detect_questions_phase; then
RESUME_SESSION=$(cat "$SID_FILE") # PR is in questions phase — resume session if SID_FILE exists
RESUME_ARGS=(--resume "$RESUME_SESSION") if [ -f "$SID_FILE" ]; then
log "Resuming session from questions phase run: ${RESUME_SESSION:0:12}..." RESUME_SESSION=$(cat "$SID_FILE")
elif ! detect_questions_phase; then RESUME_MODE="--resume $RESUME_SESSION"
log "Resuming session from questions phase run: ${RESUME_SESSION:0:12}..."
else
log "No session ID found for questions phase — starting fresh session"
fi
else
log "PR not in questions phase — starting fresh session" log "PR not in questions phase — starting fresh session"
elif [ ! -f "$SID_FILE" ]; then
log "No session ID found for questions phase — starting fresh session"
fi fi
agent_run "${RESUME_ARGS[@]}" --worktree "$WORKTREE" "$PROMPT" agent_run "$RESUME_MODE" --worktree "$WORKTREE" "$PROMPT"
log "agent_run complete" log "agent_run complete"
rm -f "$SCRATCH_FILE" rm -f "$SCRATCH_FILE"