fix(fleet): export MOSAIC_AGENT_CLASS into the agent pane so personas inject #669
Reference in New Issue
Block a user
Delete Branch "fix/persona-class-pane-export"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The A3a/A3b persona system injects a per-agent persona contract that the launcher composes from
process.env.MOSAIC_AGENT_CLASS(compose-contract→readPersonaContractBlock,launch.js:325).generateAgentEnvalready writesMOSAIC_AGENT_CLASStoagents/<name>.env, butstart-agent-session.shonly re-exportedMOSAIC_AGENT_NAMEinto the pane snippet — never the class.The tmux pane inherits the tmux SERVER environment, not this script's env nor the systemd unit's
EnvironmentFile. So the class written to the.envwas invisible in-pane; the launcher saw an undefined class and silently injected no persona contract. Every fleet agent came up class-less whilefleet psreported healthy. The comms block kept working only because it keys onMOSAIC_AGENT_NAME, which is re-exported.Fix
Re-export
MOSAIC_AGENT_CLASSintoPANE_SHELL_SNIPPETexactly asMOSAIC_AGENT_NAME,%q-quoted. An empty/unset class%q-quotes to''and is a harmless no-op (matchesreadPersonaContractBlock's empty-class contract).Verification
.env+ restart alone left the pane withoutMOSAIC_AGENT_CLASSand without a persona block — proving the.envreaches only the systemd service, not the pane.MOSAIC_AGENT_CLASS=<class>in its pane env and the matching# Persona Contract (<class>)block in its composed prompt (claude: in--append-system-prompt; pi: viacompose-contractreading the same env). Negative control (env -u MOSAIC_AGENT_CLASS compose-contract pi) emits no persona — confirming it is genuinely class-gated.Adds a regression guard to
test-start-agent-session.shasserting the pane snippet exports bothMOSAIC_AGENT_NAMEand the per-agentMOSAIC_AGENT_CLASS.🤖 Generated with Claude Code
Independent review-of-record — mos-claude-1 (two-perspective) — APPROVE
Reviewed PR head
92cbe42againstorigin/mainfrom a fresh extract of both blobs.Diff: 2 files, +26/-2 — matches description, no collateral changes.
start-agent-session.sh:
MOSAIC_AGENT_CLASSis now re-exported intoPANE_SHELL_SNIPPETin BOTH branches (with/without runtime-bin prefix),%q-quoted from${MOSAIC_AGENT_CLASS:-}. Empty/unset class%q-quotes to'', a harmless no-op (readPersonaContractBlockreturns''for an empty class). Mirrors the existingMOSAIC_AGENT_NAMEhandling exactly. Comment correctly explains the pane inherits the tmux SERVER env (not the script env nor the systemd EnvironmentFile), which is why the explicit re-export is required.Regression guard: verified it has TEETH via the suggested negative control:
ok - start-agent-session, EXIT 0FAIL: pane command does not export MOSAIC_AGENT_CLASS into the pane (persona would silently drop), EXIT 1bash -nclean on both files.Verdict: APPROVE. Correctly and minimally closes the A3a pane-propagation gap;
generateAgentEnvalready emits the CLASS line, so post-mergemosaic fleet installconverges cleanly. Recommend squash-merge on CI-green.