# Auto-Accept on New Topic Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Silently accept an awaiting Task before processing an unrelated new topic.

**Architecture:** Keep the existing Intent Agent actions. Treat `simple_chat` and `new_task` decisions made while a Task is active as new-topic boundaries, reuse `submit_acceptance()` for the old Task's latest run, and then continue the original routing decision.

**Tech Stack:** Python, pytest, Beaver TaskService and AgentService

---

### Task 1: Lock the State Transition with Tests

**Files:**
- Modify: `app-instance/backend/tests/unit/test_task_mode_feedback.py`

- [ ] Add a failing test proving an unrelated `simple_chat` message formally accepts the previous Task and does not append another run to it.
- [ ] Add a failing test proving `new_task` formally accepts the previous Task before creating a separate Task.
- [ ] Add tests proving `continue_task` and `revise_task` retain the existing active Task behavior.
- [ ] Run:

```bash
uv run pytest -q tests/unit/test_task_mode_feedback.py
```

Expected before implementation: the new-topic tests fail because the previous Task remains `awaiting_acceptance`.

### Task 2: Implement New-Topic Auto-Accept

**Files:**
- Modify: `app-instance/backend/beaver/services/agent_service.py`

- [ ] Add a focused async helper that accepts only an `awaiting_acceptance` Task with a latest run.
- [ ] Call the helper after routing when the decision is `simple_chat` or starts a new Task.
- [ ] Reuse `submit_acceptance()` so acceptance history, final accepted run, run memory, and learning behavior remain consistent.
- [ ] Run:

```bash
uv run pytest -q tests/unit/test_task_mode_feedback.py
```

Expected: all task-mode feedback tests pass.

### Task 3: Clarify Intent Routing Guidance

**Files:**
- Modify: `app-instance/backend/beaver/tasks/router.py`
- Modify: `app-instance/backend/beaver/skills/builtin/intent-agent-router/SKILL.md`
- Modify: `app-instance/backend/tests/unit/test_main_agent_router.py`

- [ ] Assert the generated routing prompt explicitly says unrelated lightweight conversation is `simple_chat`, not `revise_task`.
- [ ] Update both routing guidance sources with the same rule and examples.
- [ ] Run:

```bash
uv run pytest -q tests/unit/test_main_agent_router.py
```

Expected: all router tests pass.

### Task 4: Regression Verification

**Files:**
- Verify only

- [ ] Run:

```bash
uv run pytest -q tests/unit/test_main_agent_router.py tests/unit/test_task_mode_feedback.py tests/unit/test_active_task_api.py tests/unit/test_process_projection.py
```

- [ ] Inspect the final diff to confirm no frontend confirmation or unrelated state changes were introduced.
