fix: use shared scratch helpers in dev-agent and action-agent to eliminate duplicates (#262)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d9e216e33
commit
6405ac9837
3 changed files with 8 additions and 35 deletions
|
|
@ -24,6 +24,7 @@ export PROJECT_TOML="${2:-${PROJECT_TOML:-}}"
|
||||||
|
|
||||||
source "$(dirname "$0")/../lib/env.sh"
|
source "$(dirname "$0")/../lib/env.sh"
|
||||||
source "$(dirname "$0")/../lib/agent-session.sh"
|
source "$(dirname "$0")/../lib/agent-session.sh"
|
||||||
|
source "$(dirname "$0")/../lib/formula-session.sh"
|
||||||
# shellcheck source=../dev/phase-handler.sh
|
# shellcheck source=../dev/phase-handler.sh
|
||||||
source "$(dirname "$0")/../dev/phase-handler.sh"
|
source "$(dirname "$0")/../dev/phase-handler.sh"
|
||||||
SESSION_NAME="action-${ISSUE}"
|
SESSION_NAME="action-${ISSUE}"
|
||||||
|
|
@ -168,22 +169,8 @@ if [ -n "${_thread_id:-}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Read scratch file (compaction survival) ---
|
# --- Read scratch file (compaction survival) ---
|
||||||
SCRATCH_CONTEXT=""
|
SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE")
|
||||||
if [ -f "$SCRATCH_FILE" ]; then
|
SCRATCH_INSTRUCTION=$(build_scratch_instruction "$SCRATCH_FILE")
|
||||||
SCRATCH_CONTEXT="## Previous context (from scratch file)
|
|
||||||
$(cat "$SCRATCH_FILE")
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
SCRATCH_INSTRUCTION="## Context scratch file (compaction survival)
|
|
||||||
|
|
||||||
Periodically (every 10-15 tool calls), write a summary of:
|
|
||||||
- What you have discovered so far
|
|
||||||
- Decisions made and why
|
|
||||||
- What remains to do
|
|
||||||
to: ${SCRATCH_FILE}
|
|
||||||
|
|
||||||
If you find this file exists when you start, read it first — it is your previous context.
|
|
||||||
This file is ephemeral — not evidence or permanent memory, just a compaction survival mechanism."
|
|
||||||
|
|
||||||
# --- Build initial prompt ---
|
# --- Build initial prompt ---
|
||||||
PRIOR_SECTION=""
|
PRIOR_SECTION=""
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ set -euo pipefail
|
||||||
# Load shared environment
|
# Load shared environment
|
||||||
source "$(dirname "$0")/../lib/env.sh"
|
source "$(dirname "$0")/../lib/env.sh"
|
||||||
source "$(dirname "$0")/../lib/agent-session.sh"
|
source "$(dirname "$0")/../lib/agent-session.sh"
|
||||||
|
source "$(dirname "$0")/../lib/formula-session.sh"
|
||||||
# shellcheck source=./phase-handler.sh
|
# shellcheck source=./phase-handler.sh
|
||||||
source "$(dirname "$0")/phase-handler.sh"
|
source "$(dirname "$0")/phase-handler.sh"
|
||||||
|
|
||||||
|
|
@ -499,22 +500,8 @@ fi
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# READ SCRATCH FILE (compaction survival)
|
# READ SCRATCH FILE (compaction survival)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
SCRATCH_CONTEXT=""
|
SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE")
|
||||||
if [ -f "$SCRATCH_FILE" ]; then
|
SCRATCH_INSTRUCTION=$(build_scratch_instruction "$SCRATCH_FILE")
|
||||||
SCRATCH_CONTEXT="## Previous context (from scratch file)
|
|
||||||
$(cat "$SCRATCH_FILE")
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
SCRATCH_INSTRUCTION="## Context scratch file (compaction survival)
|
|
||||||
|
|
||||||
Periodically (every 10-15 tool calls), write a summary of:
|
|
||||||
- What you have discovered so far
|
|
||||||
- Decisions made and why
|
|
||||||
- What remains to do
|
|
||||||
to: ${SCRATCH_FILE}
|
|
||||||
|
|
||||||
If you find this file exists when you start, read it first — it is your previous context.
|
|
||||||
This file is ephemeral — not evidence or permanent memory, just a compaction survival mechanism."
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# BUILD PROMPT
|
# BUILD PROMPT
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,11 @@ about CI health, issue staleness, agent status, and system conditions.
|
||||||
## Project context
|
## Project context
|
||||||
${CONTEXT_BLOCK}
|
${CONTEXT_BLOCK}
|
||||||
${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT}
|
${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT}
|
||||||
}
|
}${SCRATCH_INSTRUCTION}
|
||||||
|
|
||||||
## Formula
|
## Formula
|
||||||
${FORMULA_CONTENT}
|
${FORMULA_CONTENT}
|
||||||
|
|
||||||
${SCRATCH_INSTRUCTION}
|
|
||||||
|
|
||||||
${PROMPT_FOOTER}"
|
${PROMPT_FOOTER}"
|
||||||
|
|
||||||
# ── Run session ──────────────────────────────────────────────────────────
|
# ── Run session ──────────────────────────────────────────────────────────
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue