From 5c643cd54ef532beb4c10a16908ed6e8fcc33d15 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sun, 21 Jun 2026 20:41:42 -0500 Subject: [PATCH] fix(fleet): bake MOSAIC_AGENT_NAME into the agent pane so native HB fires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live-validation (Lead, w-jarvis) found the native heartbeat was INERT in production: the Pi extension gates on MOSAIC_AGENT_NAME, but tmux panes inherit the tmux SERVER environment (not this script's env, nor the systemd unit's), so the name was empty in-pane for BOTH ad-hoc and systemd agents. Result: no native .hb, no model self-report — only the sidecar fallback ran. Fix: %q-quote the agent name and export it into the pane command alongside PATH, so the extension sees it -> nativeHbEnabled() -> writes .hb with model + busy/ok turn state. Re-validated live via the launcher (isolated socket, real pi on glm-5.2): - pane env now carries MOSAIC_AGENT_NAME - .hb written with status=ok + model=glm-5.2 + .hb.native marker - status flips ok -> busy on a real turn -> ok on turn end - sidecar defers to the fresh native marker Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01EsgTQzV5YUGk1JtCLP4B83 --- .../framework/tools/fleet/start-agent-session.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/mosaic/framework/tools/fleet/start-agent-session.sh b/packages/mosaic/framework/tools/fleet/start-agent-session.sh index 1d70409..7aacb67 100755 --- a/packages/mosaic/framework/tools/fleet/start-agent-session.sh +++ b/packages/mosaic/framework/tools/fleet/start-agent-session.sh @@ -90,11 +90,18 @@ MOSAIC_RUNTIME_BIN_PREFIX=$(_build_runtime_bin_prefix) # # We build the snippet as a double-quoted here-string embedded in a printf call # to avoid nested quoting problems. +# +# MOSAIC_AGENT_NAME must also be exported INTO the pane: panes inherit the tmux +# server environment (not this script's, and not the systemd unit's), so the +# name would otherwise be empty in-pane and the runtime's native heartbeat +# (which gates on MOSAIC_AGENT_NAME) would never fire. %q-quote it so it is a +# safe single bash token regardless of the name's characters. +AGENT_NAME_Q=$(printf '%q' "$AGENT_NAME") if [ -n "$MOSAIC_RUNTIME_BIN_PREFIX" ]; then - PANE_SHELL_SNIPPET="export PATH=\"${MOSAIC_RUNTIME_BIN_PREFIX}:\${PATH}\"; exec ${MOSAIC_AGENT_COMMAND}" + PANE_SHELL_SNIPPET="export MOSAIC_AGENT_NAME=${AGENT_NAME_Q}; export PATH=\"${MOSAIC_RUNTIME_BIN_PREFIX}:\${PATH}\"; exec ${MOSAIC_AGENT_COMMAND}" else - PANE_SHELL_SNIPPET="exec ${MOSAIC_AGENT_COMMAND}" + PANE_SHELL_SNIPPET="export MOSAIC_AGENT_NAME=${AGENT_NAME_Q}; exec ${MOSAIC_AGENT_COMMAND}" fi mkdir -p "$MOSAIC_AGENT_WORKDIR"