CommandCodeAI / CommandCodeAI/command-code

feat: Allow mods to spawn and await background agents / background work

Aperta
#691 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Nessun dato sulla lingua
Stelle
4k
Fork
350
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Feature Description

Summary

Mods currently have no way to run work in the background. The agent tool (with run_in_background: true), background agents (background: true), and background shell tasks are all seams the main agent drives — none are reachable from a mod. Mods only have cmd.exec (foreground shell) and the synchronous onStop + prepareNextTurn force-continue seam for post-run model turns.

Motivation

Post-run maintenance work — summarization, extraction, knowledge discovery, compaction — is exactly the kind of task that should run detached from the main loop, on a cheap model, without blocking or polluting the session. Today a mod that wants a model to do post-run work must inject a continuation turn (onStop with {continue: true}) that runs in-line: it occupies the same run, renders in the feed, and competes with sibling mods over the single continuation slot (harness short-circuits "any mod returning continue wins").

Alternatives considered
  • Keep the onStop continuation seam and just make the injected turn quieter. Doesn't solve the collision problem (one continuation slot shared by all
    mods) or the "detached from the run" goal.
  • Background shell + cmd.events polling. Mods could shell out to cmd -p via a background process, but there's no background cmd.exec, and reacting to
    completion would require polling from a hook — no clean completion signal.

Acceptance criteria

  • A mod can launch a background agent and continue the session without blocking.
  • The spawning mod is notified (hook or event) when the agent completes, with the agent's final result.
  • The behavior is observable in the TUI Background panel (Ctrl+B) like other background work.
  • Works headless (-p), degrading deterministically.
Use Case
Mods am building or trying out that could use background running
  • Memory/journal mods that extract compressed episodes or discover durable facts from a finished run (e.g. the project-brain / task-journal pattern).

  • Any mod wanting to fan out parallel investigation or run a long background process and react when it completes.
    Current gap

  • No cmd.agent(...) / cmd.spawnAgent(...) equivalent on ModApi — a mod cannot launch the built-in agent tool or a custom agent.

  • No background variant of cmd.exec (no way to get a task id + log + wake-up like shell_command run_in_background / monitor_command).

  • No hook or event a mod can register to be notified when a background agent it spawned finishes (the result of agent_output never reaches a mod).

Proposed API (suggestion — open to design)

Something like:

  • cmd.agent({prompt, agent?, model?, runInBackground: true}) → Promise<{agentId}> — spawn a background agent from a mod.
  • A completion hook or event, e.g. cmd.hooks({onAgentResult}) or cmd.events.on('agent_completed', ...), delivering the agent's final result to the
    spawning mod.
  • Optionally: a background cmd.exec variant returning a task id + on-disk log, mirroring shell_command run_in_background.
Additional Context
  • Sort of how taste learning works to be honest
How important is this to you?

Medium. Nice mod improvements for UX, but right now these are experiments and sync running is ok.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando la superficie esistente di ModApi cmd.exec e i punti di collegamento tra agent, background-agent e background-shell descritti nell’issue. Confronta il loro comportamento con il TUI Background panel (Ctrl+B) e la modalità headless (-p). Il lavoro è completo quando un mod può avviare un’attività senza bloccarsi, riceverne il risultato finale al completamento, renderlo disponibile nel background panel e degradare in modo deterministico in modalità headless.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
api, backend, cli
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.