feat(autonomy): add followup.create primitive and tool-continuation directives to enforce silence-kills-work
This commit is contained in:
@@ -274,10 +274,23 @@ def format_tool_result_for_chat(op, raw_output):
|
||||
st = "ACTIVE" if data.get("active") else "INACTIVE"
|
||||
return f"Service `{data.get('service')}` is {st}.\nStatus: {data.get('status_line')}"
|
||||
|
||||
if op == "service.restart" and isinstance(data, dict):
|
||||
if op in ("followup.create", "followup.schedule") and isinstance(data, dict):
|
||||
if not data.get("ok"):
|
||||
return f"Service restart failed for `{data.get('service')}`: {data.get('error')}"
|
||||
return f"Service `{data.get('service')}` restarted successfully."
|
||||
return f"Follow-up scheduling failed: {data.get('error')}"
|
||||
sec = data.get("in_seconds", 60)
|
||||
ag = data.get("agent", "")
|
||||
return f"Follow-up timer scheduled for {ag} in {sec}s ({round(sec/60, 1)}m)."
|
||||
|
||||
if op == "swarm.spawn" and isinstance(data, dict):
|
||||
if not data.get("ok"):
|
||||
return f"Swarm spawn failed: {data.get('error')}"
|
||||
return f"Swarm `{data.get('swarm_id')}` spawned with {data.get('count')} worker slots (status: {data.get('status')})."
|
||||
|
||||
if op == "swarm.status" and isinstance(data, dict):
|
||||
if not data.get("ok"):
|
||||
return f"Swarm status check failed: {data.get('error')}"
|
||||
sw = data.get("swarm", {})
|
||||
return f"Swarm `{sw.get('swarm_id')}`: {sw.get('status')} ({sw.get('done', 0)}/{sw.get('count', 0)} slots completed)."
|
||||
|
||||
# General fallback: compact JSON capped to 400 chars
|
||||
s = json.dumps(data)
|
||||
@@ -647,9 +660,15 @@ def process_messages(raw_messages, agent, thread_id, thread_name, last_wm, follo
|
||||
import muse_hybrid
|
||||
if t_ok:
|
||||
clean_msg = format_tool_result_for_chat(op, t_res)
|
||||
resp_text = f"Tool result (`{op}`):\n{clean_msg}"
|
||||
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>]"
|
||||
)
|
||||
else:
|
||||
resp_text = f"Tool error (`{op}`): {t_res}"
|
||||
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>]"
|
||||
)
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user