home / skills / plurigrid / asi / amp-skill

amp-skill skill

/skills/amp-skill

This skill analyzes Amp thread history to identify interruption patterns and suggests strategies to reduce rejections and improve agent behavior.

npx playbooks add skill plurigrid/asi --skill amp-skill

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.8 KB
---
name: amp-skill
description: Interruption pattern detection and retrieval from Amp thread history. Use for analyzing tool rejection patterns and improving agent behavior.
metadata:
  trit: 0
  color: "#26D826"
---

# Amp-Skill: Interruption Pattern Detection and Retrieval

**GF(3) Trit**: 0 (ERGODIC - coordination layer)
**Foundation**: DuckDB ACSet from Amp file-changes

## Overview

Amp-Skill distills usage patterns from Amp thread history, specifically focusing on **interruption patterns** where tool suggestions were rejected in favor of:
1. **Two-lock processes** - user requested confirmation before proceeding
2. **Complete discontinuation** - user abandoned the thread entirely
3. **Reverted operations** - user explicitly undid an AI action

## Retrieval Benchmark Metrics

| Metric | Value |
|--------|-------|
| Total Threads | 616 |
| Total Tool Calls | 2,535 |
| Threads with Interruptions | 282 (45.8%) |
| Reverted Tool Calls | 84 (3.3%) |
| Two-Lock Cascades | 47 |
| Complete Discontinuations | 22 |

## Interruption Pattern Distribution

| Pattern Type | Count | Percentage |
|--------------|-------|------------|
| abandoned | 269 | 62.4% |
| reverted | 84 | 19.5% |
| two_lock | 47 | 10.9% |
| discontinuation | 22 | 5.1% |
| high_rejection | 9 | 2.1% |

## GF(3) Distribution

| Role | Threads | Tool Calls | Reverted |
|------|---------|------------|----------|
| MINUS | 218 | 769 | 27 |
| ERGODIC | 209 | 976 | 26 |
| PLUS | 189 | 790 | 31 |

## File Types Most Frequently Reverted

1. `.org` - 28 reverts (Emacs org-mode files)
2. `.py` - 20 reverts (Python scripts)
3. `.sh` - 18 reverts (Shell scripts)
4. `.md` - 15 reverts (Markdown documentation)

## SQL Access

```sql
-- Query interruption patterns
SELECT * FROM amp_interruptions ORDER BY ts DESC;

-- Find high-rejection threads
SELECT thread_id, tool_call_count, reverted_count,
       ROUND(100.0 * reverted_count / tool_call_count, 1) as revert_pct
FROM amp_threads
WHERE reverted_count > 0
ORDER BY revert_pct DESC;

-- Detect two-lock cascades
SELECT thread_id, COUNT(*) as consecutive_reverts
FROM amp_interruptions
WHERE pattern_type = 'two_lock'
GROUP BY thread_id
ORDER BY consecutive_reverts DESC;
```

## Key Insights

### 1. Abandoned Threads (62.4%)
- Single tool call threads indicate quick task completion OR user abandonment
- Requires context analysis to distinguish

### 2. Two-Lock Cascades (10.9%)
- 47 instances of consecutive reverts within 60 seconds
- Indicates AI attempting same action repeatedly despite rejection
- **Action**: Implement backoff after 2 consecutive reverts

### 3. High-Rejection Threads (2.1%)
- 9 threads with >50% revert rate
- Top offender: 100% revert rate on `capability-signer-prototype.sh`
- **Pattern**: Security-sensitive code rejected multiple times

### 4. File Type Sensitivity
- `.org` files most frequently rejected (28)
- Personal/organizational files have higher rejection rate
- **Action**: Add confirmation prompt for org-mode edits

## Retrieval Benchmark Success Criteria

- [x] All 616 threads loaded from filesystem
- [x] All 2,535 tool calls indexed with metadata
- [x] 5 interruption pattern types detected
- [x] Two-lock pattern detection via SQL windowing
- [x] Discontinuation pattern (thread ends on revert)
- [ ] GF(3) conservation (currently imbalanced by 29)

## Usage

```bash
# Load/refresh Amp threads
bb scripts/amp_thread_loader.bb

# Query via DuckDB
duckdb trit_stream.duckdb "SELECT * FROM amp_interruptions"
```

## Integration with Triadic Protocol

When Amp-Skill detects a high-rejection pattern:
1. **MINUS (-1)**: Validate the rejection pattern
2. **ERGODIC (0)**: Coordinate alternative approaches
3. **PLUS (+1)**: Generate new solution avoiding rejected pattern

## Data Sources

- **Local**: `~/.amp/file-changes/T-*` (2,535 files)
- **API**: None currently (file-changes only contain diffs)
- **Potential**: Amp GraphQL API for full conversation history

Overview

This skill detects and retrieves interruption patterns from Amp thread history to help diagnose tool rejection and improve agent behavior. It summarizes where suggestions were rejected, when users reverted actions, and when threads were abandoned. The goal is actionable signals for safer, more context-aware agent responses.

How this skill works

The skill ingests Amp thread and file-change history stored in a DuckDB ACSet and indexes tool calls, timestamps, roles, and revert flags. It classifies interruptions into types such as abandoned, reverted, two_lock cascades, discontinuation, and high_rejection, and exposes SQL queries to explore patterns by thread, file type, and role. Outputs include counts, percentages, and alerts for rapid consecutive reverts that indicate repeated unwanted actions.

When to use it

  • Audit agent interactions to find frequent rejections or undo actions
  • Detect rapid repeated agent actions (two-lock cascades) and implement backoff policies
  • Prioritize confirmations for file types or contexts with high revert rates (e.g., org-mode)
  • Investigate security-sensitive threads with high rejection rates
  • Measure the impact of behavioral changes after agent policy updates

Best practices

  • Run a full ingest periodically to keep indices current and preserve timestamps for temporal analysis
  • Use provided SQL queries to filter by thread, role, file type, and revert percentage before acting
  • Treat single-call abandoned threads with contextual checks to distinguish success vs. abandonment
  • Implement a backoff after two consecutive reverts and require explicit user confirmation for sensitive file edits
  • Combine pattern signals (revert rate + short inter-revert intervals) to prioritize remediation work

Example use cases

  • Detect a pattern where an agent repeatedly attempts the same file edit and add a backoff policy after two rejections
  • Flag workflows that touch .org, .py, .sh, or .md files for extra confirmation based on historical revert frequency
  • Find threads with >50% revert rate to inspect security-sensitive operations and retrain the agent
  • Measure effects of changes by comparing interruption distributions before and after deploying an update

FAQ

What data is required to run the skill?

A local Amp file-change history dataset indexed into DuckDB with tool-call metadata, timestamps, roles, and revert annotations.

How are two-lock cascades defined?

Consecutive reverts within a short window (analysis used 60 seconds) where the agent repeats an action despite prior rejection; recommended policy is a backoff after two occurrences.