agentscope-ai / agentscope-ai/QwenPaw

[Feature]: Task Recording System (/task and /taskstop)

未关闭
#3,408 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
Python
星标
34.9k
派生
3.1k
平均合并
1 天 15 小时
30 天内合并 PR
225

描述

# Summary
Add native /task and /taskstop commands to QwenPaw that create persistent, interrupt-resistant task recording sessions. All dialogue and file operations between these commands are captured to a dedicated memory store, with layered indexing for later retrieval.

---

## Motivation

### Problem
When working on complex tasks that span multiple conversation turns, QwenPaw's system commands (/new, /clear, /compact) will interrupt and lose the task context. Users currently have no way to:

1. **Protect ongoing work** from accidental /new or /clear
2. **Create a complete audit trail** of all operations in a task session
3. **Resume or reference** completed task sessions later

### Use Cases
- **Long debugging sessions**: Record all exploration steps, file changes, and decisions
- **Code review workflows**: Document analysis, changes, and rationale
- **Learning sessions**: Capture research, experiments, and discoveries
- **Multi-step tasks**: Maintain context across dozens of conversation turns

---

## Proposed Solution

### Command Interface
/task [name] # Start recording (optional name for the task)
/taskstop # Stop recording and save

### Behavior
1. **Recording State**: Stored in **file-based state** (not in-memory), survives /new/clear
2. **Captured Content**: User messages, assistant responses, file operations, timestamps
3. **Output Location**: memory/tasks/ directory
4. **Indexing**: Layered structure with task metadata, event log, file manifest

### Interaction with System Commands

| Command | When Idle | During Recording |
|-----------|------------------------|------------------------------------------------|
| /new | Normal behavior | Warning: "Task recording active. Use /taskstop first." |
| /clear | Normal behavior | Warning: "Task recording active. Use /taskstop first." |
| /compact | Normal behavior | Recording continues, compact runs normally |
| /task | Starts new recording | Ignored (already recording) |
| /taskstop | Message: "No active recording" | Stops and saves |

---

## Technical Design

### Architecture
- Hook-based approach in copaw/agents/hooks/
- Registration via react_agent.py _register_hooks()
- State persisted to ~/.copaw/task_state.json

### File Structure
memory/
└── tasks/
├── index.json # Task list index
└── {task_id}/
├── metadata.json # Task name, start/end, duration
├── events.jsonl # Chronological event log
└── manifest.json # File manifest

### Event Schema
{
"timestamp": "2026-04-15T10:30:00Z",
"type": "user_message|assistant_message|file_read|file_write|file_edit",
"content": "...",
"metadata": {}
}

---

## Key Requirements

1. **Impervious to interruption**: Recording state survives /new, /clear, /compact
2. **Zero impact on normal operation**: When not recording, QwenPaw works exactly as before
3. **Update-safe**: Implementation via hook system, survives QwenPaw updates
4. **Minimal memory overhead**: Only active events stored in memory, bulk to disk
5. **Backward compatible**: Existing commands and workflows unchanged

---

## Alternative Approaches Considered

### Hook-based Interception
- Pros: Update-safe, modular
- Cons: Requires understanding reply() flow

### Modify CommandHandler
- Pros: Direct command interception
- Cons: Updates may overwrite changes

### Skill-based Solution
- Pros: User-space implementation
- Cons: Cannot intercept /new (skill hooks run after command check)

---

## Additional Context

This is similar to:
- VS Code Tasks: Bounded contexts for complex operations
- GitHub Actions: Workflows with state persistence
- Terminal session managers: tmux, screen for session persistence

---

**Priority**: Medium (enhances productivity but not blocking)
**Complexity**: Medium (requires hooks + file I/O + state management)
**Related**: Multi-agent workflows (future roadmap item)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。