fix(agent): register CLI channel factory for interactive mode#5802
Conversation
182bec1 moved CliChannel behind a OnceLock factory but only wired the registration in Commands::Daemon, not Commands::Agent. Running `zeroclaw agent` (interactive, no -m) panicked at startup.
|
TLDR: This fixes a |
WareWolf-MoonWall
left a comment
There was a problem hiding this comment.
Status: Approving. The fix is correct and safe to land. One conditional item below β please act on it before or immediately after merge.
β The fix is right
git blame correctly traced the regression to 182bec1e (CliChannel OnceLock refactor), which wired registration in Commands::Daemon but missed Commands::Agent. The 5-line patch mirrors the identical pattern already in Commands::Daemon and sits inside the existing #[cfg(feature = "agent-runtime")] match block at line 1198, so no additional feature guard is needed β the symmetry with Daemon's internal guard is a pre-existing (harmless) detail, not something this PR introduced.
The diagnosis of why -m masked the bug is exactly right: one-shot mode returns before run_interactive() is called, so CLI_CHANNEL_FN is never read and the OnceLock miss is invisible on that path. That's the kind of root-cause analysis that makes a hotfix trustworthy.
OnceLock::set is idempotent here (let _ = CLI_CHANNEL_FN.set(f)), so there's no risk from a hypothetical double-registration, and the blast radius is confirmed to the Commands::Agent startup path only.
π‘ Conditional β file the follow-up issue before this lands (or immediately after)
The PR description correctly identifies the structural fix: replace CLI_CHANNEL_FN: OnceLock<β¦> with a CliChannelFn parameter on run(), and drop the now-redundant interactive: bool so the compiler enforces what the OnceLock currently relies on discipline to enforce. That's the right call to defer for a hotfix. But per FND-006 Β§4.4 and FND-005's conditional taxonomy, a deferral needs a tracked issue with an assignee β "follow-up issue to be filed" in the PR body is a wish, not a commitment.
Resolution path: File an issue titled something like refactor(agent): replace CLI_CHANNEL_FN OnceLock with CliChannelFn parameter on run(), drop interactive: bool and add the issue number to the "Related #" field. Five minutes of work that prevents this from becoming one of the 5,630 deferred decisions FND-006 Β§2.1 is already counting.
The fix itself does not need to wait for that issue. The commitment to file it does need to be on record before this is closed.
Checked:
#[cfg(feature = "agent-runtime")]coverage (outer match at line 1198 covers the addition),OnceLock::setidempotency, daemon-path symmetry,-mearly-return path, all CI green. Nothing new to block on.
Summary
masterfor all contributions):masterzeroclaw agent(interactive, no-m) panics at startup withCLI channel factory not registered β call register_cli_channel_fn at startup-mone-shot path was unaffected (it never touchesCLI_CHANNEL_FN), which is why this wasn't caught earlier β that's the path I tested.register_cli_channel_fn()call toCommands::Agenthandler insrc/main.rs, matching the identical call already present inCommands::DaemonCLI_CHANNEL_FNOnceLock with aCliChannelFnparameter onrun()and dropping the redundantinteractive: boolparameter so the compiler enforces correctness) but that changes a public function signature across 5 files and 4 callsites β not appropriate for a hotfix. That refactor should be tracked as a follow-up issue.Label Snapshot (required)
risk: low|medium|high):risk: lowsize: XS|S|M|L|XL, auto-managed/read-only):size: XSruntimeChange Metadata
bug|feature|refactor|docs|security|chore):bugruntime|provider|channel|memory|security|ci|docs|multi):runtimeLinked Issue
Supersede Attribution (required when
Supersedes #is used)N/A
Validation Evidence (required)
zeroclaw agententers interactive mode without panic,zeroclaw agent -m "hi"still works,zeroclaw daemonunaffectedSecurity Impact (required)
Privacy and Data Hygiene (required)
passCompatibility / Migration
i18n Follow-Through (required when docs or user-facing wording changes)
Human Verification (required)
zeroclaw agentinteractive mode starts without panic,zeroclaw agent -m "hi"one-shot works,zeroclaw daemonunaffected-m) never touchesCLI_CHANNEL_FNβ it takes the early return before the interactive loop. This is why the bug wasn't caught:-mwas the path previously tested.Side Effects / Blast Radius (required)
Commands::Agentstartup path onlyCommands::DaemonAgent Collaboration Notes (recommended)
git blametraced regression to182bec1e(CliChannel OnceLock refactor), which wired registration inCommands::Daemonbut missedCommands::Agentinteractive: bool) is deferred to a follow-up PR.Rollback Plan (required)
git revert <sha>zeroclaw agentpanics at startup β immediate, obviousRisks and Mitigations