Skip to content

Remove in-process LLM packages and dead model management #102

@alexey-pelykh

Description

@alexey-pelykh

Summary

Remove the 4 external @mariozechner/pi-* npm packages, all dead model management infrastructure, and cascade-update ~35 callers that use dead in-process model resolution patterns. These packages powered OpenClaw's in-process LLM execution engine, which has been replaced by RemoteClaw's CLI subprocess architecture (Claude, Gemini, Codex, OpenCode runtimes). Model selection, auth, and context windows are now handled by the CLI agents themselves.

Previous PRs (#63#94) deleted the execution engine and most importing files. This PR removes the packages themselves plus ~60 dead files, and cascade-updates ~35 caller files that still reference the dead model management layer. These callers were written for OpenClaw's in-process execution model and use patterns (model resolution, context window lookup, fallback orchestration) that don't exist in RemoteClaw — ChannelBridge (the live execution path) has zero model management imports, confirming the architecture.

Packages to Remove from package.json

"@mariozechner/pi-agent-core": "0.55.0"
"@mariozechner/pi-ai": "0.55.0"
"@mariozechner/pi-coding-agent": "0.55.0"
"@mariozechner/pi-tui": "0.55.0"

Core Files to Delete

Model management (~8 source + ~9 tests in src/agents/)

Source files:

  • model-auth.ts, model-auth-label.ts, model-catalog.ts, model-fallback.ts
  • model-selection.ts, model-alias-lines.ts, context.ts, context-window-guard.ts

Test files:

  • model-auth.test.ts, model-auth.profiles.test.ts, model-catalog.test.ts
  • model-catalog.test-harness.ts, model-fallback.test.ts, model-selection.test.ts
  • context.test.ts, context-window-guard.test.ts

Note: model-compat.ts, model-forward-compat.ts, model-scan.ts, live-model-filter.ts and their tests were already deleted by #94.

Provider catalogs (~11 source + ~14 tests in src/agents/)

Source files:

  • models-config.ts, models-config.providers.ts, bedrock-discovery.ts
  • cloudflare-ai-gateway.ts, huggingface-models.ts, opencode-zen-models.ts
  • pi-model-discovery.ts, synthetic-models.ts, together-models.ts
  • venice-models.ts, minimax-vlm.ts
  • models-config.e2e-harness.ts, models-config.test-utils.ts

Test files:

  • bedrock-discovery.test.ts, huggingface-models.test.ts, opencode-zen-models.test.ts
  • minimax-vlm.normalizes-api-key.test.ts
  • models-config.auto-injects-github-copilot-provider-token-is.test.ts
  • models-config.falls-back-default-baseurl-token-exchange-fails.test.ts
  • models-config.skips-writing-models-json-no-env-token.test.ts
  • models-config.uses-first-github-copilot-profile-env-tokens.test.ts
  • models-config.providers.kilocode.test.ts
  • models-config.providers.kimi-coding.test.ts
  • models-config.providers.nvidia.test.ts
  • models-config.providers.ollama.test.ts
  • models-config.providers.qianfan.test.ts
  • models-config.providers.volcengine-byteplus.test.ts

Note: ollama-stream.ts was already deleted by #94.

Config types

  • src/config/types.models.ts (model config type definitions — all consumers are deleted)

Orphaned execution utilities (~5 source + ~7 tests in src/agents/)

Source files:

  • compaction.ts, failover-error.ts, cache-trace.ts
  • command-poll-backoff.ts, anthropic-payload-log.ts

Test files:

  • compaction.test.ts, compaction.retry.test.ts, compaction.token-sanitize.test.ts
  • compaction.tool-result-details.test.ts, failover-error.test.ts
  • cache-trace.test.ts, command-poll-backoff.test.ts

Old CLI runner chain (displaced by middleware/ runtimes)

  • src/agents/cli-runner.ts, cli-runner.test.ts
  • src/agents/cli-runner/helpers.ts, cli-runner/reliability.ts

Old system prompt chain (displaced by middleware/system-prompt.ts)

Delete:

  • src/agents/system-prompt.ts, system-prompt-params.ts, system-prompt-report.ts
  • Associated test files

Modify (redirect to middleware system prompt):

  • src/auto-reply/reply/commands-system-prompt.ts — use buildSystemPrompt() from middleware
  • src/auto-reply/reply/commands-context-report.ts — update imports

Cascade: Update Callers of Dead Model Management (~35 files)

The deleted model management files have ~35 callers using dead in-process execution patterns. These must be cascade-updated.

Telegram (2 files)

  • bot-message-dispatch.ts, sticker-cache.ts
  • Remove resolveDefaultModelForAgent() vision feature gates
  • CLI agent handles media understanding; gateway doesn't make capability decisions

Auto-reply (5-7 files)

  • agent-runner.ts, agent-runner-execution.ts, commands-system-prompt.ts, get-reply.ts, get-reply-directives.ts, status.ts, memory-flush.ts, directive-handling.persist.ts, commands-registry.ts
  • Remove lookupContextTokens() context budgeting (CLI agent manages its own context)
  • Remove runWithModelFallback() wrapper (CLI agent handles fallback or fails)
  • Remove model alias resolution (CLI agent selects its own model)

Gateway (3-5 files)

  • session-utils.ts, server-startup.ts, server-startup-log.ts, chat.ts, sessions-patch.ts
  • Remove lookupContextTokens(), model ref resolution, resolveThinkingDefault() calls
  • ChannelBridge is already decoupled from model management

Commands (3-5 files)

  • agent.ts, sessions.ts, sessions-table.ts, doctor.ts, status.summary.ts
  • Remove resolveDefaultModelForAgent(), loadModelCatalog(), model resolution
  • CLI agents handle their own model selection

Cron (2 files)

  • isolated-agent/run.ts + test
  • Remove runWithModelFallback(), model catalog lookups, context window accounting

Media understanding (2-3 files)

  • runner.ts, providers/index.ts, providers/image.ts
  • Remove loadModelCatalog()/modelSupportsVision() capability discovery
  • Keep resolveApiKeyForProvider() for vision provider auth (genuine live need, already simplified by feat: gut centralized OAuth and auth profiles #92)

Config/Plugin (1-2 files)

  • plugin-auto-enable.ts — keep normalizeProviderId() (extract before deletion)

Agent infrastructure (3-5 files)

  • cli-session.ts, cli-backends.ts, transcript-policy.ts, live-auth-keys.ts, subagent-spawn.ts, tools/session-status-tool.ts
  • Simplify model selection to config-based runtime lookup

Live Utility Extraction

Before deleting core files, extract functions with genuine live callers:

  1. normalizeProviderId() (from model-selection.ts) → extract to src/agents/provider-utils.ts or inline (trivial: lowercase + trim; used by plugin-auto-enable, auth-profiles)
  2. resolveApiKeyForProvider() (from model-auth.ts) → already simplified by feat: gut centralized OAuth and auth profiles #92; keep in surviving auth infrastructure for media-understanding and onboarding
  3. ModelRef type / parseModelRef() → keep minimal type if needed for config parsing

Surviving pi-* Import Sites

After all deletions and cascade updates, remaining files with @mariozechner/pi-* imports need import removal or replacement with local type stubs. The goal is zero @mariozechner/pi-* imports so the 4 packages can be removed from package.json.

Verification

  • 4 @mariozechner/pi-* packages removed from package.json
  • All dead files listed above are deleted
  • ~35 callers cascade-updated to remove dead model management patterns
  • Live utilities extracted (normalizeProviderId, resolveApiKeyForProvider)
  • Zero from "@mariozechner/pi- imports remain in src/
  • pnpm build passes

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