Compare commits

..

1 commit

Author SHA1 Message Date
Agent
25433eaf67 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:37:36 +00:00

View file

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