AgentSkillsCN

autonomous-agent-expert

当您构建AI智能体、设计工具API、实现权限管理系统、打造自主编程助手,或在ReAct/Plan-Execute等模式下开展工作时,不妨采用这一方法。关键词:智能体循环、工具设计、权限系统、沙盒机制、人机协同、误差累积、智能体可靠性。

SKILL.md
--- frontmatter
name: autonomous-agent-expert
description: "Use when building AI agents, designing tool APIs, implementing permission systems, creating autonomous coding assistants, or working with ReAct/Plan-Execute patterns. Keywords: agent loop, tool design, permission system, sandbox, human-in-the-loop, compounding errors, agent reliability."

Autonomous Agent Expert

Role: AI Agent Architect & Production Reliability Specialist

[!IMPORTANT] Core insight: Autonomy is earned, not granted. Start with heavily constrained agents that do one thing reliably. Add autonomy only as you prove reliability.

Philosophy

Guardrails before capabilities, logging before optimization, reliability before features.

Core Principles

  1. Compounding Errors Kill Agents - 95% success per step = 60% by step 10
  2. Constrain First, Expand Later - Narrow scope = higher reliability
  3. Human-in-the-Loop by Default - Approval for risky operations
  4. Sandbox Everything - Isolation prevents catastrophic failures
  5. Log Everything - Debugging autonomous systems requires complete audit trails

Quick Start: ReAct Agent

The most common production pattern - alternating reasoning and action:

python
class ReActAgent:
    def run(self, task: str) -> str:
        for i in range(self.max_iterations):
            # Think: Get LLM response
            response = self.llm.chat(messages=self.history, tools=self.tools)

            # Act: Execute tool if requested
            if response.tool_calls:
                for call in response.tool_calls:
                    result = self._execute_tool(call)
                    self.history.append({"role": "tool", "content": result})
            else:
                return response.content  # Done

        return "Max iterations reached"

Full implementation: See react-pattern.md


Agent Architecture Patterns

PatternBest ForReference
ReActGeneral-purpose, exploratory tasksreact-pattern.md
Plan-ExecuteComplex multi-step, predictable tasksplan-execute-pattern.md
ReflectionQuality-critical, iterative refinementreflection-pattern.md

Tool Design

Essential tools for coding agents:

CategoryToolsRisk
Readread_file, search_code, list_dirLow
Writewrite_file, edit_fileMedium
Executerun_command, send_inputHigh
Externalsearch_web, open_browserMedium

Full patterns: See tool-design.md


Permission & Safety

python
class PermissionLevel(Enum):
    AUTO = "auto"          # Fully automatic (read operations)
    ASK_ONCE = "ask_once"  # Ask once per session (write operations)
    ASK_EACH = "ask_each"  # Ask every time (execute operations)
    NEVER = "never"        # Never allow (dangerous operations)

Full implementation: See permission-patterns.md


Best Practices Checklist

Agent Design

  • Clear task decomposition
  • Appropriate tool granularity
  • Error handling at each step
  • Max iterations limit
  • Cost limits set

Safety

  • Permission system implemented
  • Dangerous operations blocked
  • Sandbox for untrusted code
  • Audit logging enabled
  • Human-in-the-loop for high-risk actions

UX

  • Progress updates provided
  • Explanation of actions
  • Undo/rollback available

Key Insights

Every extra decision multiplies failure probability. A 95% success rate per step compounds to 60% by step 10. Minimize steps, maximize reliability per step.

The best agents are boring. They do one thing reliably rather than many things impressively.

Guardrails before capabilities. Permission systems, sandboxing, and logging should be built before adding autonomous features.


Anti-Patterns & Sharp Edges

IssueSeveritySolution
Compounding error ratesCriticalReduce steps, simplify tasks
Runaway costsCriticalSet hard cost limits
Dangerous operationsCriticalApproval flows, least privilege
Hallucinating outputsHighValidate against ground truth

Full details: See anti-patterns.md


Related Skills

Works well with: agent-tool-builder, browser-automation-expert, mcp-builder, prompt-mastery


References

Internal:

External: