OpenWriterControle/.opencode/prompts/openagent
Darren Hinde 784ffadf92
chore: verify and stabilize main branch (#42)
* chore: update package-lock.json after npm install

* chore: remove unused ajv-cli, keep vitest at stable 1.6.1

- Removed ajv-cli (unused dev dependency, had high severity vulnerability)
- Kept vitest at 1.6.1 (stable, upgrading to v4 requires extensive refactoring)
- Reduced vulnerabilities from 6 to 4 (all moderate, dev-only)
- All remaining vulnerabilities are in esbuild/vite (dev server only, no production impact)
- Build and tests verified working

* feat(evals): add execution-balance validation to 21 OpenAgent tests and enhance agent system

Major improvements to evaluation framework and agent capabilities:

## Execution Balance Evaluator Integration
- Added execution-balance rule to 21 OpenAgent tests (2.7% → 31.5% coverage)
- Validates "read before execute" pattern across critical rules, workflows, and edge cases
- Tests now check: read operations before execution tools, healthy read/exec ratio (≥1.0)
- Coverage includes: approval-gate, context-loading, stop-on-failure, report-first tests

## Agent System Enhancements
- Enhanced OpenCoder agent with critical rules enforcement (approval gates, context loading)
- Added structured delegation rules and workflow phases
- Improved error handling with REPORT→PROPOSE→REQUEST→FIX pattern

## New Agent Creation System
- Added research-backed agent creation templates and guides
- Includes 8 test templates covering planning, context, incremental execution, tools
- Automated agent scaffolding with /create-agent command
- Complete documentation in .opencode/command/openagents/new-agents/

## OpenCoder Test Suite
- Added 8 comprehensive test cases for OpenCoder agent
- Tests cover: planning, context-loading, delegation, error-handling, implementation
- Includes DEBUG_GUIDE.md and QUICK_TEST_GUIDE.md for developers

## Documentation & Tooling
- Added DEVELOPMENT.md guide for contributors
- Enhanced CONTRIBUTING.md with quick reference and common commands
- Improved event-logger with DEBUG_VERBOSE mode for detailed output
- Added debug scripts: show-test-conversation.sh, run-test-verbose.sh
- Removed deprecated EXTERNAL_PR_GUIDE.md

## Version Bump
- Bumped version to 0.0.3 (patch)

Files changed: 60+ files (21 test updates, 16 new agent templates, 8 new tests, docs, tooling)

* feat(ci): add PR title validation for semantic versioning

Add automated PR title validation to ensure conventional commit format.
This enables proper automatic version bumping when PRs are merged.

Features:
- Validates PR titles against conventional commit patterns
- Shows expected version bump (major/minor/patch)
- Posts helpful comment with examples if validation fails
- Supports all conventional commit types (feat, fix, docs, etc.)
- Supports breaking changes (feat!, fix!)
- Supports pre-release tags ([alpha], [beta], [rc])

When PR titles follow the format, version bumping works correctly:
- feat: → minor bump (0.3.0 → 0.4.0)
- fix: → patch bump (0.3.0 → 0.3.1)
- feat!: → major bump (0.3.0 → 1.0.0)

* fix(ci): improve PR checks workflow with sequential execution

Reorganize PR checks to run in logical sequence and skip unnecessary checks:

Changes:
- Run PR title validation first (fast, always required)
- Detect changed files to determine which checks to run
- Only run build checks if evals/ files changed
- Add comprehensive summary job showing all check results
- Prevent cache errors when evals files not changed

Benefits:
- Faster PR checks (skip unnecessary builds)
- Clear sequential execution (title → changes → build)
- Better error messages and summaries
- Reduced CI/CD costs

* fix(ci): resolve PR #42 issues and refactor prompt architecture

## Fixed PR #42 Issues

1. **Prompt Validation** - Refactored to new architecture where agent files are canonical defaults
2. **Package-lock.json** - Fixed workflow to use root package-lock (npm workspaces)
3. **Git Merge Base** - Added fetch-depth: 0 to PR checks workflow

## New Prompt Architecture

**Before:**
- Agent files had to match .opencode/prompts/<agent>/default.md
- Caused validation failures when updating prompts
- Redundant duplication

**After:**
- Agent files (.opencode/agent/*.md) = Canonical defaults (source of truth)
- Prompt variants (.opencode/prompts/<agent>/<model>.md) = Model-specific optimizations
- No more default.md files needed

## Changes

### Workflows
- pr-checks.yml: Added fetch-depth: 0 for full git history
- validate-test-suites.yml: Fixed package-lock path for npm workspaces
- validate-registry.yml: Updated validation messaging

### Scripts
- validate-pr.sh: Validates prompt library structure (rejects default.md files)
- use-prompt.sh: Handles 'default' as agent file, variants as model-specific
- test-prompt.sh: Tests default variant correctly, saves results to prompts/results/

### Documentation
- .opencode/prompts/README.md: Updated architecture explanation
- docs/contributing/CONTRIBUTING.md: Updated prompt workflow
- scripts/development/demo.sh: Updated structure display

## Results

- 12 files changed, 231 insertions(+), 811 deletions(-)
- Net reduction: 580 lines (cleaner codebase)
- All validations passing
- Results directory structure preserved
- Backwards compatible with existing test results
2025-12-09 13:26:52 +00:00
..
results feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
gemini.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
gpt.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
grok.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
llama.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
README.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00
TEMPLATE.md feat: add PR template and automated doc sync workflow (#40) 2025-12-08 22:27:01 +00:00

OpenAgent Prompt Variants

Model-specific prompt optimizations with comprehensive test results.


🚀 Quick Start

# Test a variant with eval framework
cd evals/framework
npm run eval:sdk -- --agent=openagent --prompt-variant=llama --suite=smoke-test

# Run full core suite
npm run eval:sdk -- --agent=openagent --prompt-variant=llama --suite=core-tests

# View results
open ../results/index.html

📊 Capabilities Matrix

Variant Model Family Approval Gate Context Loading Stop on Failure Delegation Tool Usage Pass Rate Status
default Claude ✅ ✅ ✅ ✅ ✅ 7/7 (100%) ✅ Stable
gpt GPT ✅ ✅ ✅ ✅ ✅ 7/7 (100%) ✅ Stable
gemini Gemini ✅ ✅ ✅ ✅ ✅ 7/7 (100%) ✅ Stable
grok Grok ✅ ✅ ✅ ✅ ✅ 7/7 (100%) ✅ Stable
llama Llama/OSS ✅ ✅ ✅ ✅ ✅ 7/7 (100%) ✅ Stable

Legend:

  • ✅ Works reliably (passes tests)
  • ⚠️ Partial/inconsistent
  • ❌ Does not work
  • - Not tested yet

Last Updated: 2025-12-08
Test Suite: Core tests (7 tests)
Model Used: opencode/grok-code-fast (for validation)


📝 Available Variants

default.md - Claude Optimized

Target Models:

  • anthropic/claude-sonnet-4-20250514 (primary)
  • anthropic/claude-3-5-sonnet-20241022

Optimizations:

  • Structured with <context> tags for Claude's context handling
  • Detailed workflow stages with checkpoints
  • Emphasis on safety rules and approval gates

Test Results:

{
  "total_tests": 7,
  "passed": 7,
  "failed": 0,
  "pass_rate": 100%,
  "avg_duration": "~45s per test"
}

Known Issues: None

Use When: Using Claude models (recommended for production)


gpt.md - GPT-4 Optimized

Target Models:

  • openai/gpt-4o
  • openai/gpt-4-turbo
  • openai/gpt-4o-mini

Optimizations:

  • Structured with clear sections and headers
  • Explicit instructions for tool usage
  • Emphasis on step-by-step reasoning

Test Results:

{
  "total_tests": 7,
  "passed": 7,
  "failed": 0,
  "pass_rate": 100%,
  "avg_duration": "~40s per test"
}

Known Issues: None

Use When: Using GPT-4 family models


gemini.md - Gemini Optimized

Target Models:

  • google/gemini-2.0-flash-exp
  • google/gemini-2.5-flash
  • google/gemini-pro

Optimizations:

  • Structured for Gemini's instruction-following
  • Clear role definitions
  • Emphasis on safety and validation

Test Results:

{
  "total_tests": 7,
  "passed": 7,
  "failed": 0,
  "pass_rate": 100%,
  "avg_duration": "~35s per test"
}

Known Issues: None

Use When: Using Gemini models


grok.md - Grok Optimized

Target Models:

  • opencode/grok-code-fast (free tier)
  • x-ai/grok-beta

Optimizations:

  • Concise, direct instructions
  • Emphasis on practical execution
  • Optimized for Grok's coding focus

Test Results:

{
  "total_tests": 7,
  "passed": 7,
  "failed": 0,
  "pass_rate": 100%,
  "avg_duration": "~50s per test"
}

Known Issues: None

Use When: Using Grok models (great for free tier testing)


llama.md - Llama/OSS Optimized

Target Models:

  • ollama/llama3.2
  • ollama/qwen2.5
  • ollama/deepseek-r1
  • Other open-source models

Optimizations:

  • Clear, structured instructions
  • Explicit examples and patterns
  • Optimized for smaller model context windows
  • Emphasis on tool usage patterns

Test Results:

{
  "total_tests": 7,
  "passed": 7,
  "failed": 0,
  "pass_rate": 100%,
  "avg_duration": "~60s per test"
}

Known Issues: None

Use When: Using open-source models (Llama, Qwen, DeepSeek, etc.)


🧪 Testing Variants

Quick Smoke Test (1 test, ~30s)

cd evals/framework
npm run eval:sdk -- --agent=openagent --prompt-variant=llama --suite=smoke-test

Core Test Suite (7 tests, ~5-8min)

npm run eval:sdk -- --agent=openagent --prompt-variant=llama --suite=core-tests

With Specific Model

npm run eval:sdk -- --agent=openagent --prompt-variant=llama --model=ollama/llama3.2 --suite=core-tests

View Results

# Dashboard
open ../results/index.html

# JSON results
cat ../results/latest.json

# Per-variant results
cat results/llama-results.json

📈 Test Coverage

All variants are tested against the Core Test Suite which validates:

Critical Rules (4 tests)

  1. ✅ Approval Gate - Requests approval before execution
  2. ✅ Context Loading - Loads required context files
  3. ✅ Stop on Failure - Stops and reports errors
  4. ✅ Report First - Reports before fixing

Functionality (3 tests)

  1. ✅ Simple Tasks - Handles tasks directly (no unnecessary delegation)
  2. ✅ Delegation - Delegates appropriately to subagents
  3. ✅ Tool Usage - Uses proper tools (read/grep vs bash)

Total: 7 tests covering ~85% of critical functionality

See evals/agents/openagent/config/core-tests.json for details.


🔧 Creating a New Variant

Step 1: Copy Template

cp .opencode/prompts/openagent/TEMPLATE.md .opencode/prompts/openagent/my-variant.md

Step 2: Edit Metadata

---
model_family: oss
recommended_models:
  - ollama/my-model
status: experimental
maintainer: your-name
description: Optimized for my specific use case
tested_with: ollama/my-model
last_tested: 2025-12-08
---

Step 3: Customize Prompt

Edit the prompt content for your target model:

  • Adjust instruction style
  • Modify examples
  • Change emphasis areas
  • Optimize for model strengths

Step 4: Test

# Smoke test
cd evals/framework
npm run eval:sdk -- --agent=openagent --prompt-variant=my-variant --suite=smoke-test

# Core suite
npm run eval:sdk -- --agent=openagent --prompt-variant=my-variant --suite=core-tests

Step 5: Document Results

Update this README with:

  • Test results (pass rate, timing)
  • Known issues or limitations
  • Recommended use cases
  • Model-specific notes

Step 6: Submit PR

  • Include variant file only (don't modify default.md)
  • Update this README with results
  • Ensure tests pass (≥85% pass rate)

📊 Understanding Results

Result Files

Per-variant results (results/{variant}-results.json):

{
  "variant": "llama",
  "model": "ollama/llama3.2",
  "timestamp": "2025-12-08T21:43:08.964Z",
  "summary": {
    "total": 7,
    "passed": 7,
    "failed": 0,
    "pass_rate": 1
  },
  "tests": [...]
}

Dashboard (evals/results/index.html):

  • Filter by variant
  • Compare pass rates
  • View detailed test results
  • Track trends over time

🎯 Best Practices

Choosing a Variant

  1. Match your model family - Use gpt.md for GPT-4, llama.md for OSS
  2. Test before committing - Run core suite to verify
  3. Check compatibility - Some models work better with certain variants
  4. Start with default - If unsure, default.md works well across models

Testing Your Changes

  1. Start with smoke-test - Fast validation (1 test)
  2. Run core-tests - Thorough validation (7 tests)
  3. Test with your target model - Ensure compatibility
  4. Check dashboard - Visual feedback on performance

Contributing Variants

  1. Document thoroughly - Explain optimizations and trade-offs
  2. Test extensively - Run full core suite multiple times
  3. Be honest - Document both improvements and limitations
  4. Share results - Help others by documenting findings

🚀 Advanced Usage

Custom Test Suites

Create custom suites for your variant:

# Create suite
cp evals/agents/openagent/config/smoke-test.json \
   evals/agents/openagent/config/my-suite.json

# Validate
cd evals/framework && npm run validate:suites openagent

# Run
npm run eval:sdk -- --agent=openagent --prompt-variant=my-variant --suite=my-suite

Comparing Models

Test the same variant with different models:

# Test Llama 3.2
npm run eval:sdk -- --agent=openagent --prompt-variant=llama --model=ollama/llama3.2 --suite=core-tests

# Test Qwen 2.5
npm run eval:sdk -- --agent=openagent --prompt-variant=llama --model=ollama/qwen2.5 --suite=core-tests

# Compare in dashboard
open ../results/index.html

🤝 Contributing

What Makes a Good Variant?

  • ✅ Clear target - Specify which model(s) it's optimized for
  • ✅ Documented changes - Explain what you changed and why
  • ✅ Test results - Include real test results (≥85% pass rate)
  • ✅ Honest assessment - Document both improvements and limitations
  • ✅ Proper metadata - Complete YAML frontmatter

Promoting a Variant to Default

A variant can become the new default if it:

  1. Shows significant improvement in test results
  2. Works reliably across multiple models
  3. Has been tested by multiple contributors
  4. Doesn't introduce new critical issues
  5. Maintains ≥95% pass rate on core tests

Maintainers will review test results and community feedback before promoting.



🆘 Troubleshooting

Variant Not Found

# List available variants
ls .opencode/prompts/openagent/*.md

# Verify variant name
npm run eval:sdk -- --agent=openagent --prompt-variant=your-variant --suite=smoke-test

Tests Failing

  1. Check variant metadata (YAML frontmatter)
  2. Verify recommended model is available
  3. Run with debug: npm run eval:sdk -- --debug
  4. Check specific test failures in dashboard

Low Pass Rate

  • Review failed tests in dashboard
  • Check if model supports required capabilities
  • Consider adjusting prompt for model strengths
  • Test with different models in same family

💡 Tips

  • Start small - Test with smoke-test first
  • Iterate quickly - Use smoke-test for rapid iteration
  • Document everything - Help others learn from your experience
  • Share results - Update this README with your findings
  • Ask for help - Open an issue if you're stuck

Questions? See main README or open an issue.