Skip to content

Commit 9064d76

Browse files
LpcPaulqwencoder
andcommitted
refactor: shrink to MVP — ultra-short skill + flat cases + ledger
- README.md: MVP positioning (recovery memory layer, not v2.1 protocol) - SKILL.md: ultra-short (<60 lines), no complex schema/inference/retrieval - cases/: flat structure, one JSON file per tool - ledger.jsonl: append-only experience log - CONTRIBUTING.md: MVP contribution path (real cases, no schema validation) - docs/MVP.md: why we shrank, what we validate, future expansion order - docs/legacy/: all v2.1 architecture moved here (schema, rules, scripts, hooks, seeds, docs) - Remove requirements-dev.txt, .github/, scripts/ (moved to legacy) MVP does: short skill + flat cases + ledger MVP does not: schema validation, route registry, deterministic retrieval, hook automation Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
1 parent 9e04a95 commit 9064d76

55 files changed

Lines changed: 237 additions & 370 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 33 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,46 @@
1-
# Contribution Protocol — AgentRX
1+
# Contributing to AgentRX
22

3-
## How contributions enter the system
3+
## How to contribute
44

5-
**The default contributor is an AI agent.**
5+
**Current focus: real recovery cases, not infrastructure.**
66

7-
When an AI agent gets stuck and AgentRX helps it recover, the agent may optionally contribute the case back. This is the normal, high-volume contribution path.
7+
### Add or edit a case
88

9-
Human contribution is secondary and usually limited to:
10-
- schema and taxonomy changes
11-
- validation script improvements
12-
- maintenance of the route registry
13-
- exceptional cases that require human judgment
9+
1. Find the tool file in `cases/` (e.g. `cases/playwright-mcp.json`)
10+
2. If the file doesn't exist, create it as a JSON array
11+
3. Append your case:
1412

15-
**AI contributors must submit complete v2.1 JSON.** Human fallback / form-to-JSON assembly is no longer supported.
16-
17-
---
18-
19-
## AI contribution path (default)
20-
21-
When an AI agent decides to contribute a case:
22-
23-
1. Build a v2.1 case JSON with evidence and inference
24-
2. Generate a case ID: `python3 scripts/new_case_id.py --task <task-id>`
25-
3. Run `python3 scripts/validate_case.py --input case.json`
26-
4. If validation passes, submit via GitHub Issue using the case report template
27-
28-
The case must follow `schema/case.schema.json` (v2.1). Key requirements:
29-
- `schema_version` must be `"2.1"`
30-
- `evidence` and `inference` are both required
31-
- `best_candidate_route_id` must be a route id from `rules/routes.yaml`
32-
- No private business context
33-
34-
---
35-
36-
## What makes a good contribution
37-
38-
A good contribution preserves the real AI journey:
39-
40-
- **Preserve evidence before diagnosis.** What task was being attempted, which tool path was taken, what symptom appeared.
41-
- **Preserve symptom before interpretation.** Do not collapse observable facts into diagnosis too early. The evidence layer must be fillable from observable facts alone.
42-
- **Route id over tool brand.** Use `switch_to_alternative_tool_path`, not "use playwright-mcp". Route ids are stable; tool names are not.
43-
- **Explain the mismatch, not the failure.** `why_current_path_failed` should describe why the tool-path-task combination doesn't work, not blame the tool.
44-
- **Under-specify rather than invent.** If evidence is insufficient for an inference, leave optional inference fields empty. Polluted inference is worse than missing inference.
45-
- **Inference is re-computable; evidence is durable.** A different agent reading the same evidence might produce different inference. That is by design.
46-
47-
---
48-
49-
## Validation
50-
51-
All cases must pass validation before entering the library:
52-
53-
```bash
54-
# Validate a case file
55-
python3 scripts/validate_case.py --input your-case.json
56-
57-
# Rebuild the index
58-
python3 scripts/build_index.py
59-
60-
# Run all checks
61-
python3 scripts/ci_self_test.py
13+
```json
14+
{
15+
"id": "playwright-mcp-003",
16+
"status": "draft",
17+
"symptom": "describe the exact failure you saw",
18+
"env": "OS, headless/headed, proxy, etc.",
19+
"what_worked": "the concrete fix that resolved it",
20+
"what_didnt_work": ["what you tried that didn't help"],
21+
"times_confirmed": 1,
22+
"note": "any context that helps future agents"
23+
}
6224
```
6325

64-
Validation checks:
65-
- JSON Schema conformance (required fields, types, enums)
66-
- Route id validity (must exist in `rules/routes.yaml`)
67-
- Journey stage and problem family consistency with rules
68-
- Deprecated route/family auto-mapping with warning
69-
70-
---
71-
72-
## Adding a new route to the registry
73-
74-
Routes are defined in `rules/routes.yaml`. To add a new route:
75-
76-
1. Add an entry under `routes:` with `label`, `description`, `applies_when`, and `prerequisites`
77-
2. Run `python3 scripts/generate_schema.py` to sync schema enums from rules
78-
3. Run `python3 scripts/ci_self_test.py` to verify consistency
26+
### What makes a good case
7927

80-
---
28+
- **Concrete symptom** — exact error, timeout message, or behavior
29+
- **Executable what_worked** — something another agent can directly apply
30+
- **Honest what_didnt_work** — saves others from repeating dead ends
31+
- **Real experience only** — no imagined or synthetic cases in the main cases/ directory
8132

82-
## Environment information policy
33+
### Status values
8334

84-
The `evidence.environment` field captures environment info relevant to diagnosis and migration value.
35+
- `draft` — single report, not yet confirmed by others
36+
- `verified` — ≥2 independent experiences confirm the same fix works
37+
- `archived` — no longer relevant (e.g. tool version changed, workaround upstreamed)
8538

86-
- `platform` (required): e.g. `claude-code`, `openclaw`, `codex`, `cursor`
87-
- `requires_*` booleans: fill as applicable for the task
88-
- `runtime_version`, `execution_mode`, `sandbox_level`: recommended but not required
89-
- `model_provider`, `model_family`, `model_name`: **optional** — only fill when there is clear evidence that model differences affected the failure or migration value. Do not fill by default. Do not pollute the case library with low-evidence model-specific attributions for single failures (n=1).
90-
91-
**Privacy:** Do not include company names, private URLs, internal system names, or local file paths.
92-
93-
---
94-
95-
## Development
96-
97-
```bash
98-
git clone https://github.com/LpcPaul/AgentRX.git
99-
cd AgentRX
100-
101-
# Run all checks
102-
python3 scripts/ci_self_test.py
103-
```
39+
### What we don't require right now
10440

105-
## Code Style
41+
- Complete v2.1 JSON submission
42+
- Case ID generation scripts
43+
- Schema validation
44+
- Route registry alignment
10645

107-
- Python: Follow PEP 8, use type hints where practical
108-
- JSON: 2-space indent, trailing newline
109-
- YAML: 2-space indent
110-
- Commit messages: [Conventional Commits](https://www.conventionalcommits.org/)
46+
Just write a clear case in the tool file. That's it.

README.md

Lines changed: 42 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,67 @@
11
# AgentRX
22

3-
> 🩺 A task-first stuck-state protocol + deterministic retrieval layer for AI agents.
4-
> When your agent's tool path fails, AgentRX structures the failure, retrieves similar cases, and surfaces candidate routes.
3+
> Recovery memory layer for AI tool failures.
4+
> When your agent's third-party tool path fails, AgentRX surfaces what worked (and what didn't) from prior experience.
55
66
## What is AgentRX?
77

8-
AgentRX is **not** a human-facing tool directory. It is a **machine-consumable protocol** that answers one question:
8+
AgentRX is a **recovery experience library** for AI agents. It answers one question:
99

10-
> **The agent is stuck — what should it do next?**
10+
> **The agent's tool failed — what did someone else try that worked?**
1111
12-
It provides:
12+
It focuses on:
13+
- **Third-party tool failures** — playwright, browser-cdp, web-fetch, MCP connectors, etc.
14+
- **Environment long-tail issues** — proxy, headless, sandbox, permissions, dependencies
15+
- **What worked / what didn't** — concrete, actionable recovery guidance
1316

14-
- **Schema** — a standard v2.1 case format (evidence + inference separation)
15-
- **Route registry** — stable action paths, not tool brand names
16-
- **Validation** — JSON Schema + cross-file rule consistency checks
17-
- **Indexing** — lightweight case library index for retrieval
18-
- **Deterministic retrieval**`retrieve_cases.py` finds top-k candidate cases
17+
AgentRX does **not** compete with platform-level recovery (retry, circuit breaker, fallback routing). Those are the platform's job. AgentRX handles what platforms can't cover: real-world tool-specific experience.
1918

20-
AgentRX does **not** run inference for the agent. Route recommendation is the agent's own reasoning, based on retrieved cases + the route registry.
21-
22-
## A concrete example
23-
24-
```
25-
User: Extract the product list from this page.
26-
27-
AI: [tries browser-cdp skill]
28-
The page uses JavaScript to render content. browser-cdp only
29-
returned the initial HTML shell. Data missing.
30-
31-
[AgentRX activates]
32-
33-
AgentRX: Retrieved similar cases → route: switch_to_alternative_tool_path
34-
35-
Why: current tool captures static HTML only; page requires
36-
JavaScript rendering.
37-
38-
Candidate: playwright-mcp can render the page and extract
39-
the full DOM. web_fetch is a lighter option for static pages.
40-
```
41-
42-
---
43-
44-
## What AgentRX provides today
45-
46-
| Component | Status |
47-
|---|---|
48-
| Case schema (v2.1) ||
49-
| Route registry ||
50-
| Case validation | ✅ (JSON Schema + cross-file rules) |
51-
| Index building ||
52-
| Deterministic retrieval | ✅ (`retrieve_cases.py`) |
53-
| Case ID generation | ✅ (`new_case_id.py`) |
54-
55-
## What AgentRX does **not** provide (yet)
56-
57-
| Component | Status |
58-
|---|---|
59-
| Automated case review / merge / publish pipeline | 🚧 planned |
60-
| Python-based route recommender | ❌ out of scope — agent does its own route inference |
61-
62-
---
63-
64-
## Install
65-
66-
### Claude Code
19+
## How it works
6720

68-
```bash
69-
git clone https://github.com/LpcPaul/AgentRX.git ~/.claude/skills/agentrx
7021
```
71-
72-
### OpenClaw / ClawHub
73-
74-
```bash
75-
git clone https://github.com/LpcPaul/AgentRX.git ~/.openclaw/skills/agentrx
22+
1. Agent's third-party tool fails
23+
2. Agent tries to recover on its own — fails 2+ times
24+
3. Agent activates AgentRX skill
25+
4. Agent describes the failure in natural language
26+
5. Agent finds the matching tool file in cases/
27+
6. Agent reads the closest case, focuses on what_worked and what_didnt_work
28+
7. Agent applies the learned recovery
29+
8. Agent appends the outcome to ledger.jsonl
7630
```
7731

78-
### Codex / Cursor / other skill-compatible runtimes
32+
## Why we are shrinking from v2.1 to MVP
7933

80-
```bash
81-
git clone https://github.com/LpcPaul/AgentRX.git ~/.codex/skills/agentrx
82-
```
34+
The v2.1 architecture (schema validation, route registry, deterministic retrieval) was a well-intentioned infrastructure investment — but it put cart before horse. Before building a retrieval engine, we need to verify: **does case content actually help agents recover?**
8335

84-
---
36+
This MVP tests that question with minimal infrastructure. If the answer is "yes", we'll grow back the heavy architecture on a proven foundation. If "no", we saved months of wasted engineering.
8537

86-
## How it works
38+
## MVP does
8739

88-
```
89-
1. AI gets stuck (concrete failure signal)
90-
2. AI collects evidence (task, attempted_path, symptom)
91-
3. AI retrieves similar cases via retrieve_cases.py
92-
4. AI generates inference based on evidence + retrieved cases
93-
5. AI chooses a route based on retrieved cases + rules/routes.yaml
94-
6. AI records the outcome
95-
7. The new case becomes available for future AI agents
96-
```
40+
- A very short SKILL.md that tells the agent when and how to use AgentRX
41+
- Flat `cases/` directory — one JSON file per tool, containing case arrays
42+
- `ledger.jsonl` for append-only experience logging
43+
- Minimal case format: symptom, what_worked, what_didnt_work, times_confirmed
9744

98-
### Human installs. AI operates.
45+
## MVP does not do (yet)
9946

100-
| | What they do |
101-
|---|---|
102-
| **Human** | Install the skill. Host the repository. Maintain schema/taxonomy. |
103-
| **AI** | Detect stuck state. Collect evidence. Retrieve similar cases. Choose a route. Optionally contribute a new case. |
47+
- v2.1 JSON schema validation
48+
- Route registry / route recommendation
49+
- Deterministic retrieval scripts
50+
- Build index / validate / generate scripts as main path
51+
- Automated hooks triggering
52+
- Complex directory分层 (by_tool, by_tag, verified, curated, archived)
53+
- Synthetic seed cases
10454

105-
**AI contributors must submit complete v2.1 JSON.** Human fallback / form-to-JSON assembly is no longer supported.
55+
## Files
10656

107-
---
108-
109-
## Read this next
110-
111-
| Document | Role |
57+
| File | Role |
11258
|---|---|
113-
| [SKILL.md](SKILL.md) | The runtime protocol the AI agent reads when activated |
114-
| [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | System design — why evidence/inference, why route ids |
115-
| [docs/INTAKE_CARD.md](docs/INTAKE_CARD.md) | The structured intake card format |
116-
| [CONTRIBUTING.md](CONTRIBUTING.md) | How cases enter the system — JSON-only contribution path |
117-
| [cases/README.md](cases/README.md) | Case library structure and indexing |
118-
119-
## Developer validation
120-
121-
```bash
122-
pip install -r requirements-dev.txt
123-
python3 scripts/ci_self_test.py
124-
python3 scripts/build_index.py
125-
```
59+
| [SKILL.md](SKILL.md) | Ultra-short runtime protocol the agent reads when activated |
60+
| [cases/](cases/) | Flat case directory — one JSON file per tool |
61+
| [ledger.jsonl](ledger.jsonl) | Append-only experience log |
62+
| [CONTRIBUTING.md](CONTRIBUTING.md) | How to contribute real recovery cases |
63+
| [docs/MVP.md](docs/MVP.md) | Why we shrank, what we validate, future expansion order |
64+
| [docs/legacy/](docs/legacy/) | v1→v2.1 architecture exploration (historical reference only) |
12665

12766
## License
12867

0 commit comments

Comments
 (0)