12 lines
339 B
Python
12 lines
339 B
Python
import random
|
|
|
|
def unreliable_tool(task: str) -> str:
|
|
"""
|
|
Simulate a tool that fails 30% of the time.
|
|
"""
|
|
if random.random() < 0.3:
|
|
raise ValueError("Tool failed due to random error.")
|
|
# Simple implementation: if task contains arithmetic, compute it
|
|
if "2+2" in task:
|
|
return "4"
|
|
return "unknown" |