test-whatsapp-health-agent.sh
Test harness for the WhatsApp health-agent pipeline.
Note
Live script from my home-lab server. Tokens, IDs, phone numbers and other secrets have been replaced with
placeholders like
<WHATSAPP_GROUP_ID> — everything else is the real, running code.
#!/usr/bin/env bash
set -euo pipefail
session_key="agent:main:confirmation-regression-$(date +%s)"
request='Can you provide a FULL healthcheck over the last 24 hours'
output_file=$(mktemp)
trap 'rm -f "$output_file"' EXIT
openclaw agent \
--session-key "$session_key" \
--message "$request" \
--json >"$output_file"
python3 - "$output_file" <<'PY'
import json
import re
import sys
with open(sys.argv[1], encoding="utf-8") as handle:
result = json.load(handle)
payloads = result["result"]["payloads"]
reply = "\n".join(item.get("text") or "" for item in payloads)
tool_summary = result["result"]["meta"].get("toolSummary", {})
tools = tool_summary.get("tools", [])
forbidden = re.compile(
r"would you like me to (?:proceed|route)|"
r"do you want me to proceed|"
r"shall i proceed|"
r"i will route this request",
re.IGNORECASE,
)
if forbidden.search(reply):
raise SystemExit(f"FAIL: confirmation loop detected:\n{reply}")
if "route_server_request" not in tools:
raise SystemExit(
"FAIL: the health request did not call route_server_request. "
f"Tools used: {tools}"
)
print("PASS: clear health request executed without a confirmation loop.")
print(reply)
PY