|
Download agentic/aiagent-0060.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/agentic/aiagent-0060.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/agentic/aiagent-0060.jsonl
-
curl -L -o aiagent-0060.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/agentic/aiagent-0060.jsonl
2.49 kB
| {"type": "session", "harness": "opencode", "id": "aiagent-0060", "name": "error recovery"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "How do agents recover from tool errors with bounded retry, backoff, fallback and escalation? Show retry handling with tool_call_id. Include code examples."}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Recovery: retry transient errors, rephrase, try another tool, else escalate. Always bound retries.**\n\n```python\nimport time\n\ndef execute_with_recovery(llm, run_tool, task: str, max_retries: int = 3) -> str:\n history: list[dict] = [{\"role\": \"user\", \"content\": task}]\n attempts = 0\n while attempts <= max_retries:\n msg = llm.chat.completions.create(\n model=\"model-identifier-from-lm-studio\", messages=history,\n ).choices[0].message\n if not msg.tool_calls:\n return msg.content or \"\"\n history.append({\n \"role\": \"assistant\", \"content\": msg.content,\n \"tool_calls\": [{\"id\": tc.id, \"type\": \"function\",\n \"function\": {\"name\": tc.function.name,\n \"arguments\": tc.function.arguments or \"{}\"}}\n for tc in msg.tool_calls],\n })\n for tc in msg.tool_calls:\n try:\n result = run_tool(tc.function.name, tc.function.arguments or \"{}\")\n except (TimeoutError, ConnectionError) as e:\n attempts += 1\n if attempts > max_retries:\n return f\"Failed after {max_retries} retries: {e}\"\n time.sleep(min(2 ** attempts, 8))\n result = f\"RETRYABLE ERROR: {type(e).__name__}: {e}\"\n except Exception as e:\n result = f\"ERROR: {type(e).__name__}: {e}\"\n history.append({\"role\": \"tool\", \"tool_call_id\": tc.id, \"content\": str(result)})\n attempts += 1\n return \"Failed after max retries\"\n```"}} | |