Skip to content

runWorkglowCli discards models and providers its own registerTasks hook registered #856

Description

@sroussey

examples/cli/src/bootstrap.ts:85 awaits options.registerTasks?.() and then, at :99-101 and :110-115, replaces the global model repository and the HFT provider outright. setGlobalModelRepository is registry.registerInstance(MODEL_REPOSITORY, …) (packages/ai/src/model/ModelRegistry.ts:40), and AiProvider.register() (packages/ai/src/provider/AiProvider.ts:205-214) unregisters and terminates any prior worker before re-registering. So a downstream that registers models or a provider in the hook loses them, silently.

Reproduced on @workglow/sec's sec-base: bun src/libs-cli.ts model listNo models found., while probing bootstrapSecRuntime() directly gives size: 3 including claude-sonnet-5. Every AI task in sec-base therefore resolves no model.

The HFT half is worse because it is order-dependent rather than absolute. sec registers a worker that applies patchHftChatTemplateGenerationTags (transformers.js 4.2.0 bundles jinja 0.5.6, which throws Unknown statement type: generation). sec-base registers it in the hook and libs overwrites it; embarc-data-base registers it in a preAction hook and it survives. Verified by dumping WorkerManager.workerFactories before and after. Two binaries, opposite results, decided purely by hook ordering.

Fix: hoist both registrations above the hook, or give them registerIfAbsent semantics. Add a test that runs runWorkglowCli with a hook registering one model and one worker-backed provider and asserts both are still present after boot — there is currently no test that exercises the hook at all.

Found during the 2026-08-24 review. Snapshot: workglow-dev/prdanalysis/grades/2026-08-24/cross-repo-integration.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions