From c0add2a4cef31e77ecdaa8f4b64d3f4cad4d8898 Mon Sep 17 00:00:00 2001 From: operator Date: Mon, 5 Oct 2026 05:27:47 +0000 Subject: [PATCH] feat(runtime): embed box.muse-dev.online thread url and tool execution directives into followups, nudges, and dispatches --- bin/job-dispatch.py | 33 ++++++++++++++++++++++++++------- bin/response-harvester.py | 28 ++++++++++++++++++---------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/bin/job-dispatch.py b/bin/job-dispatch.py index 27e00ae..41679cc 100755 --- a/bin/job-dispatch.py +++ b/bin/job-dispatch.py @@ -437,13 +437,6 @@ def main(): rendered = render_prompt(prompt_template, variables) - # Standard completion envelope: guarantee agents know how to report completion - if "[RESULT" not in rendered: - rendered = rendered.rstrip() + f"\n\nWhen finished, end your response with:\n[RESULT {job_id}] : " - - # Format as JOB DM - dm_message = f"[JOB {job_id}] {rendered}" - # Determine recipient agent and target agent = job.get("agent", "muse") target = "main" @@ -535,6 +528,32 @@ def main(): "step_n": step_n, }) + # Determine thread url / context for the runtime envelope + target_clean = str(target) + thread_url = f"https://box.muse-dev.online/thread/{target_clean}" if re.fullmatch(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", target_clean.lower()) else f"https://box.muse-dev.online/sidechat/{target_clean}" + + # Build active tool calling envelope for https://box.muse-dev.online/ + tool_envelope = ( + f"\n\n--- NetVM Runtime & Tools ({agent} on {target_clean}) ---\n" + f"Thread Console: {thread_url}\n" + f"Available Tools via [TOOL ] or curl to https://box.muse-dev.online/exec:\n" + f" • Status: [TOOL health.check {{}}]\n" + f" • Service: [TOOL service.status {{\"unit\": \"board.service\"}}]\n" + f" • Follow-up: [TOOL followup.create {{\"in_m\": 10, \"prompt\": \"check progress\"}}]\n" + f" • Swarm: [TOOL swarm.spawn {{\"count\": 2, \"task\": \"parallel work\"}}]\n" + f"Direct Curl (Agent Bearer Auth):\n" + f" curl -sk -X POST https://box.muse-dev.online/exec -H \"Authorization: Bearer \" " + f"-H \"Content-Type: application/json\" -d '{{\"op\":\"\",\"args\":{{...}}}}'\n\n" + f"When finished, end your response with:\n" + f"[RESULT {job_id}] : " + ) + + if "[RESULT" not in rendered: + rendered = rendered.rstrip() + tool_envelope + + # Format as JOB DM + dm_message = f"[JOB {job_id}] {rendered}" + # Dispatch via dm.py (handles main or sidechat with auto-provisioning and verification) msg_id = send_dm(agent, target, dm_message, dry_run=dry_run, followup_tags=followup_tags, diff --git a/bin/response-harvester.py b/bin/response-harvester.py index 72603b6..ff5d3e3 100755 --- a/bin/response-harvester.py +++ b/bin/response-harvester.py @@ -658,17 +658,20 @@ def process_messages(raw_messages, agent, thread_id, thread_name, last_wm, follo if thread_id and re.fullmatch(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", thread_id.lower()): try: import muse_hybrid + thread_url = f"https://box.muse-dev.online/thread/{thread_id}" + tool_hint = ( + f"[Runtime Context: {thread_url}]\n" + f"Tools available: [TOOL ] or curl -sk -X POST https://box.muse-dev.online/exec\n" + f" • [TOOL followup.create {{\"in_m\": 5, \"prompt\": \"\"}}]\n" + f" • [TOOL swarm.spawn {{\"count\": 1, \"task\": \"\"}}]\n" + f" • [TOOL health.check {{}}]\n\n" + f"[Directive: Take next action or close with [RESULT ] ]" + ) if t_ok: clean_msg = format_tool_result_for_chat(op, t_res) - resp_text = ( - f"Tool result (`{op}`):\n{clean_msg}\n\n" - f"[Directive: Review result and take next action. When complete, close with [RESULT ] ]" - ) + resp_text = f"Tool result (`{op}`):\n{clean_msg}\n\n{tool_hint}" else: - resp_text = ( - f"Tool error (`{op}`): {t_res}\n\n" - f"[Directive: Review error and retry or proceed. When complete, close with [RESULT ] ]" - ) + resp_text = f"Tool error (`{op}`): {t_res}\n\n{tool_hint}" muse_hybrid.send_message(agent, resp_text, thread_id=thread_id, wait=0) except Exception as te: sys.stderr.write(f"warning: failed to post tool response back to thread: {te}\n") @@ -1046,8 +1049,13 @@ def maybe_nudge_untagged_sidechat(agent, thread_id, thread_name, mid, text, dry_ if rec.get("nudged_for_mid") == mid or rec.get("nudge_count", 0) >= 1: return - # Inject terse nudge footer - nudge_msg = f"[Nudge: To advance the workflow, reply with [RESULT {matching_job_id}] ]" + # Inject terse nudge footer with runtime & tool directive + thread_url = f"https://box.muse-dev.online/thread/{thread_id}" + nudge_msg = ( + f"[Nudge: Work thread active at {thread_url}]\n" + f"Available Tools: [TOOL ] or curl to https://box.muse-dev.online/exec\n" + f"Reply with [TOOL ] to execute or close with [RESULT {matching_job_id}] ." + ) try: import muse_hybrid print(f"[{agent}] Injecting 1-turn nudge into {thread_name or thread_id[:8]} for job {matching_job_id}")