feat(runtime): embed box.muse-dev.online thread url and tool execution directives into followups, nudges, and dispatches
This commit is contained in:
+26
-7
@@ -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}] <OK|FAILED>: <summary of output>"
|
||||
|
||||
# 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 <op> <json_args>] 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 <token>\" "
|
||||
f"-H \"Content-Type: application/json\" -d '{{\"op\":\"<op>\",\"args\":{{...}}}}'\n\n"
|
||||
f"When finished, end your response with:\n"
|
||||
f"[RESULT {job_id}] <OK|FAILED>: <summary of output>"
|
||||
)
|
||||
|
||||
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,
|
||||
|
||||
+18
-10
@@ -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 <op> <args>] or curl -sk -X POST https://box.muse-dev.online/exec\n"
|
||||
f" • [TOOL followup.create {{\"in_m\": 5, \"prompt\": \"<reminder>\"}}]\n"
|
||||
f" • [TOOL swarm.spawn {{\"count\": 1, \"task\": \"<task>\"}}]\n"
|
||||
f" • [TOOL health.check {{}}]\n\n"
|
||||
f"[Directive: Take next action or close with [RESULT <job_id>] <summary>]"
|
||||
)
|
||||
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 <job_id>] <summary>]"
|
||||
)
|
||||
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 <job_id>] <summary>]"
|
||||
)
|
||||
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}] <outcome>]"
|
||||
# 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 <op> <args>] or curl to https://box.muse-dev.online/exec\n"
|
||||
f"Reply with [TOOL <op> <args>] to execute or close with [RESULT {matching_job_id}] <outcome>."
|
||||
)
|
||||
try:
|
||||
import muse_hybrid
|
||||
print(f"[{agent}] Injecting 1-turn nudge into {thread_name or thread_id[:8]} for job {matching_job_id}")
|
||||
|
||||
Reference in New Issue
Block a user