-
Notifications
You must be signed in to change notification settings - Fork 96
Description
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)