Skip to content

[Bug] AgentDB runtime patch uses incorrect controller path for v2.x compatibility #111

@JLMA-Agentic-Ai

Description

@JLMA-Agentic-Ai

🐛 Bug Report

Problem Description

The AgentDB runtime patch system is attempting to use an incorrect controller path when patching for v2.x compatibility, resulting in a warning message during initialization:

Warning: Failed to patch AgentDB controller - path not found: /workspaces/jlmaworkspace/.claude-flow/node_modules/agentdb/src/controllers/AgentController.js

Root Cause Analysis

File: .claude-flow/lib/agentdb/runtime-patch.js (lines 15-20)
Issue: The patch system constructs the controller path using a hardcoded pattern that doesn't match the actual AgentDB v2.0.0-alpha.3.4 file structure.

Current problematic code:

const controllerPath = path.join(nodeModulesPath, 'agentdb', 'src', 'controllers', 'AgentController.js');

Actual AgentDB v2.x structure:

  • Controllers are located in /lib/controllers/ (not /src/controllers/)
  • Main controller is BaseController.js (not AgentController.js)

Environment Details

  • AgentDB Version: v2.0.0-alpha.3.4
  • Agentic-Flow Version: v2.0.6
  • Node.js: Latest LTS
  • Platform: Linux (Codespaces/Dev Container)
  • Installation: npm/npx based

Reproduction Steps

  1. Install agentic-flow v2.0.6 in a project
  2. Initialize claude-flow with AgentDB integration:
    npx @claude-flow/cli@latest init --wizard
  3. Start the daemon:
    npx @claude-flow/cli@latest daemon start
  4. Observe the warning message in console output

Expected vs Actual Behavior

Expected:

  • Silent patching of AgentDB controllers for v2.x compatibility
  • No warning messages during normal operation
  • Successful runtime patching when needed

Actual:

  • Warning message appears: "Failed to patch AgentDB controller - path not found"
  • Patch attempt fails due to incorrect path resolution
  • System continues to function (graceful degradation)

Proposed Solution

Update the path resolution logic in runtime-patch.js to correctly identify AgentDB v2.x structure:

// Current problematic code
const controllerPath = path.join(nodeModulesPath, 'agentdb', 'src', 'controllers', 'AgentController.js');

// Proposed fix - detect AgentDB version and use appropriate path
const detectAgentDBStructure = (nodeModulesPath) => {
  const v2Path = path.join(nodeModulesPath, 'agentdb', 'lib', 'controllers', 'BaseController.js');
  const v1Path = path.join(nodeModulesPath, 'agentdb', 'src', 'controllers', 'AgentController.js');
  
  if (fs.existsSync(v2Path)) {
    return { path: v2Path, version: 'v2.x' };
  } else if (fs.existsSync(v1Path)) {
    return { path: v1Path, version: 'v1.x' };
  }
  return null;
};

Impact Assessment

Severity: Low (Warning Only)

  • ⚠️ No functional breakage - system continues to operate normally
  • ⚠️ Cosmetic issue - warning message may confuse users
  • ⚠️ Runtime patches for AgentDB compatibility are not applied
  • ✅ All core functionality remains intact

Technical Analysis

Files Investigated:

  • .claude-flow/lib/agentdb/runtime-patch.js - Contains the problematic path logic
  • .claude-flow/node_modules/agentdb/ - Confirmed v2.x file structure
  • Package manifests - Verified version compatibility matrix

Evidence:

  1. AgentDB v2.0.0-alpha.3.4 uses /lib/controllers/BaseController.js
  2. Runtime patch expects /src/controllers/AgentController.js
  3. Version detection logic is missing for different AgentDB releases
  4. Graceful fallback prevents system failure

Additional Context

This bug likely emerged during the transition from AgentDB v1.x to v2.x where the internal file structure was reorganized. The runtime patch system needs to be updated to handle both legacy and current AgentDB versions.

Related Components:

  • AgentDB integration layer
  • Runtime patching system
  • Version compatibility matrix
  • Developer experience (warning messages)

Acceptance Criteria

  • No warning messages during normal agentic-flow initialization
  • Runtime patches apply correctly for both AgentDB v1.x and v2.x
  • Version detection automatically selects appropriate controller path
  • Backward compatibility maintained for existing installations
  • Clear error handling if neither path structure is found

Environment: Development Container (Linux)
Priority: Medium (UX improvement)
Labels: bug, agentdb, compatibility, v2.x, runtime-patch

🤖 Generated with Claude Code - Issue Tracker

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions