import asyncio import json import os import sys from temporalio.client import Client from workflow import AgentOptimizationWorkflow EXPERIMENT = { "task": ( "A server validation log reports repeated corrected cache-line parity " "errors but no machine-check shutdown. State whether the observed " "failure is corrected or fatal." ), "context": ( "Corrected hardware errors are recovered by hardware or firmware and " "allow execution to continue. Fatal uncorrected errors generally " "produce an unrecoverable machine-check condition." ), "expected_phrase": "corrected", "configs": [ {"name": "baseline", "max_context_chars": 5000, "max_tokens": 256, "temperature": 0}, {"name": "short_context", "max_context_chars": 250, "max_tokens": 128, "temperature": 0}, { "name": "minimal_output", "max_context_chars": 250, "max_tokens": 32, "temperature": 0, "system_prompt": "You are a server CPU validation expert. Answer in one sentence.", }, ], } async def main(): workflow_id = sys.argv[1] if len(sys.argv) > 1 else "agent-optimization-experiment-001" client = await Client.connect("localhost:7233") result = await client.execute_workflow( AgentOptimizationWorkflow.run, EXPERIMENT, id=workflow_id, task_queue="agent-optimization", ) print(json.dumps(result, indent=2)) os.makedirs("results", exist_ok=True) path = os.path.join("results", f"{workflow_id}.json") with open(path, "w") as fh: json.dump(result, fh, indent=2) print(f"\nSaved to {path}") if __name__ == "__main__": asyncio.run(main())