feat: pu bench / pu play — suspend and resume agents#111
Conversation
The suspend/resume protocol and engine support existed but had no CLI exposure. This adds two commands using PurePoint's basketball metaphor: - `pu bench <agent_id>` / `pu bench --all` — suspend agents - `pu play <agent_id>` — resume a benched agent Also enhances `pu status` to show "benched" (yellow) for suspended agents instead of the generic "waiting" status. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThe PR introduces Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as "CLI Parser"
participant Handler as "bench::run_bench / run_play"
participant Daemon
participant Output as "output formatter"
User->>CLI: invoke bench/play command
CLI->>Handler: call run_bench(socket, agent?, all, json) / run_play(socket, agent_id, json)
Handler->>Handler: determine target & validate (All or Agent)
Handler->>Daemon: send Suspend / Resume request
Daemon-->>Handler: return SuspendResult / ResumeResult
Handler->>Output: format result (status_colored_with_suspended)
Output-->>Handler: formatted message
Handler-->>User: display results
alt self-agent included
Handler-->>User: emit self-bench warning
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code reviewFound 1 issue:
PurePoint/crates/pu-cli/src/commands/bench.rs Lines 9 to 33 in eace188 Compare with the self-protection pattern in PurePoint/crates/pu-cli/src/commands/kill.rs Lines 16 to 44 in eace188 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Refuse to bench own agent when PU_AGENT_ID matches the target. For bulk --all, warn if self was included in the suspend results since the protocol lacks an exclude mechanism for suspend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Fixed in 7b8acac:
Changed file: |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
crates/pu-cli/src/commands/bench.rs (1)
45-54: Post-hoc warning is a reasonable workaround for protocol limitation.Since
SuspendTargetlacks anexcludefield (unlikeKillTarget), the code cannot prevent self-inclusion in--alloperations at the request level. The warning after the fact, with guidance to resume viapu play, is a pragmatic solution. Consider documenting this behavior in the CLI help text.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/pu-cli/src/commands/bench.rs` around lines 45 - 54, The post-hoc warning handles a protocol limitation where SuspendTarget cannot exclude self, so detect self-inclusion as currently done by checking self_agent_id and matching pu_core::protocol::Response::SuspendResult { suspended } and, in addition to the existing eprintln warning, add a short help-text note to the bench command's CLI usage explaining that `--all` may include the invoking agent and how to resume with `pu play <agent_id>`; update the help/usage string for the bench subcommand (where the command description/long_about is defined) to document this behavior so users see it before running the command.crates/pu-cli/src/main.rs (1)
70-79: Consider addingconflicts_withfor mutual exclusivity.The
Killcommand (lines 91-92) uses#[arg(long, conflicts_with_all = ["worktree", "all"])]to enforce that--agentand--allare mutually exclusive at the CLI level. TheBenchcommand allows bothagent_idand--allto be provided simultaneously, relying onbench.rsto prefer--all. While functionally correct, addingconflicts_withwould provide clearer error messages at parse time.♻️ Optional: Add conflicts_with for clearer CLI errors
/// Bench (suspend) agents — pull them off the court Bench { /// Agent ID to bench + #[arg(conflicts_with = "all")] agent_id: Option<String>, /// Bench all active agents #[arg(long)] all: bool,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/pu-cli/src/main.rs` around lines 70 - 79, The Bench variant allows both agent_id and --all simultaneously; update the CLI arg attributes on the Bench fields to declare mutual exclusivity so clap reports a parse-time error: add an attribute to the agent_id field (e.g. #[arg(long, conflicts_with = "all")] or #[arg(conflicts_with = "all")]) and/or to the all field (e.g. #[arg(long, conflicts_with = "agent_id")]) so the Bench struct's agent_id and all flags conflict at parse time (refer to the Bench variant and its agent_id and all fields).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/pu-cli/src/commands/bench.rs`:
- Around line 45-54: The post-hoc warning handles a protocol limitation where
SuspendTarget cannot exclude self, so detect self-inclusion as currently done by
checking self_agent_id and matching pu_core::protocol::Response::SuspendResult {
suspended } and, in addition to the existing eprintln warning, add a short
help-text note to the bench command's CLI usage explaining that `--all` may
include the invoking agent and how to resume with `pu play <agent_id>`; update
the help/usage string for the bench subcommand (where the command
description/long_about is defined) to document this behavior so users see it
before running the command.
In `@crates/pu-cli/src/main.rs`:
- Around line 70-79: The Bench variant allows both agent_id and --all
simultaneously; update the CLI arg attributes on the Bench fields to declare
mutual exclusivity so clap reports a parse-time error: add an attribute to the
agent_id field (e.g. #[arg(long, conflicts_with = "all")] or
#[arg(conflicts_with = "all")]) and/or to the all field (e.g. #[arg(long,
conflicts_with = "agent_id")]) so the Bench struct's agent_id and all flags
conflict at parse time (refer to the Bench variant and its agent_id and all
fields).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aedae928-786a-4cf9-a59d-355eff61b50d
📒 Files selected for processing (4)
crates/pu-cli/src/commands/bench.rscrates/pu-cli/src/commands/mod.rscrates/pu-cli/src/main.rscrates/pu-cli/src/output.rs
Clap now errors if both an agent ID and --all are provided, instead of silently ignoring the agent ID. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address CodeRabbit docstring coverage warning and nitpick about documenting --all self-inclusion behavior in the CLI help text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed the remaining CodeRabbit feedback in c7a1b9f: Nitpick #1 (bench.rs:45-54 — document Nitpick #2 (main.rs:70-79 — Docstring coverage warning: Added doc comments to All CI checks were green before this commit; local validation (tests, clippy, fmt) passes. |
Summary
pu bench <agent_id>andpu bench --allto suspend (bench) agentspu play <agent_id>to resume a benched agentpu statusto show "benched" (yellow) for suspended agents instead of generic "waiting"The suspend/resume protocol (
Request::Suspend/Request::Resume) and engine handlers were already fully implemented but had no CLI commands. This wires them up with the right terminology.What it looks like
Test plan
cargo clippycleancargo fmtcleanpu bench --help/pu play --helpshow correct usageReview feedback addressed
--allself-inclusion (7b8acac)conflicts_withfor mutual exclusivity of<agent_id>and--all(953fec0)long_abouthelp text documenting--allbehavior (c7a1b9f)🤖 Generated with Claude Code