AI agent should prefer fan-out model methods over shell loops for fleet operations
Opened by swampadmin · 3/11/2026
Problem Statement
When an AI agent (e.g. Claude Code) is asked to run a command across a fleet of VMs, it defaults to generating a shell loop that spawns N separate swamp model method run ... exec CLI invocations — one per VM. This causes:
- Datastore lock contention — each CLI invocation acquires the datastore lock, so parallel runs timeout waiting on the lock (e.g. 45 out of 50 calls fail with
Lock ... timed out after 60180ms) - Redundant discovery — each
execcall independently runsdiscoverVms(), making N identical kubectl calls - Poor UX — the user has to wait for lock timeouts and retry, or manually discover that
execAllexists
This happened in practice: the user asked to "check all jenkins workers in prod" and the agent tried to run 50 parallel swamp model method run prod-vms exec CLI invocations instead of a single swamp model method run prod-vms execAll --input '{"filter":"jenkins-worker", ...}'.
Proposed Solution
Improve discoverability of fan-out methods so AI agents (and users) find them before resorting to shell loops:
- Model type metadata: Add a
fleetAware: trueflag orfanOutMethodsfield to model type descriptions, soswamp model type describemakes it obvious which methods handle multiple targets internally. - CLI hint: When
execis called with a filter that matches multiple VMs but only executes on one, emit a hint:"Hint: Use 'execAll' to run across all matching VMs". - Skill/documentation: Update the
swamp-modelskill to mention that fleet-aware models (like@bixu/kubevirt-vm) haveexecAll,checkService, andhealthCheckmethods that fan out internally with built-in concurrency control.
Alternatives Considered
- Smarter locking: Allow concurrent reads or use per-model locks instead of a global datastore lock. This would help but doesn't address the redundant discovery or UX issues.
- Agent-side heuristic: Teach the AI agent to always check for
*Allor fleet methods before looping. This is fragile and puts the burden on every agent integration.
Summary
Changes would be needed in:
- Model type schema to support fleet-awareness metadata
- CLI output to emit hints when a single-target method is used on a multi-target filter
- Skill documentation (
swamp-model) to document fleet patterns
The approach is to make fan-out methods discoverable at the type description level so both humans and AI agents naturally find the right method for fleet operations.
Open
No activity in this phase yet.
Sign in to post a ripple.