Repository navigation
Fix #2083: deliver mail to agents started through a wrapper script (configured harness) - #2087
Merged
Merged
Conversation
… configured harness The mailbox read an agent's app from its running command, then a builder's launch script, and never from shell.architectHarness / builderHarness / siteManagerHarness, so an agent started through a wrapper script had every message held no-profile. The configured harness is now the last tier, read only when the command and the launch script identify no harness, and read at each pass, so mail already held delivers once the setting is added. An agent whose mail will be held is said so once at start: a Tower WARN and a line for afx workspace start / add-architect / setup / spawn and afx manager start. codev doctor reports configured commands it cannot identify. The no-profile owner notice and liveness warning name the setting instead of afx interrupt / a TUI update.
Unit: the precedence (command, launch script, config), each agent kind, the start notice and its single log line, doctor's report, and held mail delivering once the setting is added. E2E in a scratch Tower: an architect whose command is a real wrapper script answers delivered with architectHarness set; without it activation says so, the send holds no-profile, and adding the setting delivers the held mail with no restart. Both fail with the config tier disabled.
…-profile causes Codex review: an agent whose command or launch script names a harness the mailbox has no profile for (opencode) also has all its mail held, and the issue asks for a notice whenever no profile resolves. It now gets one at start and from codev doctor, saying no setting changes it. The owner and liveness notices cannot tell the two causes apart, so they name both and promise the setting only for the wrapper case.
…nv vars Claude review: the Site Manager's sender notice still offered afx manager attach for a no-profile hold; it now names the two causes and shell.siteManagerHarness. codev doctor reads a configured command with its environment variables expanded, as the launch side runs it, so $AGENT naming claude is not reported. heldMailNotice reads the launch script once, and notes that a wrapper whose name contains a harness name reads as that harness.
…the launch script Codex review round 2: a running command naming a harness with no profile (opencode) fell through to the launch script, so a script naming claude read its screen with Claude's profile. The precedence predates this PR; it contradicts PIR #1475 (the running command is authoritative), so the command's harness is now checked before the script.
Found by this PR's Windows run: a Windows checkout gives the builder-prompt templates CRLF line endings, and the heading-then-placeholder regex expected a bare \n, so all 18 template cases failed there. The test landed on main after the last green Windows run, so it had never run on Windows.
… and says what it saw Tower Integration on CI: the first case timed out after 10 s waiting for the wrapper's ready line on a cold scratch Tower; the second case passed. The wait is now 30 s, re-reads the architect's terminal id on every check (a terminal replaced while Tower starts is followed), and on timeout fails with the terminal's output and the tail of Tower's log.
waleedkadous
added a commit
that referenced
this pull request
Dec 5, 2026
waleedkadous
added a commit
that referenced
this pull request
Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An agent started through a wrapper script (
shell.architect: "./start-agent.sh claude") had every message heldno-profile, forever and silently: the mailbox identified the agent's app from its running command only, and never read the harness the owner named in config. The mailbox now falls back toshell.architectHarness/shell.builderHarness/shell.siteManagerHarnesswhen the command and the launch script identify no harness, says so once at start when mail will be held, andcodev doctorreports it.Fixes #2083
Root Cause
Tower splits
shell.architecton whitespace and launches the first word, so the architect's running command is./start-agent.sh.resolveProfileForSession(mailbox-wiring.ts) matched that command's basename against the known harnesses, then read a builder's.builder-start.sh(an exact harness name in command position), and otherwise returnednull, sodeliverAgentMailheldno-profileon every pass. The launch side already resolves the harness from config first (getArchitectHarness: explicitarchitectHarness→ detection → claude); the mailbox never consulted it. Builders behind a wrapper (the launch script namesstart-agent.sh, not a harness) and the Site Manager behind one were affected the same way.Fix
gate-profiles.tsresolveAgentProfile): running command → launch script → configured harness, the last tier only when the first two name no harness. A command that names a harness always wins over config (PIR Architect identity: hydrate from the WELCOME frame (fully-authoritative) instead of fail-closed self-heal #1475), including one with no profile (e.g.opencode), which config never overrides. A wrong declaration stays safe: another family's profile fails the composer-marker test, so mail holds rather than misdelivers.(scope, toAgent); the kind comes from Tower's routing registry (architect / builder), machine scope is the Site Manager (siteManagerHarness, thenarchitectHarness, as its launch does). A plain shell has no setting. Config is read at each resolution, so mail already held delivers on the next pass once the setting is added, with no restart.servers/agent-profile.tswarnIfMailWillBeHeld): a TowerWARNand one line for the person starting the agent, naming what could not be identified, that mail will be held, and the setting that fixes it. When the command or launch script identifies a harness the mailbox has no profile for (e.g.opencode), the line says so and that no setting changes it (CMAP, codex). It is returned by activate (mailNotices, main + re-spawned siblings), add-architect and builder terminal-create (mailNotice), and printed byafx workspace start/setup/add-architect,afx spawn, andafx manager start(via the Site Manager's state reason, also shown byafx status).codev doctorreports each configured architect / builder / Site Manager command it cannot identify (configuredMailNotices), reading each as the launch side runs it (environment variables expanded) and a builder command as its launch script will (exact harness name only).tower-instances(imported bytower-terminals) andsite-managerwarn without importing the mailbox wiring.no-profileentry inagent-farm.md(bothcodev/andcodev-skeleton/) names the settings.Adjacent fix, in place: the 180 s owner notice for a
no-profilebuilder fell into the "CANNOT VERIFY" arm: it blamed a drifted TUI / torn frame and offeredafx interrupt, which only sends ESC (ends the builder's turn) and cannot clear a hold caused by the gate not recognising the app. It now names no terminal command and gives both causes of ano-profilehold: a wrapper script, whichshell.builderHarnessfixes with no restart, or a harness with no screen profile, which no setting changes. #1482's test that pinned the old remedy forno-profileis updated accordingly. The Site Manager's sender notice offeredafx manager attachfor the same hold and now gives the same two causes withshell.siteManagerHarness(CMAP, claude). The liveness warning forno-profilegives the same two causes, with the agent's own setting, instead of only "check for a TUI update".Adjacent fix, found by this PR's Windows run:
bugfix-1751-protocol-reference.test.tschecked the heading-then-placeholder layout with a regex expecting a bare\n; a Windows checkout gives the builder-prompt templates CRLF line endings, so all 18 template cases failed there. The test landed on main after the last green Windows run, so it had never run on Windows. Now\r?\n.Size: about 450 production lines, a good part of them comments: above the ~300 guideline because the start notice and the doctor check reach every start path (architect main/sibling, builder, Site Manager, four CLI commands). The resolution change itself is small.
The issue's two "Not checked" points
no-profilehold and name the reason? For an architect (the reported case): no.escalateHeldToOwnerdeliberately skips architect-addressed rows (the notice would starve in the same mailbox); the only traces were the sender'sheld (no-profile)answer and the liveness log/notification after 10 consecutive checks with recent output, which blamed "a TUI update". For a builder: yes, to its owner architect at 3 × the escalation age, namingno-profile, but with the wrong remedy (fixed above). For the Site Manager: its senders get the notice. With this PR the person starting any of the three is told at start, and the liveness warning names the setting.no-profile? The drainer retries held rows every 1.5 s backstop pass and re-resolves the profile each time; the config tier reads the config file at each resolution. So once the setting is added, held mail delivers on the next pass, with no restart of Tower or the agent. Pinned in both the unit test and the e2e below.Test Plan
bugfix-2083-configured-harness.test.ts(unit, realcreateSessionRawsessions, real config files, isolated HOME): precedence (command / launch script / config), each kind (architect, builder, Site Manager incl. itsarchitectHarnessfallback), known command wins over config, a builder ignoresarchitectHarness, delivery through the productionresolveProfileport, held mail delivers after the setting is added, the start notice + exactly oneWARN, a builder's notice names its launch script (never/bin/bash), doctor's report, owner/liveness wordingbugfix-2083-wrapper-architect.e2e.test.ts: a scratch Tower (dist, own port 14830, isolated HOME/state/sockets; not the machine's Tower) whose workspace'sshell.architectis a real wrapper script on disk. WitharchitectHarness: "claude":POST /api/sendtoarchitectanswersdeliveredand the bytes reach the terminal. Without it: activate returns the notice, the send answersheld/no-profile, and writing the setting (no restart) delivers the held message. Run withvitest run --config vitest.e2e.config.ts src/agent-farm/__tests__/bugfix-2083-wrapper-architect.e2e.test.tssuites=true): first run failed in two pre-existing tests, neither in code this PR changes (see below); rerun after the CRLF fix passed on7261d22f8, peer-pipeline includedCMAP
no-profile. Both fixed in26aea5ac2.79ea594e5: the command's harness is checked before the script.7261d22f8.b11cbc30b: Site Manager sender notice, doctor env-var expansion, launch script read once, docstring note on the substring matcher (a wrapper namedrun-gemini-agent.shreads as gemini; since26aea5ac2it gets the profile-less notice instead of silence),manager.tscomment. Not changed: "(claude or codex)" in the remedy omits agy on purpose:agyis not a launch harness (resolveHarnessrejects it unless a custom harness is defined), so naming it inarchitectHarnesswould break the launch.Flaky Tests
This PR's own
bugfix-2083-wrapper-architect.e2e.test.tstimed out once on CI (912277fe6, Tower Integration): its first case waited 10 s for the wrapper's ready line on a cold scratch Tower; the second case passed. Fixed in245bbb740: 30 s wait, the architect's terminal id re-read each check, and a timeout reports the terminal output and Tower's log tail. Green on CI since.peer-pipeline.test.ts› "a backlog of held mail" › "drains in order against C's per-pair limit…" and "…against R's own limit with C's raised…" (Windows only):expected [] to have a length of 29 / 30 but got +0after a 5 s clock advance (26 s and 22 s wall time). Its own header notes the file runs ~75× slower on the Windows runner. It imports onlypeer/*anddb/mailbox, none of which this PR touches; it passes on macOS/Linux CI and locally. Left running.