← 返回 Skills 市场
sky-lv

Agent Performance Profiler

作者 SKY-lv · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
100
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install agent-performance-profiler
功能描述
Analyzes AI agent response time, token usage, and tool call efficiency, providing actionable recommendations to optimize performance and reduce cost.
使用说明 (SKILL.md)

Agent Performance Profiler — 性能分析与优化

功能说明

深度分析 AI Agent 性能,包括响应时间、Token 消耗、工具调用效率,提供可执行的优化建议。让 Agent 更快、更省、更稳定。

核心指标

1. 响应时间 (Response Time)

metrics:
  - first_token_latency: 首 Token 延迟(目标:\x3C500ms)
  - total_response_time: 总响应时间(目标:\x3C3s)
  - time_to_first_byte: 首字节时间
  - streaming_latency: 流式延迟

benchmarks:
  - simple_query: \x3C1s
  - complex_task: \x3C5s
  - multi_tool: \x3C10s

2. Token 消耗 (Token Usage)

metrics:
  - input_tokens: 输入 Token 数
  - output_tokens: 输出 Token 数
  - total_tokens: 总 Token 数
  - cost_per_request: 单次请求成本

optimization:
  - prompt_compression: 提示词压缩
  - context_pruning: 上下文裁剪
  - response_summarization: 响应摘要

3. 工具调用效率 (Tool Efficiency)

metrics:
  - tool_call_count: 工具调用次数
  - tool_success_rate: 工具成功率(目标:>95%)
  - redundant_calls: 冗余调用数
  - parallel_opportunities: 可并行机会

optimization:
  - batch_calls: 批量调用
  - cache_results: 缓存结果
  - parallel_execution: 并行执行

4. 错误率 (Error Rate)

metrics:
  - api_error_rate: API 错误率(目标:\x3C1%)
  - timeout_rate: 超时率(目标:\x3C2%)
  - retry_rate: 重试率(目标:\x3C5%)

alerts:
  - error_spike: 错误率突增
  - latency_spike: 延迟突增
  - cost_spike: 成本突增

性能分析流程

1. 基线测试

test_cases:
  - simple_qa: 简单问答
  - multi_step: 多步任务
  - tool_intensive: 工具密集型
  - context_heavy: 重上下文

metrics_collected:
  - response_time
  - token_usage
  - tool_calls
  - error_rate

2. 瓶颈识别

common_bottlenecks:
  - verbose_prompts: 提示词过长
  - redundant_tool_calls: 冗余工具调用
  - sequential_execution: 顺序执行(可并行)
  - context_bloat: 上下文膨胀
  - inefficient_retries: 低效重试

3. 优化建议

optimization_strategies:
  - prompt_optimization:
      - 移除冗余描述
      - 使用结构化输出
      - 添加示例(few-shot)
  
  - tool_optimization:
      - 批量调用
      - 结果缓存
      - 并行执行
  
  - context_optimization:
      - 相关性过滤
      - 摘要压缩
      - 向量检索

优化技巧

提示词优化

❌ 低效:

你是一个很有帮助的 AI 助手,你需要帮助用户完成各种任务。
请仔细阅读用户的问题,然后思考如何解决。
你需要考虑各种因素,包括...(冗长描述)

✅ 高效:

角色:{专业角色}
任务:{具体任务}
输出格式:{JSON/Markdown/列表}
约束:{限制条件}

效果: Token 减少 60%,响应时间减少 40%

工具调用优化

❌ 低效(顺序调用):

1. 搜索 A
2. 搜索 B
3. 搜索 C
4. 合并结果

✅ 高效(并行调用):

并行:
  - 搜索 A
  - 搜索 B
  - 搜索 C
合并结果

效果: 响应时间减少 70%

上下文优化

❌ 低效(完整历史):

[完整对话历史,5000+ Token]

✅ 高效(相关性过滤):

[最近 5 轮对话]
[相关记忆摘要,500 Token]

效果: Token 减少 80%,成本减少 80%

工具函数

profile_agent

def profile_agent(task: str, iterations: int = 10) -> dict:
    """
    Agent 性能分析
    
    Args:
        task: 测试任务
        iterations: 测试迭代次数
    
    Returns:
        {
            "avg_response_time": 1.23,  # 秒
            "p95_response_time": 2.45,
            "avg_tokens": 450,
            "avg_cost": 0.002,  # 美元
            "tool_calls": 3.2,  # 平均每次
            "error_rate": 0.02  # 2%
        }
    """

optimize_prompt

def optimize_prompt(prompt: str) -> dict:
    """
    提示词优化
    
    Args:
        prompt: 原始提示词
    
    Returns:
        {
            "original_tokens": 500,
            "optimized_tokens": 200,
            "reduction": 0.6,
            "optimized_prompt": "优化后的提示词",
            "changes": ["移除冗余", "结构化", "添加示例"]
        }
    """

analyze_tool_calls

def analyze_tool_calls(trace: list) -> dict:
    """
    工具调用分析
    
    Args:
        trace: 工具调用追踪
    
    Returns:
        {
            "total_calls": 15,
            "redundant_calls": 3,
            "parallel_opportunities": 2,
            "cache_hits": 5,
            "optimization_suggestions": [
                "合并 A 和 B 调用",
                "并行执行 C 和 D",
                "缓存 E 的结果"
            ]
        }
    """

性能基准

优秀 Agent 标准

指标 优秀 良好 需优化
响应时间 \x3C1s 1-3s >3s
Token 效率 \x3C300 300-800 >800
工具成功率 >98% 95-98% \x3C95%
成本/请求 \x3C$0.001 $0.001-0.005 >$0.005

成本计算

模型定价(参考):
  - GPT-4: $0.03/1K input, $0.06/1K output
  - Claude-Sonnet: $0.003/1K input, $0.015/1K output
  - Qwen-Plus: ¥0.004/1K input, ¥0.012/1K output

示例:
  输入 500 Token + 输出 300 Token
  GPT-4 成本:$0.033
  Claude-Sonnet 成本:$0.006
  Qwen-Plus 成本:¥0.0056

相关文件

触发词

  • 自动:检测 performance、optimize、token、latency、profiling 相关关键词
  • 手动:/agent-profiler, /performance-analysis, /optimize-agent
  • 短语:性能分析、优化 Agent、Token 消耗、响应时间

Usage

  1. Install the skill
  2. Configure as needed
  3. Run with OpenClaw
安全使用建议
This skill appears to do what it says: measure response latency, token usage, and tool-call patterns and offer optimizations, and it has no install script or credential requests. Before installing, confirm these specifics with the skill author or test in a safe environment: - Data scope: exactly which inputs does the skill read to profile the agent? (full conversation history, last N turns, tool call traces, external logs?) - Data retention/transmission: where are profiling results stored or sent? Are reports kept locally only or uploaded to external endpoints? Is any PII or secret data redacted before analysis? - Invocation behavior: does the skill run automatically on keyword detection or only when explicitly invoked? If automatic, consider disabling autonomous triggers until you confirm safe defaults. - Access control: can you limit the skill to profiling synthetic or sanitized sessions first? If you cannot get answers to the above, run the skill manually on non-sensitive test data only. If answers are satisfactory, the skill is reasonably proportional and coherent for its stated purpose.
功能分析
Type: OpenClaw Skill Name: agent-performance-profiler Version: 1.0.0 The skill bundle for 'agent-performance-profiler' consists of metadata and documentation (SKILL.md) defining a framework for analyzing AI agent performance. It outlines metrics for latency, token consumption, and tool efficiency, and provides function signatures for profiling and optimization. No executable code or malicious prompt-injection instructions were found; the content is entirely aligned with its stated purpose of performance analysis.
能力评估
Purpose & Capability
Name/description (agent profiling, token/cost optimization, tool-call analysis) align with the SKILL.md content. It does not request unrelated binaries, credentials, or config paths; the declared scope matches what the skill says it will measure and recommend.
Instruction Scope
SKILL.md provides profiling metrics, test cases, and pseudocode for functions that operate on agent traces and conversation history (e.g., profile_agent, analyze_tool_calls). This is expected for profiling, but the document is vague about exactly which data sources (full chat history, tool payloads, external logs) will be read and whether any data will be transmitted or persisted. That ambiguity increases the risk of collecting sensitive user content.
Install Mechanism
Instruction-only skill with no install spec and no code files. Lowest install risk — nothing is downloaded or written by an installer.
Credentials
No environment variables, credentials, or config paths are required. The declared requirements are proportionate to a profiling tool. However, profiling implicitly needs access to conversation/tool traces; the SKILL.md does not enumerate access controls or limits.
Persistence & Privilege
always:false (normal). The skill declares trigger words and is allowed to be invoked autonomously (disable-model-invocation:false, which is the platform default). Combined with the unclear data-scope, automatic triggering could lead to unexpected profiling of conversations or tool calls — consider restricting automatic invocation or confirming what data is captured/retained.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agent-performance-profiler
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agent-performance-profiler 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of Agent Performance Profiler. - Provides in-depth analysis of agent response time, token consumption, and tool call efficiency. - Offers actionable optimization recommendations with clear metrics, benchmarks, and workflow. - Includes built-in functions for profiling, prompt optimization, and tool call analysis. - Supports both automatic and manual triggering using performance-related keywords and commands.
元数据
Slug agent-performance-profiler
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Agent Performance Profiler 是什么?

Analyzes AI agent response time, token usage, and tool call efficiency, providing actionable recommendations to optimize performance and reduce cost. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 100 次。

如何安装 Agent Performance Profiler?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-performance-profiler」即可一键安装,无需额外配置。

Agent Performance Profiler 是免费的吗?

是的,Agent Performance Profiler 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Agent Performance Profiler 支持哪些平台?

Agent Performance Profiler 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Agent Performance Profiler?

由 SKY-lv(@sky-lv)开发并维护,当前版本 v1.0.0。

💬 留言讨论