feat(envelope): inject Work Order header and shared tmux directives into prompt envelope

This commit is contained in:
operator
2026-10-05 16:31:35 +00:00
parent 1809a1a8e2
commit 1d2440c1f8
+14 -5
View File
@@ -10,6 +10,7 @@ Profiles tune the spawn recipe per job family; add new ones to PROFILES.
""" """
import json import json
import re import re
import hashlib
BOX_API = "https://box.muse-dev.online/api/box" BOX_API = "https://box.muse-dev.online/api/box"
@@ -155,27 +156,35 @@ def wrap(job_name, job_id, agent, target, rendered):
profile = pick_profile(job_name) profile = pick_profile(job_name)
spawn = spawn_call(job_id, job_name, profile) spawn = spawn_call(job_id, job_name, profile)
follow = native_followup_call(job_id, job_name, profile, agent) follow = native_followup_call(job_id, job_name, profile, agent)
parts = job_id.split("-")
wo_id = parts[-1] if len(parts) > 1 and len(parts[-1]) >= 8 else hashlib.sha256(job_id.encode()).hexdigest()[:8]
session_name = f"work-{agent}-{wo_id}"
tmux_new = _tool("tmux.new", {"session": session_name, "command": "bash"})
tmux_send = _tool("tmux.send", {"session": session_name, "keys": "echo 'Starting task execution...'"})
top = ( top = (
"WORK ORDER - ACTION REQUIRED, NOT INFORMATIONAL.\n" f"[WO:{wo_id}] WORK ORDER - ACTION REQUIRED, NOT INFORMATIONAL.\n"
"Your FIRST output must be tool calls, not prose. Start now:\n" "Your FIRST output must be tool calls, not prose. Run background commands via shared tmux:\n"
" 1) %s\n" " 1) %s\n"
" 2) %s\n" " 2) %s\n"
" 3) %s\n"
" 4) %s\n"
"Each tool call returns a result message; keep going until the task is done.\n" "Each tool call returns a result message; keep going until the task is done.\n"
"---- TASK ----\n" % (spawn, follow) "---- TASK ----\n" % (tmux_new, tmux_send, spawn, follow)
) )
has_result = "[RESULT" in rendered has_result = "[RESULT" in rendered
bottom = ( bottom = (
"\n---- END TASK ----\n" "\n---- END TASK ----\n"
"REMINDER (importance: critical): work is only real if a tool call ran. " "REMINDER (importance: critical): work is only real if a tool call ran. "
"If you have not yet spawned subagents or set a follow-up timer, do it now:\n" "Execute and inspect commands in your background tmux session or subagents:\n"
" %s\n" " %s\n"
" %s\n" " %s\n"
" Capture output: [TOOL tmux.capture {\"session\": \"%s\", \"lines\": 30}]\n"
"Native tools (preferred): cron.create (runonce/interval), cron.status, cron.view, cron.runs " "Native tools (preferred): cron.create (runonce/interval), cron.status, cron.view, cron.runs "
"(truth about what ran), cron.run, subagent spawn; hooks.dry_run before hooks.enable. " "(truth about what ran), cron.run, subagent spawn; hooks.dry_run before hooks.enable. "
"Native cron form: %s\n" "Native cron form: %s\n"
"Box fallback tools: [TOOL health.check {}] [TOOL swarm.list {}] [TOOL swarm.status {\"swarm_id\": \"<id>\"}] " "Box fallback tools: [TOOL health.check {}] [TOOL swarm.list {}] [TOOL swarm.status {\"swarm_id\": \"<id>\"}] "
"[TOOL swarm.results {\"swarm_id\": \"<id>\"}] [TOOL quality.check {}]\n" "[TOOL swarm.results {\"swarm_id\": \"<id>\"}] [TOOL quality.check {}]\n"
% (spawn, follow, native_followup_call(job_id, job_name, profile, agent)) % (spawn, follow, session_name, native_followup_call(job_id, job_name, profile, agent))
) )
bottom += _box_surface_block(agent, job_name, job_id, target) bottom += _box_surface_block(agent, job_name, job_id, target)
if not has_result: if not has_result: