Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 46 additions & 11 deletions .claude/commands/agent-sdk/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ Create a new PMOVES Agent instance with full ecosystem access.

- `$ARGUMENTS` - Agent role/specialization (e.g., "researcher", "code-reviewer", "media-processor")

## Prerequisites

Before creating agents, ensure:

1. **Submodules initialized:**
```bash
git submodule update --init --recursive PMOVES-BoTZ
```

2. **Dependencies installed:**
```bash
pip install -r pmoves/requirements.txt
```

3. **Services running:**
```bash
# Check NATS
curl http://localhost:4222

# Check TensorZero
curl http://localhost:3030/v1/models

# Check Hi-RAG v2
curl http://localhost:8086/healthz
```

## Instructions

1. Parse the agent role from arguments
Expand All @@ -26,12 +52,22 @@ Create a new PMOVES Agent instance with full ecosystem access.

```python
from pmoves_botz.features.agent_sdk import PMOVESAgent
import asyncio
from datetime import datetime

async def main():
timestamp = int(datetime.now().timestamp())
role = "researcher" # Choose: researcher, code-reviewer, media-processor, knowledge-manager, general

agent = PMOVESAgent(
agent_id=f"pmoves-{role}-{timestamp}",
role=role,
model="openai::qwen3:8b",
)

agent = PMOVESAgent(
agent_id="pmoves-{role}-{timestamp}",
role="{role}",
)
await agent.connect()
await agent.connect()

asyncio.run(main())
```

4. Show created agent configuration:
Expand All @@ -41,17 +77,16 @@ await agent.connect()
- MCP servers connected
- Subagents available

5. Announce agent on NATS:
```
Subject: botz.agent.registered.v1
Payload: {"agent_id": "...", "role": "...", "capabilities": [...]}
```
5. NATS events published by agent:
- `botz.agent.heartbeat.v1` - Agent presence (every 30s)
- `agent.task.start.v1` - Task execution started
- `botz.work.completed.v1` - Task completed successfully

## Example

```bash
/agent-sdk:create researcher
# Creates: pmoves-researcher-1703123456
# Creates: pmoves-researcher-1735123456
# Tools: WebSearch, hirag_query, nats_publish, Task
# Subagents: None (top-level agent)
```
197 changes: 158 additions & 39 deletions .claude/commands/agent-sdk/resume.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,184 @@

Resume a previous agent session with full context preservation.

## Arguments
## Prerequisites

- `$ARGUMENTS` - Session ID to resume (or "list" to show recent sessions)
Before resuming sessions, ensure:

## Instructions
1. **Submodules initialized:**
```bash
git submodule update --init --recursive PMOVES-BoTZ
```

### List Sessions
2. **Dependencies installed:**
```bash
pip install -r pmoves/requirements.txt
```

If argument is "list" or empty:
```python
from pmoves_botz.features.agent_sdk import PMOVESSessionManager
3. **Services running:**
```bash
# Check NATS
curl http://localhost:4222

manager = PMOVESSessionManager()
sessions = await manager.list_sessions(limit=10)
for s in sessions:
print(f"{s.session_id}: {s.agent_id} ({s.status}) - {s.created_at}")
```
# Check TensorZero
curl http://localhost:3030/v1/models

# Check Hi-RAG v2
curl http://localhost:8086/healthz
```

4. **Storage backend accessible:**
- **File:** Check `~/.pmoves/sessions/` exists
- **Supabase:** Test connection with curl (see Storage Backends below)
- **SurrealDB:** Verify Open Notebook is running

## Usage

Use this command when:
- Continuing an interrupted task
- Resuming from a previous checkpoint
- Picking up work from an earlier session

### Resume Session
## Implementation

1. Load session state from storage (file/Supabase/SurrealDB)
2. Restore agent configuration and context
3. Continue from last checkpoint:
Execute via PMOVES CLI:

```python
from pmoves_botz.features.agent_sdk import PMOVESSessionManager
```bash
pmoves agent-sdk resume list
# List recent sessions

pmoves agent-sdk resume session-abc123
# Resume specific session with full context

manager = PMOVESSessionManager()
async for message in manager.resume(
session_id="$ARGUMENTS",
task="Continue from where we left off"
):
print(message.content)
pmoves agent-sdk resume session-abc123 "Continue the analysis"
# Resume with additional task context
```
Comment on lines +47 to 56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, check if mini_cli.py exists and examine resume-related code
fd mini_cli.py pmoves/

# Search for resume command registration
rg -n "resume" pmoves/tools/mini_cli.py -A 3 -B 1

# List all command registrations to see what's implemented
rg -n "\.command\(" pmoves/tools/mini_cli.py

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 2772


Documentation references unimplemented resume command.

The documented pmoves agent-sdk resume command does not exist as a standalone command in pmoves/tools/mini_cli.py. The CLI only registers create, run, list, and status commands for agent-sdk. Session resumption appears to be handled via the --session option in the run command. Update documentation to reflect the actual CLI interface or implement the standalone resume command.

πŸ€– Prompt for AI Agents
In .claude/commands/agent-sdk/resume.md around lines 16 to 25, the doc shows a
standalone "pmoves agent-sdk resume" command which is not implemented in
pmoves/tools/mini_cli.py (CLI only registers create, run, list, status and uses
--session on run to resume); update this file to reflect the actual CLI
interface by replacing the examples with the correct usage (e.g., show using
"pmoves agent-sdk run --session <session-id>" and the form with an extra prompt
argument), or alternatively implement and register a new "resume" subcommand in
pmoves/tools/mini_cli.py that forwards to the same run/session logic β€” pick one
approach and make the docs and code consistent.


### Arguments

- `session-id` - Session ID to resume, or "list" to show recent sessions

### Options

- `--task` - Additional task context for resumption (optional)

## What It Does

- βœ… Lists recent sessions with status
- βœ… Loads session state from storage
- βœ… Restores agent configuration and context
- βœ… Continues from last checkpoint
- βœ… Preserves conversation history
- βœ… Maintains tool execution state

### Session States

| State | Description |
|-------|-------------|
| `active` | Currently running |
| `paused` | Suspended, can resume |
| `completed` | Finished successfully |
| `failed` | Terminated with error |
| `forked` | Branched into new session |
| State | Description | Can Resume |
|-------|-------------|------------|
| `active` | Currently running | ❌ Already running |
| `paused` | Suspended, can resume | βœ… Ready to resume |
| `completed` | Finished successfully | βœ… Can fork new session |
| `failed` | Terminated with error | βœ… Can retry |
| `forked` | Branched into new session | ❌ Use child session |

### Storage Backends

Sessions are stored based on `SESSION_STORAGE` env var:
- `file` (default): `~/.pmoves/sessions/`
- `supabase`: `agent_sessions` table
- `surrealdb`: Open Notebook integration

**File System** (default):
```bash
export SESSION_STORAGE=file
# Sessions stored in: ~/.pmoves/sessions/
# No additional configuration required
```

**Supabase:**
```bash
export SESSION_STORAGE=supabase
export SUPABASE_URL=http://localhost:3010
export SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Verify connection:
curl http://localhost:3010/rest/v1/agent_sessions?limit=1 \
-H "apikey: ${SUPABASE_SERVICE_ROLE_KEY}"
```

**SurrealDB (Open Notebook):**
```bash
export SESSION_STORAGE=surrealdb
export OPEN_NOTEBOOK_API_URL=http://localhost:8085
export OPEN_NOTEBOOK_API_TOKEN=your_api_token
# Verify connection:
curl ${OPEN_NOTEBOOK_API_URL}/health \
-H "Authorization: Bearer ${OPEN_NOTEBOOK_API_TOKEN}"
```

## Timeouts

- **Session load:** 30 seconds default
- **Context restoration:** 60 seconds default
- **HTTP requests:** 30 seconds
- **NATS connection:** 10 seconds

Configure via environment variables:
```bash
export AGENT_SESSION_LOAD_TIMEOUT=30 # Session load timeout in seconds
export AGENT_CONTEXT_RESTORE_TIMEOUT=60 # Context restoration timeout in seconds
export AGENT_HTTP_TIMEOUT=30 # HTTP timeout in seconds
export AGENT_NATS_TIMEOUT=10 # NATS connection timeout in seconds
```

## Example

```bash
/agent-sdk:resume list
# Shows: session-abc123: pmoves-researcher-1703123456 (paused) - 2025-01-15
$ pmoves agent-sdk resume list

πŸ“‹ Recent Sessions:
session-abc123: pmoves-researcher-1735123456 (paused) - 2025-01-15 14:23:01
session-def456: pmoves-code-reviewer-1735123490 (completed) - 2025-01-15 15:10:22
session-ghi789: pmoves-researcher-1735123456 (failed) - 2025-01-15 16:05:33

$ pmoves agent-sdk resume session-abc123

πŸ”„ Loading session: session-abc123
πŸ“¦ Agent: pmoves-researcher-1735123456
πŸ“ Last Task: "Analyze PMOVES architecture"
βœ… Context restored from checkpoint

/agent-sdk:resume session-abc123
# Resumes session with full context
# Agent continues from last checkpoint
Continuing from where we left off...
[Agent continues with full conversation history]
```

## Related Commands

- `pmoves agent-sdk create` - Create new agent instance
- `pmoves agent-sdk run` - Execute task with agent
- `pmoves agent-sdk list` - List all agents
- `pmoves agent-sdk status` - Check agent status

## Notes

- **Session ID Required**: Use `list` argument to find session IDs
- **Context Preservation**: Full conversation history and tool state restored
- **Checkpoint System**: Agents auto-save progress at key milestones
- **Storage Location**: Configured via `SESSION_STORAGE` environment variable

## Troubleshooting

**"Session not found"**
- Verify session ID with: `pmoves agent-sdk resume list`
- Check storage backend is accessible (file system, Supabase, etc.)

**"Session state corrupted"**
- Session may have been interrupted during save
- Try creating new session instead: `pmoves agent-sdk create`

**"Cannot resume active session"**
- Session is currently running in another process
- Wait for completion or use `pmoves agent-sdk status` to check

**"Storage backend unavailable"**
- Check `SESSION_STORAGE` environment variable
- Verify backend connectivity:
- File: Check `~/.pmoves/sessions/` exists
- Supabase: Test connection with `psql`
- SurrealDB: Verify Open Notebook is running
Loading
Loading