Skip to content

Top-level agentic-flow import runs CLI/agents and starts servers as side effects (main entrypoint is not library-safe) #110

@thesoulpole

Description

@thesoulpole

Summary: In agentic-flow 2.0.6, importing the top-level package (import 'agentic-flow') immediately executes CLI/agent runtime logic: it loads dotenv, initializes agents, parses CLI args, starts a health server, and runs agent tasks with hardcoded defaults. The main entrypoint behaves like an executable, not a library module.

Observed behavior:
On a clean install of [email protected], running a simple dynamic import:

import(‘agentic-flow’)

causes the process to:
• apply agentdb runtime patch
• load dotenv/config
• import and initialize multiple agents (webResearchAgent, codeReviewAgent, dataAgent, claudeAgent)
• start a health server
• parse CLI arguments
• and then execute runParallelMode() with default values (“migrate payments service”, etc.), printing sections like:

=== RESEARCH ===
=== CODE REVIEW ===
=== DATA ===

The process does not exit promptly and behaves like a long-running agent/CLI process.

Root cause (from dist/index.js):
The published main entrypoint contains top-level side effects and a main() flow that runs unless explicitly exited. It is structured as a CLI runner, but is also exported as the package “.” entrypoint.

Impact:
• import 'agentic-flow' cannot be safely used in any library/application context.
• Simply importing the package starts background services and agent execution.
• This makes the top-level export unusable as a normal npm library entry.

Expected behavior:
The main package entrypoint should be side-effect free and only define exports. CLI behavior (argument parsing, agent execution, health server, demos) should live in a separate executable entry (bin script) or behind an explicit function call.

Suggested fixes:
• Split the CLI/runner into a dedicated entry (e.g. bin or cli entry).
• Ensure dist/index.js only exports APIs and does not auto-run anything.
• Guard execution with a “run only when invoked as CLI” check instead of running on import.

Version tested:
agentic-flow 2.0.6 (npm)

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