
Dual-Cycle Reasoner
Detects when AI agents get stuck in repetitive loops and automatically suggests recovery strategies based on past experiences. Uses statistical analysis and semantic understanding to improve agent reliability.
Provides dual-cycle metacognitive reasoning framework that detects when autonomous agents get stuck in repetitive behaviors through statistical anomaly detection and semantic analysis, then automatically diagnoses failure causes and generates recovery strategies using case-based learning.
What it does
- Detect repetitive behaviors in agent actions
- Analyze semantic patterns using NLP
- Generate recovery strategies from past cases
- Monitor agent progress and state changes
- Store and retrieve solution experiences
- Perform entropy-based anomaly detection
Best for
About Dual-Cycle Reasoner
Dual-Cycle Reasoner is a community-built MCP server published by cyqlelabs that provides AI assistants with tools and capabilities via the Model Context Protocol. Dual-Cycle Reasoner enables agents to detect repetitive behavior, diagnose failure causes, and recover with advanced met It is categorized under ai ml, developer tools.
How to install
You can install Dual-Cycle Reasoner in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
License
Dual-Cycle Reasoner is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
MCP Dual-Cycle Reasoner

A Model Context Protocol (MCP) server implementing the Dual-Cycle Metacognitive Reasoning Framework for autonomous agents. This tool empowers agents with greater self-awareness and reliability through intelligent loop detection and experience acquisition.
Description
The MCP Dual-Cycle Reasoner is a sophisticated tool designed to enhance the autonomy and reliability of AI agents. By implementing a dual-cycle metacognitive framework, it provides agents with the ability to monitor their own cognitive processes, detect when they are stuck in repetitive loops, and learn from past experiences to make better decisions.
The framework consists of two main components:
- Sentinel: Monitors the agent's actions and detects anomalies, such as action repetition, state invariance, and progress stagnation.
- Adjudicator: Manages a case base of past experiences, allowing the agent to store and retrieve solutions to previously encountered problems.
This server is built with TypeScript and leverages high-performance libraries for statistical analysis, natural language processing, and semantic similarity, enabling advanced features like entropy-based anomaly detection, NLI-based text analysis, and intelligent case management.
Key Features
- 📊 Advanced Statistical Analysis: Entropy-based anomaly detection and time series analysis.
- 🧠 Enhanced Case-Based Reasoning: Semantic similarity matching with NLI-based text analysis.
- 🎯 Multi-Strategy Detection: Statistical, pattern-based, and hybrid loop detection.
- 📈 Time Series Analysis: Trend detection and cyclical pattern recognition.
- 🔧 Configurable Detection: Domain-specific thresholds and progress indicators.
- 🎨 Intelligent Case Management: Quality scoring, deduplication, and usage-based optimization.
- 🚀 High-Performance Libraries: Built with
simple-statistics,natural,compromise, and HuggingFace Transformers.
Tech Stack
- Language: TypeScript
- Framework: Node.js
- Server: FastMCP for SSE transport
- NLP and Machine Learning:
@huggingface/transformers: For NLI-based semantic analysisnatural: For sentiment analysis and tokenizationcompromise: For natural language processing
- Statistics:
simple-statistics: For statistical calculationsml-matrix: For matrix operations
- Development Tools:
jest: For testingeslint: For lintingprettier: For code formattingzod: For schema validation
Installation
To get the project running locally, follow these steps:
-
Clone the repository:
git clone https://github.com/cyqlelabs/mcp-dual-cycle-reasoner.git cd mcp-dual-cycle-reasoner -
Install dependencies:
npm install -
Build the project:
npm run build
Usage
Running the Server
You can run the server in two modes:
-
HTTP Stream (Default):
npm startThe server will start on port 8080.
-
Stdio:
npm start -- --stdio
Using with Claude Desktop
Add the following to your Claude Desktop MCP configuration:
{
"mcpServers": {
"dual-cycle-reasoner": {
"command": "npx",
"args": ["@cyqlelabs/mcp-dual-cycle-reasoner"]
}
}
}
For stdio transport, add the --stdio flag to the args array.
Available Tools
Core Monitoring Tools
start_monitoring
Initialize metacognitive monitoring of an agent's cognitive process.
Input Schema:
{
goal: string; // Current goal being pursued
initial_beliefs?: string[]; // Initial beliefs about the task
}
process_trace_update
Main monitoring function—processes cognitive trace updates from the agent.
Input Schema:
{
last_action: string; // Latest action name
current_context?: string; // Current environment context
goal: string; // Current goal being pursued
window_size?: number; // Monitoring window size (default: 10)
}
Return Payload:
Returns a JSON object indicating if intervention is required and details about any detected loop.
{
"intervention_required": true,
"loop_detected": {
"detected": true,
"type": "action_repetition",
"confidence": 0.85,
"details": "Loop detected via parameter_repetition: 57% anomaly score...",
"actions_involved": ["click_submit_button"]
}
}
stop_monitoring
Stop metacognitive monitoring and get a session summary.
Input Schema: {}
Loop Detection Tools
detect_loop
Detect if the agent is stuck in a loop using various strategies.
Input Schema:
{
current_context?: string; // Current environment context
goal: string; // Current goal being pursued
detection_method?: "statistical" | "pattern" | "hybrid"; // Detection method (default: "hybrid")
}
Return Payload:
Returns a LoopDetectionResult object as a JSON string.
{
"detected": true,
"type": "action_repetition",
"confidence": 0.85,
"details": {
"dominant_method": "parameter_repetition",
"anomaly_score": 0.57,
"actions_involved_count": 1,
"recent_actions_count": 10,
"metrics": {
"semantic_repetition": 0.6,
"parameter_repetition": 0.8
}
},
"actions_involved": ["click_submit_button"]
}
configure_detection
Configure loop detection parameters and domain-specific progress indicators.
Input Schema:
{
progress_indicators?: string[]; // default: []
min_actions_for_detection?: number; // default: 5
alternating_threshold?: number; // default: 0.5
repetition_threshold?: number; // default: 0.4
progress_threshold_adjustment?: number; // default: 0.2
semantic_intents?: string[]; // default: []
}
Enhanced Experience Management
store_experience
Store a case for future case-based reasoning with enhanced metadata and quality scoring.
Input Schema:
{
problem_description: string;
solution: string;
outcome: boolean;
context?: string;
difficulty_level?: "low" | "medium" | "high";
}
retrieve_similar_cases
Retrieve similar cases using advanced semantic matching and filtering.
Input Schema:
{
problem_description: string;
max_results?: number; // default: 5
context_filter?: string;
difficulty_filter?: "low" | "medium" | "high";
outcome_filter?: boolean;
min_similarity?: number; // default: 0.1
}
Return Payload:
Returns an array of Case objects as a JSON string.
[
{
"id": "case-123",
"problem_description": "Form submission button not responding to clicks",
"solution": "Ensure all required fields are filled correctly.",
"outcome": true,
"context": "registration_form",
"difficulty_level": "medium",
"similarity_metrics": {
"combined_similarity": 0.92
}
}
]
System Tools
get_monitoring_status
Get the current monitoring status and statistics.
Input Schema: {}
Return Payload:
Returns a JSON string with the current monitoring status, including is_monitoring, current_goal, trace_length, and intervention_count.
{
"is_monitoring": true,
"current_goal": "Complete user registration process on website",
"trace_length": 15,
"intervention_count": 2,
"recent_actions": [
{ "type": "click_submit_button", "timestamp": 1678886400000 },
{ "type": "click_submit_button", "timestamp": 1678886401000 }
]
}
reset_engine
Reset the dual-cycle engine state.
Input Schema: {}
Example Usage Scenario
Example Usage Scenario
Here's a complete example showing how to use the dual-cycle reasoner to monitor an autonomous agent and build up experience over time:
1. Initial Setup and Configuration
// Configure detection parameters for your domain
await configure_detection({
progress_indicators: ['page_loaded', 'form_submitted', 'data_extracted'],
min_actions_for_detection: 3,
alternating_threshold: 0.6,
repetition_threshold: 0.3,
semantic_intents: [
'navigating to page',
'clicking element',
'filling form field',
'submitting form',
'validating input',
'handling popup',
'extracting data',
'waiting for response',
],
});
// Start monitoring the agent's goal
await start_monitoring({
goal: 'Complete user registration process on website',
});
2. Monitoring Agent Actions
// Monitor each action the agent takes
await process_trace_update({
last_action: 'click_signup_button',
current_context: 'homepage',
goal: 'Complete user registration process on website',
});
// ... agent continues actions ...
// Agent gets stuck clicking submit repeatedly
await process_trace_update({
last_action: 'click_submit_button',
current_context: 'registration_form',
goal: 'Complete user registration process on website',
});
// Returns: {
// "intervention_required": true,
// "loop_detected": {
// "detected": true,
// "type": "action_repetition",
// "confidence": 0.85,
// "details": {
// "dominant_method": "parameter_repetition",
// "anomaly_score": 0.57,
// "actions_involved_count": 1,
// "re
---
*README truncated. [View full README on GitHub](https://github.com/cyqlelabs/mcp-dual-cycle-reasoner).*
Alternatives
Related Skills
Browse all skillsUI design system toolkit for Senior UI Designer including design token generation, component documentation, responsive design calculations, and developer handoff tools. Use for creating design systems, maintaining visual consistency, and facilitating design-dev collaboration.
Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".
Master API documentation with OpenAPI 3.1, AI-powered tools, and modern developer experience practices. Create interactive docs, generate SDKs, and build comprehensive developer portals. Use PROACTIVELY for API documentation or developer portal creation.
Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.
Guide for building TypeScript CLIs with Bun. Use when creating command-line tools, adding subcommands to existing CLIs, or building developer tooling. Covers argument parsing, subcommand patterns, output formatting, and distribution.
Integrate Vercel AI SDK applications with You.com tools (web search, AI agent, content extraction). Use when developer mentions AI SDK, Vercel AI SDK, generateText, streamText, or You.com integration with AI SDK.