Skip to content

gut(agents): remove src/agents/model-selection.ts — CLI runtimes own model selection per MBP #2455

@alexey-pelykh

Description

@alexey-pelykh

Summary

src/agents/model-selection.ts (170 LOC) has live H9-attested functions but should be gutted per the Middleware Boundary Principle: model selection is owned by CLI runtimes (Claude, Gemini, Codex, OpenCode), not by RemoteClaw middleware.

Evidence

  • File header: // Gutted in RemoteClaw fork (Middleware Boundary Principle) — gutting intent declared
  • File body: Full implementations of resolveConfiguredModelRef, resolveDefaultModelForAgent, buildModelAliasIndex, resolveModelRefFromString (functional, not stubs)
  • H9 attestations: MODULE_ATTESTATIONS declares these as "live" — matching reality
  • Zombie-import gate (post-H3): flags 13 callsites across src/auto-reply/, src/commands/, src/config/, src/cron/, src/gateway/, src/telegram/

Live callsites (13 tracked in #2355 allowlist)

src/auto-reply/reply/agent-runner.ts:5
src/auto-reply/reply/directive-handling.model-picker.ts:1
src/auto-reply/reply/directive-handling.ts:9
src/commands/agent.test.ts:6
src/commands/agent/session-store.ts:4
src/commands/status.summary.ts:3
src/config/defaults.ts:2
src/cron/isolated-agent/run.test-harness.ts:71
src/gateway/gateway-cli-backend.live.test.ts:7
src/gateway/server-methods/chat.ts:4
src/gateway/session-utils.ts:16
src/telegram/sticker-cache.ts:4
src/plugin-sdk/mattermost.ts (verify)

Gutting plan

  1. For each caller: migrate to CLI-runtime model resolution OR eliminate the model reference entirely
  2. Once all 13 callers are migrated: delete src/agents/model-selection.ts (and re-export file src/agents/provider-utils.ts if appropriate)
  3. Remove "agents/model-selection" from fallbackDeadModulePatterns in scripts/check-no-zombie-imports.mjs
  4. Remove 13 entries from scripts/data/zombie-import-allowlist.json
  5. Decrement .zombie-import-allowlist-baseline by 13

Context

Discovered during #2355 (H3 gate restoration). The broad agents/model-selection gate pattern was KEPT despite the file having live code, precisely because the functions are tracked-for-gutting — the allowlist is the explicit reminder to gut this file.

Acceptance criteria

  • All 13 callers migrated to CLI-runtime model resolution or eliminated
  • src/agents/model-selection.ts deleted
  • Zombie-import gate passes with allowlist decremented by 13 and agents/model-selection removed from fallback patterns

References

Metadata

Metadata

Assignees

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