Skip to content

Core SDK: remove dead/unreferenced code (superseded mixin, empty stubs, dead imports) #1952

@MervinPraison

Description

@MervinPraison

Summary

Several files and symbols in praisonaiagents are genuinely unreferenced — a superseded mixin, empty placeholder modules, and dead imports/variables. Removing them is a pure clean-up: no runtime behaviour changes and no public API is touched. This reduces navigation confusion (e.g. a maintainer chasing a "draft" __init__new.py or an orphaned mixin to understand intent).

Current behaviour

All of the following were verified unreferenced across the core package and tests/:

  1. praisonaiagents/agent/unified_chat_mixin.py — 151-line UnifiedChatMixin class. It was superseded in place by _execute_unified_chat_completion / _execute_unified_achat_completion in agent/chat_mixin.py (around lines 1353–1543), which is what Agent actually uses. The only references to UnifiedChatMixin are its own definition plus two docstring mentions in chat_mixin.py:1370 and chat_mixin.py:1494. It is not in agent/__init__.py.__all__, not imported by agent.py, and not referenced by any test.
  2. Four empty (0-byte) placeholder modules: praisonaiagents/__init__new.py, praisonaiagents/llm/__init__new.py, praisonaiagents/planning/__init__new.py, praisonaiagents/ui/__init__new.py. No code anywhere references the string __init__new.
  3. Dead import in praisonaiagents/memory/workflows.py:30StepResult is imported from ..workflows.results but immediately shadowed by a local @dataclass class StepResult at line 43 (an intentionally different, incompatible schema used throughout the file). The imported StepResult is never used; the other names on that import line (StepError, WorkflowResult, StepStatus, ErrorStrategy) are used and must stay.
  4. Dead module-level variables in praisonaiagents/tools/__init__.py:7-8_tools_lock = threading.Lock() and _tools_lazy_cache = {} are declared but never read or written. The actual lazy machinery uses importlib.import_module in __getattr__ and a separate _loaded_classes cache. _tools_lock is never acquired.

Why it matters

Maintenance/clarity: ~150+ lines of orphaned code and four empty modules invite "is this a draft replacement?" confusion, and the dead StepResult import / unused lock imply contracts that do not exist. No import-time or hot-path cost beyond a trivial lock+dict allocation per tools import.

Category

Dead code

Capability preserved

  • No user-facing behaviour changes whatsoever. The live execution path (chat_mixin._execute_unified_chat_completion/_achat_completion), the local StepResult dataclass in memory/workflows.py, and the real tools lazy-loader (__getattr__ + _loaded_classes) all remain exactly as-is.

Proposed approach

Remove dead code only:

  • Delete agent/unified_chat_mixin.py (and tidy the two stale docstring mentions in chat_mixin.py).
  • Delete the four empty __init__new.py files.
  • Drop StepResult from the import on memory/workflows.py:30 (keep the local class).
  • Delete tools/__init__.py:7-8 (_tools_lock, _tools_lazy_cache).

Resolution sketch

# memory/workflows.py — before
from ..workflows.results import StepResult, StepError, WorkflowResult, StepStatus, ErrorStrategy
# after (StepResult is shadowed by the local dataclass below)
from ..workflows.results import StepError, WorkflowResult, StepStatus, ErrorStrategy

# tools/__init__.py — before
_tools_lock = threading.Lock()
_tools_lazy_cache = {}
# after: removed (unused; real cache is _loaded_classes in __getattr__)

Severity

Low

Validation

Each item confirmed unreferenced via repo-wide grep across praisonaiagents/ and tests/. unified_chat_mixin.py has no __all__ entry, no import, no test reference. The four __init__new.py files are 0 bytes. StepResult from the import is shadowed before any use. _tools_lock/_tools_lazy_cache have zero read/write sites. No public API or robustness behaviour is involved.

Keep unchanged

  • chat_mixin._execute_unified_chat_completion / _execute_unified_achat_completion (the live path).
  • The local StepResult dataclass in memory/workflows.py and the other imported result types.
  • The tools __getattr__ lazy-loader and _loaded_classes cache.
  • All protocols, adapters, and extension points.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclaudeAuto-trigger Claude analysisdocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions