Skip to content

feat: Add ReasoningAgent and DualBrainAgent specialized agent classes #1216

@MervinPraison

Description

@MervinPraison

Summary

Add two new specialized agent classes: ReasoningAgent (chain-of-thought reasoning with self-verification) and DualBrainAgent (fast System-1 + deliberate System-2 thinking). These are additive — no existing code should be modified except agent/__init__.py exports.

🚨 ARCHITECTURE VIOLATION - CLOSING ISSUE

After reviewing AGENTS.md, this feature request violates core architecture principles:

Violations Found:

  1. Protocol-driven Core Violation (§ 4.1): Heavy implementations belong in wrapper (praisonai), not core SDK (praisonaiagents)
  2. DRY Violation (§ 4.3): Base Agent already supports reasoning via reflection=True, model switching via llm parameter
  3. Missing Protocol-First Design (§ 3.2): Should be protocols with wrapper implementations

Correct Approach:

# Move to wrapper: praisonai/agents/reasoning.py
from praisonaiagents import Agent

class ReasoningAgent(Agent):
    # Implementation here
# Core SDK protocols only: praisonaiagents/protocols.py
class ReasoningProtocol(Protocol):
    def apply_reasoning(self, prompt: str, depth: str) -> str: ...

The existing 14 specialized agents mentioned should also be moved to wrapper to fix architecture.


Original Requirements (for reference)

1. agent/reasoning_agent.py — ReasoningAgent

class ReasoningAgent(Agent):
    """Agent that uses chain-of-thought reasoning with self-verification."""

Features:

  • Automatic chain-of-thought prompting in system instructions
  • Step-by-step reasoning breakdown
  • Self-verification loop: agent checks its own reasoning before final answer
  • Configurable reasoning depth (shallow/medium/deep)
  • Works with any LLM (not dependent on model-specific features)

2. agent/dual_brain_agent.py — DualBrainAgent

class DualBrainAgent(Agent):
    """Agent with fast (System-1) and deliberate (System-2) thinking modes."""

Features:

  • System-1 (fast): quick responses for simple queries using lightweight model
  • System-2 (deliberate): deep reasoning for complex queries using powerful model
  • Automatic complexity detection to route between modes
  • Configurable model for each mode
  • Falls back gracefully if only one model available

Architecture Rules

  1. Both MUST inherit from Agent class (import from agent.agent)
  2. Use from praisonaiagents._logging import get_logger for logging
  3. Add to agent/__init__.py lazy __getattr__ loader (follow existing pattern for ImageAgent etc.)
  4. NO module-level heavy imports
  5. Both must support sync and async: run()/arun(), start()/astart()
  6. Add exports to top-level praisonaiagents/__init__.py lazy loader

Verification

# All existing tests must pass
pytest tests/unit/ -q --timeout=30

# Smoke test
python -c "
from praisonaiagents import ReasoningAgent, DualBrainAgent
r = ReasoningAgent(name='reasoner', instructions='Think step by step')
d = DualBrainAgent(name='dual', instructions='Analyze carefully')
print('ReasoningAgent:', r.name)
print('DualBrainAgent:', d.name)
"

# Real agentic test
python -c "
from praisonaiagents import ReasoningAgent
agent = ReasoningAgent(name='reasoner', instructions='Think step by step')
result = agent.start('What is 17 * 23? Show your reasoning.')
print(result)
"

Success Criteria

  • 2 new agent files created
  • Both inherit from Agent
  • Lazy-loaded in init.py
  • All existing 4473+ unit tests pass
  • Smoke test imports work
  • Real agentic test produces reasoned LLM output
  • Import time stays <200ms

Replaces stale PR #977.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeAuto-trigger Claude analysisenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions