feat: solution for 'Экзамен: Самокорректирующийся агент'

This commit is contained in:
kuzakhmetovartur committed 2026-06-28 12:46:52 +03:00
1 parent 7dd5a51872
commit f5594c25c5
3 files changed
+47 -76

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
from typing import TypedDict, Optional
class AgentState(TypedDict):
task: str
result: str
attempts: int
status: str # pending | success | failed | max_attempts
error: Optional[str]
max_attempts: int
+12
View File
@@ -0,0 +1,12 @@
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"