Hospital Agent Orchestration
Native Codex worker profiles, single-writer controls, startup checks, and evidence requirements.
Purpose And Scope
Use one native Codex session to coordinate bounded Hospital work. Do not build a separate orchestration service or run an uncontrolled group of writers. This setup supports the MAR execution policy. It does not change that plan's clinical requirements, unit dependencies, or release gates. PR 2757 is the draft integration boundary. Local MAR U1-U7 have implementation checkpoints. Local U8 verification and review fixes remain in progress. Use the review queue and execution records for current state.
The root AGENTS.md contains the scoped delegation rule. Current comparable
patterns are Codex's native custom-agent files and the existing Hospital unit
execution records. No application runtime, API, schema, or dependency changes
are required for this setup.
Roles And Models
| Role | Model / effort | Responsibility |
|---|---|---|
| Main orchestrator | gpt-6.1-sol / high | Assign tasks, inspect results, verify, commit, and maintain the PR |
hospital_explorer | gpt-6-luna / high | Read-only source mapping and evidence |
hospital_implementer | gpt-6.1-sol / high | One bounded implementation unit with focused proof |
hospital_reviewer | gpt-6-astra / high | Read-only review of stable changes and coverage |
Profiles live in .codex/agents/. They set both model and effort explicitly.
The main orchestrator is the root session, not a fourth worker profile.
.codex/config.toml caps spawned threads at two, excluding the parent. It does
not change the root model, default worker model, provider, permissions, MCP
servers, or other app model choices. Thread cleanup belongs to the active harness.
Use an explicit close operation when one is exposed. Otherwise collect the terminal
result and leave cleanup to the harness; do not invent a close command. If a later
spawn hits the thread limit, stop for supported cleanup rather than raising the cap.
The CLI must load the project as trusted before project configuration applies. Do not mark an unknown checkout trusted automatically. Use the normal client trust prompt. Global model/provider controls and account availability still apply.
These profiles do not provide separate per-worker sandboxes. Read-only role instructions are cooperative restrictions. Workers inherit the parent's sandbox and approval controls. For the initial smoke test, set the entire parent session to read-only. Never use a sandbox or approval bypass to make a worker run.
Use the official subagent documentation for the current configuration contract. A model listed in a local catalogue is not proof that an account can run it. A successful model request is separate from proof of the actual serving snapshot or reasoning effort.
Start The Orchestrator
Run from the existing integration worktree. Do not create a new integration PR or start another writer in that worktree.
codex --strict-config \
--model gpt-6.1-sol \
-c 'model_reasoning_effort="high"'This command selects a model for that new session. It does not switch this connected conversation's model. Use the normal permission controls for actual implementation. The command does not grant additional permissions.
For the current Hospital work, give the session this bounded starting request:
Follow AGENTS.md and the Hospital agent-orchestration guide. Continue the open
local U8 review queue under the canonical MAR plan. Verify HEAD,
model access, worker tools, and the prior checkpoint evidence before edits. Keep one
writer, existing branch and PR 2757, and all clinical release gates. Use fresh
Hospital workers and report observed model/effort limits honestly. Do not touch
.context, .compound-engineering, credentials, or ignored local configuration.Do not run this writer while another session owns active edits. Finish or stop the existing writer first. A second terminal does not make two writers safe.
Preflight And Read-Only Smoke Test
Before implementation:
- Record the branch, HEAD, tracked changes, pre-existing untracked paths, and excluded artifacts. Confirm the same worktree and integration PR.
- Verify the installed CLI version and project configuration. Check the current model catalogue, then make a bounded live request. Do not infer model access from a configured string alone.
- Start a read-only parent. Ask it to dispatch the named profiles, one at a time,
for tiny source-reading tasks. Test
hospital_implementerwith an explicit no-edit smoke packet; do not ask it to implement during the smoke test. - Require each worker to return its worker/thread ID, an answer with file/symbol evidence, changed paths, and any observed model receipt. Wait for each terminal result. Close the worker if the host exposes that operation; otherwise record harness-owned cleanup before starting the next. A launch is not completion.
- Inspect harness events as well as the answers. A parent answering the questions itself does not prove delegation. A worker reporting its own configured model does not prove the actual served model. Record absent receipts as unavailable.
- Compare Git state and content hashes of the intended setup files before and after. Require no repository write. The smoke packet must forbid external tools/connectors, databases, tests/builds, installers, and nested delegation.
- Record success or failure, tool/model availability, IDs, limits, and next action in the unit handoff. If a pin or tool cannot run, stop that route. Do not silently replace it or represent inline work as a successful model trial.
The native CLI route does not use the older external-worker npx launcher.
This does not authorize bypassing a skill's required external-controller protocol.
Native subagents and external implementation workers are different execution routes.
Use a skill's native route when it supports one; otherwise report the constraint.
Unit Execution Contract
- Give a worker one unit, the relevant requirement/decision excerpts, allowed files, starting commit, dependencies, and precise tests. Do not send the full chat or ask a worker to invent the programme scope.
- List required instruction reads separately from task source files. Include
root
AGENTS.md,CLAUDE.md, this guide, and applicable scoped instructions before dispatch. Do not give a file allowlist that conflicts with the profile. - Use a fresh implementation worker for each unit. At most one worker may edit. Read-only exploration can overlap only when it cannot observe changing files. Never split coupled schema, source constraints, or API contracts across writers.
- Stop the writer before review. Identify the reviewed commit and staged/unstaged diff. Review a stable snapshot; do not change it while the review runs.
- Only the orchestrator integrates and verifies. Inspect actual paths, not just the worker's claimed scope. Preserve unexpected or unrelated edits and resolve ownership before a commit. Workers cannot stage, commit, push, merge, or deploy.
- Assign owned disposable databases and isolated test resources. Run shared checks in a controlled order. Do not reset shared development/staging data.
- Resolve valid review findings and rerun affected checks. After two failed repair rounds, investigate the shared assumption before another edit.
- Keep the skill-required review loop. A generic native reviewer response does not itself satisfy a CE review receipt or CodeRabbit approval requirement.
- Keep one integration branch and PR. Add manual QA checkboxes and separate code delivery, API integration, deployment, nursing QA, and pilot approval.
Evidence And Recovery
At every unit boundary, record:
- Starting/reviewed/committed HEAD and base; task, allowed and actual paths.
- Worker IDs, requested profile/model/effort, observed harness identity, and any unavailable model/effort receipt. Never promote a self-report to verification.
- Test strategy, commands, results, review findings and fixes, and review limits.
- Repair rounds and measured usage when available. Use
unavailablefor missing usage; do not estimate cost savings from model names or elapsed time. - Current state: queued, running, waiting for review, blocked, or complete; the latest useful result and exact next action. Do not use a plan checkbox as proof.
- Open human QA and clinical release gates, plus concrete manual QA checkboxes.
Keep operational logs outside tracked source unless a reviewed developer/QA
record belongs in docs/. Never include patient data, credentials, private
payloads, or full session transcripts in review artifacts or the PR.
If a worker fails, preserve its result and inspect the actual tree before retry. Do not start a second writer while the first is live or its changes are unowned. Close completed workers when the host provides that operation; otherwise leave cleanup to the harness after terminal collection. Never retask a completed worker for a new unit. On resume, inspect existing work before dispatching again; do not duplicate a completed or unknown-outcome task.
Historical Setup Evidence
The setup was checked at source commit 237b2892f900882c61f0901e4d4ee51707d59a92
with Codex CLI 0.162.1. Standard TOML parsing passed for the project settings
and three profiles. The live CLI accepted strict configuration. The current
model catalogue included all three configured model names; that catalogue alone
does not establish actual serving identity.
The read-only parent collected these terminal results. The IDs below are task IDs reported by the parent's receipts, not verified child serving snapshots. The event stream exposed collection events but no child model/effort metadata.
| Profile | Reported task ID | Result |
|---|---|---|
hospital_explorer | /root/hospital_explorer_smoke | Identified delivered local U1 and its unrun Luna trial |
hospital_implementer | /root/hospital_implementer_smoke | Counted 11 planned MAR pairs; none live in U1 |
hospital_reviewer | /root/hospital_reviewer_smoke | Confirmed parent-only Git writes and inherited sandbox controls |
hospital_implementer follow-up | /root/hospital_mar_no_edit_followup | Confirmed 7 GET and 4 POST pairs within the explicit instruction/source allowance |
All requests used the table's configured model and high effort. Actual served
model and effort receipts were unavailable. This is delegation evidence, not
verified cross-model review or proof that a cheaper implementation trial passed.
There was no explicit close tool. Terminal results were collected and cleanup
remained harness-owned. A first attempt stopped before dispatch because its
packet required a close tool. The lifecycle rule was then corrected. The first
implementer packet also omitted the guide from its explicit allowance, although
the profile required it. The follow-up listed instruction files separately and
returned without that scope conflict.
Independent host checks found identical HEAD, Git status, tracked diff, and hashes of all seven setup files before and after the completed smoke runs. No application, database, permission, or model-default changes occurred. The three-worker parent's reported usage was 347,499 input tokens, including 314,624 cached tokens, and 3,388 output tokens. The follow-up parent reported 192,845 input tokens, including 163,840 cached tokens, and 1,886 output tokens. These receipts do not establish total child billing or cost savings. Keep future packets small and measure an actual unit before judging efficiency.
At this smoke-test checkpoint, local U2 had not started. This is historical evidence, not the current next-work instruction. The execution records and review queue identify current work. Nursing QA and pilot approval remain separate gates. Before any new write, check the available tools and confirm that no other writer owns the checkout.
Setup Acceptance
- CLI accepts the project configuration and all three profile files.
- The read-only parent dispatches and collects each named profile, with explicit close or documented harness-owned cleanup.
- Requested models and missing served-model/effort evidence are recorded.
- Git state and setup-file hashes match before and after the smoke test.
- At each new implementation start, confirm that another writer is not active.
- The existing PR stays draft; no clinical activation or approval is inferred.