agent-runtime/test_cog.py
Nico 8b69e6dd0d v0.6.2: Thinker node with python tool execution (S3 Control)
- ThinkerNode: reasons about perception, decides tool use vs direct answer
- Python tool: subprocess execution with 10s timeout
- Auto-detects python code blocks in LLM output and executes them
- Tool call/result visible in trace + HUD
- Thinker meter in frontend (token budget: 4K)
- Flow: Input (perceive) -> Thinker (reason + tools) -> Output (speak)
- Tested: math (42*137=5754), SQLite (create+query), time, greetings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 01:04:22 +01:00

35 lines
1.0 KiB
Python

"""Test script for cog runtime API. Run with: .venv/Scripts/python.exe test_cog.py"""
import httpx, sys, time
API = "https://cog.loop42.de/api"
TOKEN = "7Oorb9S3OpwFyWgm4zi_Tq7GeamefbjjTgooPVPWAwPDOf6B4TvgvQlLbhmT4DjsqBS_D1g"
HEADERS = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}
def send(text):
r = httpx.post(f"{API}/send", json={"text": text}, headers=HEADERS, timeout=30)
d = r.json()
return d.get("response", "").strip(), d.get("memorizer", {})
def clear():
httpx.post(f"{API}/clear", headers=HEADERS, timeout=10)
tests = [
("hello!", None),
("what is 42 * 137?", None),
("create a sqlite db with 5 customers and show them", None),
("wie spaet ist es?", None),
]
clear()
print("=== COG TEST RUN ===\n")
for i, (msg, _) in enumerate(tests, 1):
print(f"--- {i}. USER: {msg}")
resp, memo = send(msg)
print(f" COG: {resp}")
print(f" MEMO: name={memo.get('user_name')} mood={memo.get('user_mood')} topic={memo.get('topic')}")
print()
time.sleep(0.5)
print("=== DONE ===")