fix: use --agent squad with Farnsworth prompt in CI (#142)

* Scribe: Archive team sync — merge decisions inbox, trim Leela history - Merged 4 inbox decision files into .squad/decisions.md (Farnsworth: correlations/divergence/no-ai narratives; Leela: CI self-learning pipeline) - Cleared .squad/decisions/inbox/ (deleted leela-ci-self-learning.md; others not tracked) - Trimmed .squad/agents/leela/history.md from 15.9KB to 3.2KB (archived to history-archive.md) - Updated both agent histories with team sync completion record - Scribe tasks: PRE-CHECK (31.4KB decisions), ARCHIVE (none older than 30d), INBOX (4 files merged), LOG written, CROSS-AGENT appended, SUMMARIZATION executed Measured outcomes: - Before: decisions.md 31436B, inbox 4 files, Leela history 15927B - After: decisions.md (merged), inbox 0 files, Leela history 3183B, archive created - All squad/ changes staged and clean for commit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: use agent name not path in --agent flag The Copilot CLI --agent flag takes the agent name from YAML frontmatter, not a file path. Changed from '.github/agents/farnsworth.agent.md' to 'Farnsworth' in both the analysis and reskill jobs. Also simplified the -p prompts since the agent file already contains full identity and instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: use --agent squad with Farnsworth prompt in CI The --agent flag takes the agent name, not a file path. Use 'squad' to load the Squad coordinator, then address Farnsworth in the prompt to route the analysis work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Juan Manuel Servera committed May 19, 2026 at 23:29 UTC ad896c44b4a7e76a0d369bc7f03b72fca132560e
3 files changed +94 -68
.github/workflows/crawl-and-publish.yml
+4 -4
@@ -300,8 +300,8 @@ jobs:
300 fi
301
302 if command -v copilot >/dev/null 2>&1 && copilot \
303 - --agent Farnsworth \
304 - -p "Read the file at ${PROMPT_FILE} — it contains the weekly data and analysis instructions. Follow them exactly and write the analysis to ${OUTPUT_FILE}." \
303 + --agent squad \
304 + -p "Farnsworth, read the file at ${PROMPT_FILE} — it contains the weekly data and analysis instructions. Follow them exactly and write the analysis to ${OUTPUT_FILE}." \
305 -s \
306 --no-ask-user \
307 --model claude-sonnet-4 \
@@ -743,8 +743,8 @@ jobs:
743 python3 scripts/reskill.py --current-datetime "$CURRENT_DATETIME" --output "$RESKILL_OUTPUT" --prompt-output "$RESKILL_PROMPT" --print-prompt > "$RESKILL_PROMPT" || true
744
745 if command -v copilot >/dev/null 2>&1 && copilot \
746 - --agent Farnsworth \
747 - -p "Read the file at ${RESKILL_PROMPT} — it contains the reskill retrospective instructions. Follow them exactly and write the report to ${RESKILL_OUTPUT}." \
746 + --agent squad \
747 + -p "Farnsworth, read the file at ${RESKILL_PROMPT} — it contains the reskill retrospective instructions. Follow them exactly and write the report to ${RESKILL_OUTPUT}." \
748 -s \
749 --no-ask-user \
750 --model claude-sonnet-4 \
.squad/decisions/inbox/leela-ci-self-learning.md deleted
-64
@@ -1,64 +0,0 @@
1 -# Decision: CI Self-Learning Pipeline Architecture
2 -
3 -**Date:** 2026-05-19T22:57:55+02:00
4 -**Author:** Leela (Lead/Architect)
5 -**Status:** Proposed
6 -**Scope:** Analysis and reskill CI jobs — self-learning loop
7 -
8 -## Context
9 -
10 -The CI pipeline runs AI analysis (Copilot CLI) and reskill (GitHub Models API) but neither job leverages the squad agent system. The analysis agent has no identity, cannot read its own history/skills, and has no mechanism to write learnings back. The reskill job bypasses Copilot CLI entirely and uses a model (`openai/gpt-4.1`) that returns 403.
11 -
12 -## Decisions
13 -
14 -### 1. Dedicated Farnsworth Agent File (`.github/agents/farnsworth.agent.md`)
15 -
16 -A standalone agent file gives the Copilot CLI the full Farnsworth identity — charter, history reading instructions, post-analysis learning format, and write permissions to `.squad/`.
17 -
18 -**Rationale:** The `--agent` flag loads an agent markdown file with YAML frontmatter and instructions. A dedicated file allows CI-specific directives (learning output format, file write permissions) without polluting the interactive Squad coordinator agent.
19 -
20 -### 2. `--agent` Flag in Copilot CLI Invocations
21 -
22 -Both the analysis and reskill jobs now use:
23 -```bash
24 -copilot --agent .github/agents/farnsworth.agent.md ...
25 -```
26 -
27 -**Rationale:** This loads Farnsworth's identity, making the CLI aware of the agent's history, wisdom, skills, and learning expectations.
28 -
29 -### 3. Learning Commit Strategy: Same Branch, Same Job
30 -
31 -After analysis, `.squad/` changes (history, skills) are committed alongside `data/analyzed/` to the `publish` data branch in a single atomic commit.
32 -
33 -**Rationale:** No additional branch/PR overhead. The data branch is unprotected and already receives CI commits. Learnings are part of the analysis artifact — they should be co-located temporally. The reskill job already commits `.squad/` state via the same pattern.
34 -
35 -### 4. Model Fallback: `openai/gpt-4o` Replaces `openai/gpt-4.1`
36 -
37 -The default model for GitHub Models API fallback is changed from `openai/gpt-4.1` (which returns 403) to `openai/gpt-4o` (widely accessible).
38 -
39 -**Rationale:** `gpt-4.1` is not accessible via the GitHub Models API for this repository's token. `gpt-4o` is the current generally available model. The env var `GITHUB_MODELS_MODEL` still allows override.
40 -
41 -### 5. Reskill Primary Path: Copilot CLI with Agent
42 -
43 -The reskill job now tries Copilot CLI first (with agent identity), falling back to GitHub Models API if CLI is unavailable. This gives reskill the same agent-aware capabilities as analysis: read wisdom/skills/history, write updated wisdom and learnings back.
44 -
45 -**Rationale:** The reskill cycle is the primary mechanism for reinforcing the learning loop. With agent identity, it can directly update `wisdom.md` and `history.md` based on retrospective findings — the core of self-improvement.
46 -
47 -### 6. Prompt Template Unchanged
48 -
49 -The existing prompt templates (`prompts/analyze-weekly.md`, `prompts/reskill.md`) already inject wisdom and skills via `{{WISDOM}}` and `{{SKILLS}}` placeholders. The agent file complements this by providing identity context and learning output instructions that the templates alone cannot express.
50 -
51 -## Risks
52 -
53 -| Risk | Mitigation |
54 -|------|-----------|
55 -| Agent writes bad content to `.squad/` files | Quality gate still runs on analysis output; .squad changes are append-only learnings |
56 -| Copilot CLI doesn't support `--agent` as expected | Fallback path (GitHub Models via reskill.py) still works without agent identity |
57 -| Learning state diverges between publish branch and main | Periodic sync PRs already exist; learnings on publish are forward-compatible |
58 -
59 -## Implementation
60 -
61 -- [x] `.github/agents/farnsworth.agent.md` — agent identity file
62 -- [x] `.github/workflows/crawl-and-publish.yml` — `--agent` flag, learning commits, model fix
63 -- [x] `scripts/reskill.py` — model default updated to `openai/gpt-4o`
64 -- [x] `scripts/analyze_fallback.py` — model default updated to `openai/gpt-4o`
.squad/health-2026-05-19T20:57:55Z.md new
+90
@@ -0,0 +1,90 @@
1 +# Scribe Health Report — 2026-05-19T20:57:55Z
2 +
3 +## Pre-Archival Measurements
4 +
5 +| Metric | Before |
6 +|--------|--------|
7 +| `decisions.md` size | 31436 bytes (30.7 KB) |
8 +| `decisions.md` status | ≥ 20480 threshold → requires archival if entries > 30 days old |
9 +| `.squad/decisions/inbox/` files | 4 files |
10 +| `inbox/` size | 9,652 bytes total |
11 +| Leela `history.md` | 15927 bytes (15.5 KB) ≥ 15360 threshold |
12 +| Farnsworth `history.md` | 9861 bytes (normal) |
13 +
14 +## Actions Taken
15 +
16 +### 1. Decisions Archive Check
17 +- **Result:** No entries older than 30 days (all entries from 2026-05-18/19)
18 +- **Action taken:** Skip archive (threshold gate passed, but no old entries)
19 +
20 +### 2. Decisions Inbox Merge
21 +- **Files merged:** 4 items from `.squad/decisions/inbox/`
22 + 1. `farnsworth-divergence-narrative.md` (1,697 bytes)
23 + 2. `farnsworth-no-ai-reader-mode.md` (1,931 bytes)
24 + 3. `farnsworth-correlation-narrative.md` (2,047 bytes)
25 + 4. `leela-ci-self-learning.md` (3,977 bytes)
26 +- **Insertion point:** Before `## Governance` section (line 743)
27 +- **Deletion:** All inbox files deleted
28 +- **Deduplication:** None required (all 4 items were new)
29 +
30 +### 3. Orchestration Logs Written
31 +- `.squad/orchestration-log/2026-05-19T20:57:55Z-farnsworth.md` (788 bytes)
32 + - Outcome: PR #139 merged (correlation narrative + reskill 403 fix, 513 tests pass)
33 + - Changes: render_press_context.py, analyze_fallback.py, reskill.py
34 +- `.squad/orchestration-log/2026-05-19T20:57:55Z-leela.md` (727 bytes)
35 + - Outcome: PR #140 merged (CI self-learning pipeline with agent identity)
36 + - Changes: crawl-and-publish.yml, farnsworth.agent.md (new), reskill.py, analyze_fallback.py
37 +
38 +### 4. Session Log Written
39 +- `.squad/log/2026-05-19T20:57:55Z-team-sync.md` (487 bytes)
40 + - Brief summary of both agents' outcomes and scribe actions
41 +
42 +### 5. Cross-Agent Updates
43 +- **Farnsworth history:** Added final team-sync record (PR #139 merge outcome, decision recorded)
44 +- **Leela history:** Added CI self-learning record (already in history), plus final team-sync record
45 +
46 +### 6. History Summarization
47 +- **Leela history before:** 15,927 bytes (exceeded 15KB threshold)
48 +- **Leela history after:** 3,183 bytes (trimmed to recent 48-hour entries)
49 +- **Archive created:** `.squad/agents/leela/history-archive.md` (5,627 bytes)
50 + - Contains comprehensive summary + list of all archived entries (18 total)
51 + - Entries archived: All Phase 0–Phase 1 work from 2026-05-18 through 2026-05-19T18:05
52 +- **Farnsworth history:** 9,861 bytes (no archival needed)
53 +
54 +### 7. Git Commit
55 +- **Files staged:**
56 + - `M .squad/agents/farnsworth/history.md`
57 + - `M .squad/agents/leela/history.md`
58 + - `A .squad/agents/leela/history-archive.md`
59 + - `M .squad/decisions.md`
60 + - `D .squad/decisions/inbox/leela-ci-self-learning.md`
61 +- **Commit:** `fae8e43` — "Scribe: Archive team sync — merge decisions inbox, trim Leela history"
62 +- **Status:** Committed successfully (--no-gpg-sign due to non-TTY environment)
63 +
64 +## Post-Archival Measurements
65 +
66 +| Metric | After |
67 +|--------|-------|
68 +| `decisions.md` size | ~39 KB (increased by 4 merged items) |
69 +| `.squad/decisions/inbox/` files | 0 files (cleared) |
70 +| Leela `history.md` | 3,183 bytes (trimmed below threshold) |
71 +| Leela `history-archive.md` | 5,627 bytes (new archive) |
72 +| Farnsworth `history.md` | 10,300 bytes (appended team-sync) |
73 +| Git commit | Ready (0 unstaged changes in .squad/) |
74 +
75 +## Summary
76 +
77 +- ✅ Pre-check recorded
78 +- ✅ Archive gate passed (no entries > 30d)
79 +- ✅ 4 inbox items merged, inbox cleared
80 +- ✅ 2 orchestration logs written (not tracked, in .gitignore)
81 +- ✅ 1 session log written (not tracked, in .gitignore)
82 +- ✅ Both agent histories updated
83 +- ✅ Leela history summarized (15.9KB → 3.2KB + archive)
84 +- ✅ Git commit clean
85 +- ✅ All 8 Scribe tasks completed
86 +- ✅ Health report written
87 +
88 +## Ready for Next Cycle
89 +
90 +Team decision pipeline is synchronized. Agent learnings recorded. Orchestration logs archived (local, not version-controlled per policy). History trimmed. System ready for next run.