UAT: agents actor context clear command missing — no way to reset context without deleting it #4960

Open
opened 2026-04-08 23:40:25 +00:00 by freemo · 1 comment
Owner

Bug Report

Summary

The agents actor context clear [--yes|-y] (--all|-a|<NAME>) command is completely absent from the implementation. The actor_context.py module only registers remove, export, and import commands. The clear command — which resets a context's messages and state while preserving the context directory — is missing.

Expected Behavior (from spec)

The specification (Command Synopsis) defines:

agents actor context clear [--yes|-y] (--all|-a|<NAME>)
  • agents actor context clear <NAME> — clears the messages, state, and global_context of a named context, resetting it to empty while keeping the context directory
  • agents actor context clear --all — clears all contexts
  • --yes/-y — skips the confirmation prompt

Key distinction from remove: clear resets a context to empty state (preserves the directory, resets content), while remove deletes the context entirely. This is the same pattern as git clean vs rm -rf.

Actual Behavior

Running agents actor context clear raises a Typer "No such command" error:

$ agents actor context clear myctx
Error: No such command 'clear'.

Code Location

File: src/cleveragents/cli/commands/actor_context.py

The clear command is entirely absent. The ContextManager class already has a clear() method (line ~80 in reactive/context_manager.py) that resets messages, state, and global_context — the CLI command just needs to call it.

# ContextManager.clear() already exists:
def clear(self) -> None:
    self.messages = []
    self.state = {}
    self.global_context = {}
    self.metadata = {
        "created_at": datetime.now().isoformat(),
        "last_updated": datetime.now().isoformat(),
        "context_name": self.context_name,
    }
    self.save()

Impact

  • Users cannot reset a context to start fresh without deleting and recreating it
  • Breaks iterative workflows where users want to reuse a context name but start with a clean slate
  • The ContextManager.clear() method exists but is unreachable from the CLI

Steps to Reproduce

  1. Create a context: agents actor run --context myctx <actor> "hello"
  2. Try to clear it: agents actor context clear myctx
  3. Observe: Error: No such command 'clear'.

Suggested Fix

Add clear command to src/cleveragents/cli/commands/actor_context.py:

@app.command("clear")
def context_clear(
    name: Annotated[str | None, typer.Argument(help="Context name to clear")] = None,
    all_contexts: Annotated[bool, typer.Option("--all", "-a", help="Clear all contexts")] = False,
    yes: Annotated[bool, typer.Option("--yes", "-y", help="Skip confirmation")] = False,
    context_dir: Annotated[Path | None, typer.Option("--context-dir", resolve_path=True)] = None,
    fmt: Annotated[str, typer.Option("--format", "-f")] = "rich",
) -> None:
    """Clear messages and state from a named actor context (preserves the context directory)."""
    if name and all_contexts:
        typer.echo("Error: Cannot specify NAME when using --all", err=True)
        raise typer.Exit(code=1)
    if not name and not all_contexts:
        typer.echo("Error: Must specify NAME or use --all", err=True)
        raise typer.Exit(code=1)
    # ... confirmation prompt, then ctx_mgr.clear()

Definition of Done

  • agents actor context clear <NAME> clears messages/state/global_context of the named context
  • agents actor context clear --all clears all contexts
  • --yes/-y skips confirmation prompt
  • Context directory is preserved (not deleted) after clear
  • Supports --format json/yaml/plain/table/rich
  • Returns exit code 1 with error message when context does not exist

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report ### Summary The `agents actor context clear [--yes|-y] (--all|-a|<NAME>)` command is completely absent from the implementation. The `actor_context.py` module only registers `remove`, `export`, and `import` commands. The `clear` command — which resets a context's messages and state while preserving the context directory — is missing. ### Expected Behavior (from spec) The specification (Command Synopsis) defines: ``` agents actor context clear [--yes|-y] (--all|-a|<NAME>) ``` - `agents actor context clear <NAME>` — clears the messages, state, and global_context of a named context, resetting it to empty while keeping the context directory - `agents actor context clear --all` — clears all contexts - `--yes/-y` — skips the confirmation prompt **Key distinction from `remove`:** `clear` resets a context to empty state (preserves the directory, resets content), while `remove` deletes the context entirely. This is the same pattern as `git clean` vs `rm -rf`. ### Actual Behavior Running `agents actor context clear` raises a Typer "No such command" error: ``` $ agents actor context clear myctx Error: No such command 'clear'. ``` ### Code Location **File:** `src/cleveragents/cli/commands/actor_context.py` The `clear` command is entirely absent. The `ContextManager` class already has a `clear()` method (line ~80 in `reactive/context_manager.py`) that resets messages, state, and global_context — the CLI command just needs to call it. ```python # ContextManager.clear() already exists: def clear(self) -> None: self.messages = [] self.state = {} self.global_context = {} self.metadata = { "created_at": datetime.now().isoformat(), "last_updated": datetime.now().isoformat(), "context_name": self.context_name, } self.save() ``` ### Impact - Users cannot reset a context to start fresh without deleting and recreating it - Breaks iterative workflows where users want to reuse a context name but start with a clean slate - The `ContextManager.clear()` method exists but is unreachable from the CLI ### Steps to Reproduce 1. Create a context: `agents actor run --context myctx <actor> "hello"` 2. Try to clear it: `agents actor context clear myctx` 3. Observe: `Error: No such command 'clear'.` ### Suggested Fix Add `clear` command to `src/cleveragents/cli/commands/actor_context.py`: ```python @app.command("clear") def context_clear( name: Annotated[str | None, typer.Argument(help="Context name to clear")] = None, all_contexts: Annotated[bool, typer.Option("--all", "-a", help="Clear all contexts")] = False, yes: Annotated[bool, typer.Option("--yes", "-y", help="Skip confirmation")] = False, context_dir: Annotated[Path | None, typer.Option("--context-dir", resolve_path=True)] = None, fmt: Annotated[str, typer.Option("--format", "-f")] = "rich", ) -> None: """Clear messages and state from a named actor context (preserves the context directory).""" if name and all_contexts: typer.echo("Error: Cannot specify NAME when using --all", err=True) raise typer.Exit(code=1) if not name and not all_contexts: typer.echo("Error: Must specify NAME or use --all", err=True) raise typer.Exit(code=1) # ... confirmation prompt, then ctx_mgr.clear() ``` ### Definition of Done - [ ] `agents actor context clear <NAME>` clears messages/state/global_context of the named context - [ ] `agents actor context clear --all` clears all contexts - [ ] `--yes/-y` skips confirmation prompt - [ ] Context directory is preserved (not deleted) after clear - [ ] Supports `--format json/yaml/plain/table/rich` - [ ] Returns exit code 1 with error message when context does not exist --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — agents actor context clear is a missing command that prevents users from resetting context state without deleting it entirely
  • Milestone: v3.2.0 (actor context management is core functionality)
  • Story Points: 2 — S — Fix requires implementing the clear subcommand in actor_context.py that resets messages/state while preserving the context directory
  • MoSCoW: Must Have — The spec explicitly defines agents actor context clear as a required command; its absence means users have no way to reset context state without destructive deletion

This is a valid spec compliance bug. The actor_context.py module is missing the clear subcommand registration.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — `agents actor context clear` is a missing command that prevents users from resetting context state without deleting it entirely - **Milestone**: v3.2.0 (actor context management is core functionality) - **Story Points**: 2 — S — Fix requires implementing the `clear` subcommand in `actor_context.py` that resets messages/state while preserving the context directory - **MoSCoW**: Must Have — The spec explicitly defines `agents actor context clear` as a required command; its absence means users have no way to reset context state without destructive deletion This is a valid spec compliance bug. The `actor_context.py` module is missing the `clear` subcommand registration. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.2.0 milestone 2026-04-09 00:51:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#4960
No description provided.