goal: /goal is the primitive; per-topic autopilot vs copilot
Summary
Magnus laid out a simpler product model: agency isn't a separate mode, it's the default. The primitive is /goal, one goal lives in its own Telegram topic forever, and each topic has a per-topic execution mode the user can toggle.
- One goal = one TG topic = one persistent session. Reply at any time, agent resumes with full context.
- Two execution modes per topic:
copilot(default) — agent drafts, queries, scrapes privately, then posts oneagency-reportcard with the action pre-completed and asks ✅ Yes / 🔁 More / ⏭ Skip. Stops at every visible boundary.autopilot— agent acts directly on reversible work, posts short progress updates inline. Stops only at visible/external side effects (send email, post publicly, merge, pay).
- Self-scheduling baked in. At the end of every cycle, the agent picks its own cadence (30m / 1h / 4h / daily) and fires
tg-scheduleitself. Resume keeps full session context. - One concrete action per cycle, not a batch of ten. The old prompt told the agent to "generate 10 cards" which produces filler.
- Buttons collapse to one canonical set. ✅ Yes / 🔁 More / ⏭ Skip. No more spawn-topic label variants, no Edit. New
morekind regenerates the same idea with a different angle. /goalfailure now surfaces. IfcreateForumTopicfails (group lacks topics, bot isn't admin), the user is told instead of silently merging the goal into the current thread.
Changes
agent/telegram_bot.py—/autopilot,/copilotcommands;_get_goal_mode/_set_goal_modehelpers; newmodecolumn on the mini-app goals table with backfill; rewritten_agency_goal_prompt;_handle_agency_callbackhandleskind="more";/goalsurfaces topic-creation errors.agent/agency-report—DEFAULT_BUTTONS(one canonical set); docstring updated; spawn-topic label variants removed.agent/agency_db.py—record_decisionmaps "more" decisions to statusregenerated.agent/mini_app.py— matchingmodecolumn in its goals-table schema + backfill.agent/CLAUDE.md— "Agency mode" section rewritten around the new primitive.
Saved for v2 (not in this PR)
- Collapse
AGENCY.mdfrom 470 → ~120 lines (the doctrine cut). - Drop the old Mini App (
index.html / app.js / app.css, ~2230 LOC; the canonical/already routes totinder.html). - Merge
install.sh+bootstrap.shduplication. - Split
telegram_bot.py(7741 LOC, 115 top-level fns).
Silent-failure paths still in the file (separate cleanup)
Scan turned up _handle_agency_callback and _start_agency_goal_from_command silent fallbacks. Fixed the /goal one as part of this PR; others (DB record_decision failures, callback segment-count mismatch with empty toast, refine context-injection swallowed) remain for a follow-up.
Test plan
-
pytest agent/test_telegram_bot.py agent/test_mini_app.py— 21 passed -
python3 -c "ast.parse(...)"syntax check across all touched files - Send
/goal write a sample post about Xin a group with topics on a real box — verify new topic spawns and first cycle posts a card with ✅ Yes / 🔁 More / ⏭ Skip - Send
/autopilotin that topic — verify ack + mode flip - Tap 🔁 More on a card — verify agent regenerates with a different angle
🤖 Generated with Claude Code
Summary by cubic
Make /goal the core flow: one goal per Telegram topic with a persistent session and per‑topic mode (copilot default, autopilot optional). Cards are simplified to ✅ Yes / 🔁 More / ⏭ Skip, and cycles self‑schedule.
-
New Features
- Per-topic mode switches:
/autopilotand/copilot; persisted asgoals.mode(defaultcopilot) with backfill. - Mode‑aware goal prompt: one concrete action per cycle, then self‑schedule via
tg-schedule. agency-report: default buttons now✅ Yes(action),🔁 More(regenerate with a different angle),⏭ Skip(dismiss). Yes/More run in the same topic; spawn-topic flags kept for back‑compat./goal: creates a dedicated topic per goal; the topic is the goal’s permanent lane with full context resume.
- Per-topic mode switches:
-
Bug Fixes
/goalnow surfacescreateForumTopicfailures instead of silently falling back to the current thread.