chat-agent-loops

Chat agent loops endlessly running git hygiene on idle ticks — should be quiescent when no inbox messages

Metadata

Statusdone
Assignedagent-228
Agent identity3184716484e6f0ea08bb13539daf07686ee79d440505f1fdf2de0357707034c3
Created2026-04-27T02:08:09.972466211+00:00
Started2026-04-27T02:08:43.294591019+00:00
Completed2026-04-27T02:26:42.529606742+00:00
Tagseval-scheduled
Eval score0.79
└ blocking impact0.85
└ completeness0.75
└ constraint fidelity0.10
└ coordination overhead0.80
└ correctness0.80
└ downstream usability0.75
└ efficiency0.80
└ intent fidelity0.60
└ style adherence0.80

Description

Description

User repro: .chat-2 (and presumably any chat agent) is waking up on every iteration of its supervisor loop and doing pointless work. From the user's TUI snapshot:

The .chat-2 task is the persistent chat-agent loop. No unread messages, no pending
user request — this iteration has nothing to act on. I'll log the state and mark the
iteration done (non-converged) so the cycle continues.
> Bash: wg log .chat-2 'Chat agent iteration 1 — no unread messages, no pending user request...'
> Bash: wg done .chat-2
> Warning: git hygiene for '.chat-2': uncommitted changes:
?? .wg/
?? .workgraph.1/

User quote: 'omfg it keeps waking up and doing git hygiene. what the actual fuck'

Two stacked bugs

A. Chat agent supervisor loops with nothing to do.

  • The chat agent (LLM session in the supervisor) is running iterations even when inbox.jsonl has no new messages.
  • It dutifully logs 'no unread messages' then wg done to advance the iteration.
  • This burns tokens, churns the graph, triggers eval scaffolding, and produces noise.
  • Correct behavior: when inbox.jsonl has no new messages AND no pending user request AND no synthetic prompt, the chat handler does nothing (waits, no LLM call). The supervisor only re-spawns / re-iterates when inbox has new content OR an explicit signal arrives.

B. Chat agent runs 'git hygiene' on every iteration.

  • A chat agent is a CONVERSATION endpoint, not a code agent. It should never run git hygiene checks.
  • The Warning: git hygiene for '.chat-N': uncommitted changes is being emitted from wg done apparently — meaning wg done runs git hygiene by default, even on chat tasks.
  • Worse: the warnings flag .wg/ and .workgraph.1/ as 'uncommitted changes', which are EXPECTED untracked dirs per project memory ('stale .workgraph.N/ dirs + agency YAMLs sit untracked').
  • Fix two ways:
    • wg done should NOT run git hygiene for chat-loop tasks (tag-gated skip)
    • wg done git hygiene should respect a project ignore list (don't flag .wg, .workgraph.* etc.)

Spec

Bug A fix:

  • Chat agent supervisor loop: only fire the LLM when there's actual work (new inbox message OR explicit user-input event). Otherwise sleep / wait on file watch.
  • If using cycle iterations to model the chat-loop task, the cycle should advance only when there's a new turn — NOT on a wall-clock interval.
  • Remove the 'log nothing happened then call wg done' busywork.

Bug B fix:

  • wg done <task> skips git hygiene check when the task has tag chat-loop (or whatever tag identifies chat-agent tasks).
  • Git hygiene check (when it does run) respects .gitignore — already-ignored or explicitly-allowed-untracked dirs (.wg/, .workgraph.*/, etc) don't trigger warnings.
  • Optional: a config knob [dispatcher].git_hygiene_on_done = false to fully disable for users who don't want it.

Files likely to touch

  • src/commands/service/coordinator_agent.rs — chat-loop iteration trigger (currently wakes on a timer; should wake on inbox event)
  • src/commands/done.rs — git hygiene check + tag-gated skip
  • src/agency/prompt.rs or wherever the chat-agent system prompt is built — explicitly tell the chat agent NOT to run wg done in idle iterations

Validation

  • Failing tests first:
    • test_chat_agent_idle_emits_zero_llm_calls — synthesize a chat-loop task with empty inbox, run supervisor for 60s, assert zero LLM calls fired
    • test_chat_agent_wakes_on_inbox_message — append an inbox message, supervisor wakes within 1s, fires one LLM call
    • test_wg_done_skips_git_hygiene_for_chat_loop_tag — wg done on a chat-loop tagged task does not emit git-hygiene warnings
    • test_git_hygiene_respects_ignored_paths — .wg/ and .workgraph.*/ don't trigger warnings even when wg done runs hygiene
  • Implementation makes tests pass
  • cargo build + cargo test pass with no regressions
  • Manual smoke (HARD GATE):
    • Create a fresh chat (wg service create-chat), don't send any messages
    • Wait 5 minutes; observe daemon log: zero LLM calls fired for the chat handler, zero wg done invocations on the chat task, zero git-hygiene warnings
    • Send 'hi' to the chat; LLM call fires once, response comes back, then quiescent again

Depends on

Required by

Log