-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlooping_without_ece_observation_mode.py
More file actions
72 lines (55 loc) · 1.58 KB
/
Copy pathlooping_without_ece_observation_mode.py
File metadata and controls
72 lines (55 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# examples/looping_without_ece_observation_mode.py
from veloryn import execute, print_summary
import anthropic
client = anthropic.Anthropic()
TASK_ID = "claude-loop-observation"
# No max_cost → observation mode
MAX_COST = None
COST_MODEL = {
"input": 0.000003,
"output": 0.000015,
}
previous_output = ""
def run_task():
global previous_output
prompt = f"""
You are improving a customer support automation system for an e-commerce platform.
Previous version:
{previous_output}
Refine the system with:
- Better handling of edge cases (refund abuse, delayed shipping)
- Improved escalation logic to human agents
- More realistic customer scenarios
- Clear decision flows
Make it more detailed and production-ready.
"""
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=800,
messages=[
{
"role": "user",
"content": prompt
}
],
)
output = response.content[0].text
previous_output = output
return {
"output": output,
"usage": {
"input_tokens": response.usage.input_tokens,
"output_tokens": response.usage.output_tokens,
},
}
# Fixed steps (unbounded execution)
for _ in range(15):
execute(
task_id=TASK_ID,
run_task=run_task,
input_data="customer support refinement",
model="claude-sonnet-4-6",
cost_model=COST_MODEL,
max_cost=MAX_COST, # observation mode
)
print_summary(TASK_ID)