You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing all 292 ES API schemas (src/es/apis.ts) allocates ~373 MB of heap memory. The CLI currently runs as a short-lived process so this doesn't cause OOM, but it's a significant footprint that will grow as more APIs are added and could become a problem if the CLI is used as a long-running process (daemon, language server, agent loop).
For context, the Kibana workflows team hit OOM at 800-1000 MB when loading ~1000 API schemas through Zod. At 373 MB for 292 APIs, the CLI is already at ~47% of that threshold.
Zod v4 was found to worsen memory consumption in Kibana (kibana#262948).
Agent/LLM workflows may run many CLI invocations in sequence; forking 373 MB per invocation adds up.
Adding more APIs (the ES spec has 400+) will push this higher.
Possible approaches
Lazy loading: Only instantiate schemas for the command being invoked, not all 292 on startup.
Schema splitting: Move each API's schema into a separate chunk that's imported on demand.
Codegen optimization: Investigate whether the schema graph has excessive duplication (shared types like QueryDslQueryContainer may be instantiated multiple times via z.lazy()).
Summary
Importing all 292 ES API schemas (
src/es/apis.ts) allocates ~373 MB of heap memory. The CLI currently runs as a short-lived process so this doesn't cause OOM, but it's a significant footprint that will grow as more APIs are added and could become a problem if the CLI is used as a long-running process (daemon, language server, agent loop).For context, the Kibana workflows team hit OOM at 800-1000 MB when loading ~1000 API schemas through Zod. At 373 MB for 292 APIs, the CLI is already at ~47% of that threshold.
Environment
0.1.0-alpha.1(commit1b91960)Darwin 25.4.0 arm64Repro
Result
Additionally, generating JSON Schema output (
--help --json) for all APIs produces 22 MB total:Why this matters
docs chatcommand (added in feat: add elastic docs commands (search, ask, chat, read) #147) keeps the process alive for interactive sessions — 373 MB baseline for every chat session.Possible approaches
QueryDslQueryContainermay be instantiated multiple times viaz.lazy()).