Skip to content

Commit 5430a63

Browse files
FradSerclaude
andcommitted
feat(agent): add metacognitive thinking agent
- add metacognitive to thinkingdirection enum - create metacognitivethinkingcapability with bias detection focus - add timing config (90s) and message history config (5) - update full_exploration_sequence to include metacognitive - update test to reflect new thinking sequence Metacognitive agent analyzes thinking process itself, identifies cognitive biases, evaluates mental models, and suggests alternative framing - complementing the existing synthesis agent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fdd820c commit 5430a63

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

src/mcp_server_mas_sequential_thinking/processors/multi_thinking_core.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class ThinkingDirection(Enum):
5151
OPTIMISTIC = "optimistic" # Optimism and value
5252
CREATIVE = "creative" # Creativity and innovation
5353
SYNTHESIS = "synthesis" # Metacognition and integration
54+
METACOGNITIVE = "metacognitive" # Thinking about thinking
5455

5556

5657
class ProcessingDepth(Enum):
@@ -95,6 +96,9 @@ class ThinkingTimingConfig:
9596
ThinkingDirection.SYNTHESIS: ThinkingTimingConfig(
9697
ThinkingDirection.SYNTHESIS, 60, 30, 120, False
9798
),
99+
ThinkingDirection.METACOGNITIVE: ThinkingTimingConfig(
100+
ThinkingDirection.METACOGNITIVE, 90, 45, 180, False
101+
),
98102
}
99103

100104

@@ -471,6 +475,78 @@ def _get_specific_instructions(self) -> list[str]:
471475
return instructions
472476

473477

478+
class MetaCognitiveThinkingCapability(ThinkingCapability):
479+
"""Meta-Cognitive thinking capability: thinking about thinking."""
480+
481+
def __init__(self) -> None:
482+
super().__init__(
483+
thinking_direction=ThinkingDirection.METACOGNITIVE,
484+
role="Cognitive Process Analyst",
485+
description="Analyze thinking process, identify cognitive biases, evaluate mental models",
486+
role_description="I analyze HOW we think about the problem, not WHAT we think. I examine cognitive biases, evaluate our reasoning approach, and identify how our mental models shape our conclusions.",
487+
thinking_mode="metacognitive_analysis",
488+
cognitive_focus="Process awareness, bias detection, mental model evaluation",
489+
output_style="Self-aware analysis, bias identification, reasoning evaluation",
490+
timing_config=THINKING_TIMING_CONFIGS[ThinkingDirection.METACOGNITIVE],
491+
reasoning_level=3,
492+
memory_enabled=True,
493+
)
494+
495+
def _get_specific_instructions(self) -> list[str]:
496+
instructions = [
497+
"",
498+
"METACOGNITIVE ANALYSIS GUIDELINES:",
499+
"• Analyze the thinking process itself, not just the content",
500+
"• Identify cognitive biases that may be influencing reasoning",
501+
"• Evaluate whether the approach being taken is appropriate",
502+
"• Question assumptions about how we frame the problem",
503+
"• Consider alternative framing that might yield different insights",
504+
"",
505+
"BIAS DETECTION FOCUS AREAS:",
506+
"• Confirmation bias: Are we only seeing evidence that supports existing views?",
507+
"• Anchoring bias: Are we overly influenced by initial information?",
508+
"• Availability bias: Are we relying on easily recalled examples?",
509+
"• Sunk cost fallacy: Are we continuing down a path because of past investment?",
510+
"• Dunning-Kruger effect: Are we overestimating our understanding?",
511+
"",
512+
"PROCESS EVALUATION:",
513+
"- Is the current thinking strategy appropriate for this problem?",
514+
"- What mental models are we using, and are they fitting the problem?",
515+
"- How might someone with different expertise approach this differently?",
516+
"- What information gaps exist in our reasoning approach?",
517+
]
518+
519+
# Add research capabilities if ExaTools is available
520+
if EXA_AVAILABLE and ExaTools is not None:
521+
instructions.extend(
522+
[
523+
"",
524+
"RESEARCH CAPABILITIES:",
525+
"• Use search_exa() to research cognitive biases and thinking fallacies",
526+
"• Search for academic insights on meta-cognition and reasoning",
527+
"• Find examples of how similar problems were reframed successfully",
528+
]
529+
)
530+
531+
instructions.extend(
532+
[
533+
"",
534+
"FORBIDDEN in metacognitive analysis:",
535+
"- Making the final decision (that's Synthesis's job)",
536+
"- Providing the actual answer to the question",
537+
"- Focusing only on content rather than process",
538+
"",
539+
"YOUR OUTPUT SHOULD:",
540+
"• Describe the thinking process being used",
541+
"• Identify potential biases and limitations",
542+
"• Suggest alternative framing if beneficial",
543+
"• Evaluate if the current approach is optimal",
544+
]
545+
)
546+
547+
return instructions
548+
549+
474550
class SynthesisThinkingCapability(ThinkingCapability):
475551
"""Synthesis thinking capability: metacognition and integration."""
476552

@@ -531,6 +607,7 @@ class MultiThinkingAgentFactory:
531607
ThinkingDirection.OPTIMISTIC: OptimisticThinkingCapability(),
532608
ThinkingDirection.CREATIVE: CreativeThinkingCapability(),
533609
ThinkingDirection.SYNTHESIS: SynthesisThinkingCapability(),
610+
ThinkingDirection.METACOGNITIVE: MetaCognitiveThinkingCapability(),
534611
}
535612
_default_learning_resources: ClassVar[LearningResources | None] = None
536613

src/mcp_server_mas_sequential_thinking/processors/multi_thinking_processor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
ThinkingDirection.OPTIMISTIC: 3, # Focused opportunity analysis
4848
ThinkingDirection.CREATIVE: 8, # Broader context for creative connections
4949
ThinkingDirection.SYNTHESIS: 10, # Maximum context for comprehensive integration
50+
ThinkingDirection.METACOGNITIVE: 5, # Process analysis needs moderate context
5051
}
5152

5253

@@ -309,7 +310,7 @@ async def _process_full_direction_sequence(
309310
non_synthesis_agents = [
310311
direction
311312
for direction in thinking_sequence
312-
if direction != ThinkingDirection.SYNTHESIS
313+
if direction not in (ThinkingDirection.SYNTHESIS, ThinkingDirection.METACOGNITIVE)
313314
]
314315

315316
if non_synthesis_agents:

src/mcp_server_mas_sequential_thinking/routing/multi_thinking_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ThinkingDirection.OPTIMISTIC,
3030
ThinkingDirection.CRITICAL,
3131
ThinkingDirection.CREATIVE,
32+
ThinkingDirection.METACOGNITIVE,
3233
ThinkingDirection.SYNTHESIS,
3334
)
3435

tests/unit/test_multi_thinking_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def test_route_thought_defaults_to_full_exploration(
5656
"optimistic",
5757
"critical",
5858
"creative",
59+
"metacognitive",
5960
"synthesis",
6061
]
6162

0 commit comments

Comments
 (0)