Skip to content

feat: Agent God Class Decomposition (Unified Epic) #1254

@MervinPraison

Description

@MervinPraison

Objective

Decompose the monolithic Agent god class (praisonaiagents/agent/agent.py - currently ~8,915 lines) into a modular, maintainable mixin framework while maintaining 100% backward API compatibility.

This issue unifies the efforts from previously conflicting/duplicate PRs (#1240, #1243, and #1244). A single agent workflow should pick this up and orchestrate the full decomposition into a single, clean pull request.

Requirements

1. Mixin Framework Architecture

Extract the core functionalities of the Agent class into independent mixin classes:

  • ChatMixin (agent/chat_mixin.py): Chat/LLM methods including synchronous/async chat, streaming, and tool calls.
  • ExecutionMixin (agent/execution_mixin.py): Runtime execution methods including run, arun, start, astart, and autonomous loop execution.
  • MemoryMixin (agent/memory_mixin.py): Memory, cache, chat history, and state management operations.
  • ToolExecutionMixin / SessionManagerMixin / ChatHandlerMixin: Modular handler segregation.

2. Backward Compatibility

  • Zero Breaking Changes: All existing public methods and properties must remain accessible natively on the Agent object.
  • All 34 __init__ parameters must be preserved in the base Agent class constructor.
  • User instantiation pattern must remain unchanged: Agent(name="...", instructions="...").

3. Performance & Guideline Compliance

  • Import Time: Maintain an SDK import time strictly under 200ms (target ~15ms achieved in tests).
  • AGENTS.md Protocol: Comply directly with protocol-driven architecture principles. Use lazy imports wherever heavy dependencies are required.
  • Class definition should cleanly merge the layers:
    class Agent(ToolExecutionMixin, ChatHandlerMixin, SessionManagerMixin, ChatMixin, ExecutionMixin, MemoryMixin):
        # ... core glue logic

Action Items for Agents (Claude/Copilot/Qodo)

Please implement these changes cleanly by moving the actual method bodies over to the mixins, run standard test validations, and push a single unified PR resolving this issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions