Skip to content

v9: new-topic helper — spawn fresh lane synchronously, queue heartbeat#217

Open
MagMueller wants to merge 1 commit into
v8-agency-report-slimfrom
v9-new-topic-helper
Open

v9: new-topic helper — spawn fresh lane synchronously, queue heartbeat#217
MagMueller wants to merge 1 commit into
v8-agency-report-slimfrom
v9-new-topic-helper

Conversation

@MagMueller
Copy link
Copy Markdown
Contributor

@MagMueller MagMueller commented May 15, 2026

Stacked on #216 (v8). One small new helper that fixes a doctrine awkwardness you called out.

Why

tg-schedule "+1 minute" --fresh "..." was being recommended as the way for the agent to spawn a fresh topic for a new project. But that's misusing the schedule API:

  • The 1-minute delay is wrong UX (topic appears late).
  • It's a one-shot — the spawned topic got an initial prompt and then nothing. No check-in 3 hours later. No heartbeat.
  • "Schedule" reads wrong for a synchronous spawn.

What

agent/new-topic — a small Python helper (~140 LOC):

new-topic "<title>" "<initial prompt>"                       # default +1h heartbeat
new-topic "<title>" --heartbeat "+3 hours" "<prompt>"        # custom cadence
new-topic "<title>" --heartbeat none "<prompt>"              # one-shot, no follow-up

What it actually does:

  1. createForumTopic synchronously — topic appears in Telegram immediately, no at-job delay.
  2. bot.run_task to dispatch the initial prompt as the topic's first turn.
  3. tg-schedule --repeat to queue the recurring heartbeat (skipped on --heartbeat none).
  4. Prints {ok, chat_id, thread_id, title, heartbeat} as JSON so the caller can include a link in whatever it's posting back to the user.

/goal stays the user-driven autopilot trigger (no approvals). new-topic is the agent-driven copilot equivalent (default mode, draft + ask).

Changes

  • agent/new-topic (new, +178 LOC)
  • install.sh + agent/bootstrap.sh — install + symlink
  • agent/system-prompt.md — "Spawning new topics" rewritten around new-topic

Tests

  • 29 pass
  • Syntax check
  • On a box: new-topic "Test topic" "draft hello" — verify topic appears, first turn dispatches, atq shows a queued heartbeat
  • new-topic "X" --heartbeat none "Y" — verify no heartbeat queued

🤖 Generated with Claude Code


Summary by cubic

Add new-topic to start a fresh Telegram topic instantly, send the first agent turn, and schedule a recurring heartbeat. Replaces the misuse of tg-schedule --fresh so new lanes appear now and keep getting follow‑ups.

  • New Features
    • agent/new-topic CLI:
      • Creates the forum topic immediately and dispatches the first turn via bot.run_task.
      • Queues a recurring heartbeat with tg-schedule --repeat (default +1h; supports --heartbeat "+3 hours" or --heartbeat none).
      • Prints JSON {ok, chat_id, thread_id, title, heartbeat} for easy linking.
      • New lanes run in copilot mode; /goal stays the user-driven autopilot.
    • Added install/symlink in install.sh and agent/bootstrap.sh. Updated agent/system-prompt.md to use new-topic.

Written for commit d928d51. Summary will update on new commits. Review in cubic

You were right: `tg-schedule "+1 minute" --fresh "..."` is misusing the schedule API. It's not a schedule, it's "launch a fresh topic now with this initial prompt" — and the spawned topic got one prompt and then nothing, no follow-up.

Added `agent/new-topic` — a dedicated helper the agent calls when conversation surfaces a new ongoing project that deserves its own lane:

  new-topic "<title>" "<initial prompt>"            # default +1h heartbeat
  new-topic "<title>" --heartbeat "+3 hours" "<prompt>"
  new-topic "<title>" --heartbeat none "<prompt>"   # one-shot, no follow-up

What it does:
- createForumTopic synchronously (no at-job delay — topic appears immediately)
- bot.run_task to dispatch the initial prompt as the topic's first turn
- tg-schedule --repeat to queue the recurring heartbeat (skipped on --heartbeat none)
- prints {ok, chat_id, thread_id, title, heartbeat} as JSON so the caller can include the link

Wired into install.sh + bootstrap.sh. system-prompt.md "Spawning new topics" section rewritten around `new-topic`. /goal stays the user-driven autopilot trigger; new-topic is the agent-driven copilot equivalent.

Tests: 29 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="agent/new-topic">

<violation number="1" location="agent/new-topic:151">
P2: Heartbeat scheduling failures are silently ignored, so the command can report success even when no recurring heartbeat was queued.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Re-trigger cubic

Comment thread agent/new-topic
heartbeat_prompt,
],
env=env_for_schedule,
check=False,
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Heartbeat scheduling failures are silently ignored, so the command can report success even when no recurring heartbeat was queued.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent/new-topic, line 151:

<comment>Heartbeat scheduling failures are silently ignored, so the command can report success even when no recurring heartbeat was queued.</comment>

<file context>
@@ -0,0 +1,171 @@
+                    heartbeat_prompt,
+                ],
+                env=env_for_schedule,
+                check=False,
+                stdout=subprocess.DEVNULL,
+                stderr=subprocess.DEVNULL,
</file context>
Fix with Cubic

MagMueller added a commit that referenced this pull request May 15, 2026
…omposio for codex

Lands 16 stacked PRs reviewed by multiple sub-agents:

- v1 (#209)  /goal as primitive, per-topic autopilot vs copilot
- v2 (#210)  drop agency-mode gate, fold doctrine into CLAUDE.md, delete old Mini App UI
- v3 (#211)  CLAUDE.md → system-prompt.md (source of truth), agent identity = "agency"
- v4 (#212)  trim system prompt to 87 lines, mode emoji in topic title, extract bot/markdown.py
- v5 (#213)  heartbeat-by-default plumbing (later removed), copilot voice fix, autopilot security note
- v6 (#214)  steering semantics, new-topic spawning, 2-option cards, source-aware images
- v7 (#215)  /goal IS autopilot framing, drop topic emoji prefix, silence allowed, codex goals=true, `schedule` alias
- v8 (#216)  drop --spawn-topic, --importance, trim agency-report docstring
- v9 (#217)  new-topic helper — spawn fresh lane synchronously, queue heartbeat
- v10 (#218) self-schedule only when waiting on something concrete; drop auto-heartbeats
- v11 (#219) /goal is a verbatim CLI passthrough; bot is a dumb pipe
- v12 (#220) drop 30-min timeout, kill lingering heartbeat, prompt-injection defenses, seed goals.md
- v13 (#221) /goal stays copilot by default; autopilot only on explicit user opt-in
- v14 (#222) doctrine fixes from final multi-agent review
- v15 (#223) tighten autopilot triggers — drop the loose phrases
- v16 (#224) register composio MCP for codex too; simplify autopilot trigger paragraph

Tests: 22 pass.

Follow-ups (tracked, not in this merge):
- P0: install bootstrap.sh as /usr/local/sbin root:root (closes the trivial bux→root)
- P1: stuck-lane watchdog (no-stdout-for-30-min SIGTERM)
- P1: /invite is a dead command (remove from BotFather menu)
- P1: composio tool names wrong-case in system prompt
- P1: help text + COMMANDS still reference dropped autopilot trigger phrases
- P1: BUX_BOX_TOKEN provenance for OSS self-host installs
- P2: button-tap dispatches bypass _enqueue (lane race on rapid taps)
- P2: persisted per-topic autopilot flag in state (instead of LLM phrase detection)
- P2: agency_db ghost columns (importance, spawn_topic)
- P2: mini app teardown decision (1700 LOC for an unreferenced surface)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant