@agentxin-ai/plugin-middleware-reflection
v0.0.1
Published
Reflection middleware plugin for AgentXinAI — post-execution quality evaluation, SOP distillation and KEDB archiving.
Maintainers
Readme
@agentxin-ai/plugin-middleware-reflection
Post-execution reflection middleware for AgentXinAI agents — evaluates agent performance, distills SOPs from high-scoring executions, and archives known errors from failures.
Features
- Quality Evaluation — LLM-based scoring across tool selection, process adherence, and resolution quality (1–5 scale)
- SOP Distillation — Automatically extracts Standard Operating Procedures from high-scoring executions into a knowledge base
- KEDB Archiving — Archives failure patterns into a Known Error Database for future retrieval
- Knowledge Retrieval Augmentation — Injects relevant SOPs/KEDBs into agent system prompts via
wrapModelCall - Custom KPIs — Add domain-specific evaluation metrics
- Blended Scoring — Combines LLM evaluation with optional user ratings
Installation
npm install @agentxin-ai/plugin-middleware-reflectionActivation
Add the plugin to the PLUGINS environment variable in your AgentXinAI host project:
PLUGINS=@agentxin-ai/plugin-middleware-reflectionFor multiple plugins, separate with commas:
PLUGINS=@agentxin-ai/plugin-middleware-reflection,@agentxin-ai/plugin-agent-middlewaresSee Plugin Publish & Use for full host-loading documentation.
Configuration
Once loaded, navigate to an Agent's middleware settings in AgentXin Studio and add Reflection Middleware. Available options:
| Field | Description | |---|---| | Evaluation Model | LLM used for reflection scoring, SOP distillation and KEDB archiving | | Domain Context | Business domain description for context-aware evaluation | | SOP Knowledge Base | Knowledge base ID for storing distilled SOPs | | SOP Distill Threshold | Minimum overall score (1–5) to trigger SOP distillation (default: 4) | | KEDB Knowledge Base | Knowledge base ID for archiving known errors | | Error Archive Threshold | Maximum overall score (1–5) to trigger KEDB archiving (default: 2) | | Custom KPIs | Domain-specific evaluation metrics (key, type, description) | | Reflection Prompt | Advanced: fully override the built-in evaluation prompt | | SOP Distill Prompt | Advanced: override the SOP distillation prompt | | KEDB Prompt | Advanced: override the KEDB archiving prompt |
How It Works
User ──► Agent executes ──► afterAgent hook fires
│
┌─────▼──────┐
│ LLM Score │ (Phase 1: evaluate execution)
└─────┬──────┘
│
┌───────────┼───────────┐
▼ │ ▼
Score ≥ 4 │ Score ≤ 2
┌────────┐ │ ┌────────┐
│Distill │ │ │Archive │
│ SOP │ │ │ KEDB │
└────────┘ │ └────────┘
▼
(no write for 3)On the next conversation turn, wrapModelCall retrieves relevant SOPs/KEDBs and injects them into the agent's system prompt.
Development
# Build
npx nx build middleware-reflection
# Test
npx nx test middleware-reflection
# Publish
npx nx run @agentxin-ai/plugin-middleware-reflection:nx-release-publish --access publicLicense
BUSL-1.1
