Communitygithub.com

代理间交换格式

用于代理间通信的数据结构与序列化格式,涵盖消息信封、结构化输出模式、能力声明、任务交接载荷、错误/重试信号以及作为数据结构的上下文窗口。深入对比 A2A 协议、MCP、OpenAI 函数调用和 LangChain 消息类型。指导何时使用严格模式 vs 带验证的自由格式、类型化 vs 非类型化、流式 vs 批量。

代理间交换格式 是什么?

该技能旨在为 AI 代理开发者和集成者提供关于代理间通信数据格式的全面指南。它定义了核心数据结构,例如消息信封、能力卡、任务交接载荷和错误信号,并确保这些结构既机器可解析又对 LLM 友好。技能通过决策树指导您选择正确的协议,例如在需要服务发现、异步任务生命周期和多代理编排时选择 A2A 协议,而在单一代理调用工具时选择 MCP。它还深入探讨了模式严格性的权衡,强调对于工具调用参数和能力卡等关键交互必须采用“模式优先”的方法,而对于创造性内容则建议使用“验证后”方法以避免过度约束。此外,该技能提供了关于流式传输与批处理的决策方案,并详细描述了常见的故障模式,如模式漂移、消息丢失和上下文窗口溢出,以及相应的修复策略。它包含完整的 TypeScript 示例,演示了具有上下文预算限制的任务交接、使用 A2A 的文档处理管道以及带有指数退避的智能错误重试逻辑。最后,它提供了明确的质量标准和边界说明,帮助您避免将该技能的使用范围扩大到会话语义或编排拓扑等领域。

兼容平台~Claude Code✓Codex CLI~Cursor✓Antigravity
npx skills add https://github.com/curiositech/windags-skills/tree/HEAD/skills/agent-interchange-formats

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

代理间交换格式 是做什么的?

您是代理用于通信的数据结构方面的专家。了解从 FIPA-ACL 到 MCP 和 A2A 的线路格式,并且能够设计既机器可解析又对 LLM 友好的消息信封、能力卡片、任务载荷和错误信号。

决策点

协议选择树

Agent通信场景?
├── 单一代理调用工具?
│   ├── 工具是本地进程 → 通过 stdio 的 MCP
│   └── 工具是远程服务 → 通过 HTTP/SSE 的 MCP 或 OpenAI 函数调用
├── 代理间通信?
│   ├── 需要发现 + 任务生命周期 + 异步 → A2A 协议
│   ├── 简单的请求/响应 → 自定义 JSON-RPC 2.0
│   └── 与现有框架集成 → 框架的原生格式
└── 来自 LLM 的结构化输出?
    ├── 机器可读载荷(API、模式) → 模式优先(Zod/JSON Schema)
    └── 创造性/探索性内容 → 验证后解析

模式严格性决策

如果载荷类型为:
├── 工具调用参数 → 始终模式优先(没有结构会出错)
├── 代理能力卡 → 始终模式优先(发现需要可靠性)
├── 任务交接数据 → 始终模式优先(自动化需要结构)
├── 错误/重试信号 → 始终模式优先(编程重试逻辑)
├── 创造性文本输出 → 始终验证后(模式扼杀创造力)
├── 分析结果 → 验证后,使用回退提取
└── 混合内容 → 使用 Parts 数组:DataPart 模式优先,TextPart 验证后

流式与批处理决策

如果用户体验要求:
├── 渐进式输出(面向用户) → 流式(SSE/WebSocket)
├── 长时间运行的任务(>30秒) → 带状态更新的流式
├── 代理到代理管道 → 批处理(更清晰的错误处理)
├── 成本跟踪至关重要 → 批处理(已知的初始 token 计数)
├── 中流恢复需要 → 批处理(流式错误处理很复杂)
└── 简单集成 → 批处理(HTTP 请求/响应)

故障模式

模式漂移

症状: 之前工作的代理间出现运行时验证错误,TypeScript 编译成功但运行时失败 诊断: 模式定义版本不匹配,一个代理更新了模式而没有协调 修复: 在所有模式中添加显式版本字段;实现向后兼容性检查;使用模式注册表进行协调

消息丢失

症状: 对话看起来不完整,代理无限重试,发生重复处理 诊断: 没有去重机制,缺少关联 ID,没有恢复的网络问题 修复: 添加 UUID 消息 ID;实现已见消息跟踪;使用 conversationId 进行线程化;添加带指数退避的重试逻辑

上下文窗口溢出

症状: 代理任务失败并提示“上下文过长”,对话被截断,工具结果不完整 诊断: 交接中没有 token 计数,无限制的上下文积累,缺少总结 修复: 估算每个 Part 的 token 数;实现上下文预算;添加可丢弃优先级系统;使用摘要进行压缩

解析僵化

症状: 代理输出格式错误的 JSON,创造性的任务产生通用响应,高重试率 诊断: 模式优先应用于探索性内容,验证过于严格,没有优雅降级 修复: 对创造性内容使用验证后;实现提取回退;对探索性任务放宽约束

协议巴别塔

症状: 每对代理需要自定义翻译,集成复杂性爆炸,维护负担 诊断: 每个团队发明了自己的线路格式,没有标准化,非我发明综合征 修复: 采用 JSON-RPC 2.0 作为线路标准;对多代理使用 A2A;为遗留系统实现格式适配器

工作示例

示例 1:带上下文窗口限制的任务交接

场景: 研究代理(32k 上下文)向代码生成代理(128k 上下文)交接包含 50k 令牌研究数据的任务。

决策过程:

  1. 检查接收代理的上下文预算:128k - 8k(系统)- 8k(输出) = 112k 可用
  2. 研究数据(50k)适合,但为了鲁棒性仍应用上下文预算
  3. 使用优先级丢弃非关键上下文来构建交接
// 研究代理准备交接
const contextHandoff: ContextHandoff = {
  context: [
    { kind: 'text', text: summary, mimeType: 'text/markdown' },
    { kind: 'data', data: criticalFindings, schema: FindingsSchema },
    { kind: 'text', text: detailedNotes, mimeType: 'text/plain' }
  ],
  estimatedTokens: 50000,
  droppable: [
    { partIndex: 2, priority: 1, tokenEstimate: 30000 }, // 首先丢弃详细笔记
    { partIndex: 0, priority: 2, tokenEstimate: 15000 }  // 不得已时丢弃摘要
  ],
  summary: "关键发现:API 速率限制,需要异步模式",
  summaryTokens: 500
};

// 代码生成代理接收并预算
const budget = calculateContextBudget(128000);
if (contextHandoff.estimatedTokens > budget.available) {
  // 丢弃低优先级上下文
  let remainingBudget = budget.available;
  const finalContext = contextHandoff.context.filter((part, index) => {
    const droppable = contextHandoff.droppable?.find(d => d.partIndex === index);
    if (droppable && droppable.tokenEstimate > remainingBudget) {
      return false; // 丢弃这个部分
    }
    remainingBudget -= droppable?.tokenEstimate || 1000;
    return true;
  });
}

新手遗漏: 会在没有 token 估算的情况下传递原始研究数据,导致下游上下文溢出。 专家捕获: 使用显式预算和优雅降级来构建交接。

示例 2:A2A 与 MCP 协议选择

场景: 构建一个包含 OCR 代理、分析代理和格式化代理的文档处理系统。

决策过程:

  1. 多个代理需要发现彼此 → 排除 OpenAI 函数调用
  2. 代理运行在不同的服务器上,需要异步任务生命周期 → A2A 协议胜过 MCP
  3. 需要双向通信和任务状态 → 确认选择 A2A
// 文档流经代理管道
const ocrCard: AgentCard = {
  agentId: 'ocr-service-v2',
  name: 'OCR 文档阅读器',
  url: 'https://ocr.company.com',
  skills: [{
    id: 'extract-text',
    inputSchema: { /* PDF/图像模式 */ },
    outputSchema: { /* 结构化文本模式 */ }
  }],
  capabilities: {
    streaming: true,  // 长时间运行的 OCR 任务需要状态更新
    pushNotifications: true,  // OCR 完成时通知
    stateTransitionHistory: true  // 跟踪管道中的进度
  }
};

// 向 OCR 代理提交任务
const ocrTask: Task = {
  id: generateTaskId(),
  state: 'submitted',
  messages: [{
    id: generateId(),
    timestamp: new Date().toISOString(),
    sender: { agentId: 'document-processor' },
    recipient: { agentId: 'ocr-service-v2' },
    conversationId: documentProcessingId,
    parts: [
      { kind: 'file', name: 'contract.pdf', content: base64Content, mimeType: 'application/pdf' }
    ]
  }],
  artifacts: [],
  createdAt: new Date().toISOString(),
  updatedAt: new Date().toISOString()
};

新手遗漏: 会因“更简单”而选择 MCP,而不考虑双向异步需求。 专家捕获: 认识到需要 A2A 来实现服务发现、任务生命周期和多代理编排。

示例 3:带重试逻辑的错误恢复

场景: 分析代理在处理过程中因速率限制而失败,需要智能重试。

决策过程:

  1. 从结构化错误代码检测错误类型
  2. 检查可重试标志和退避参数
  3. 实现带抖动的指数退避
  4. 在达到最大重试次数后升级到人工处理
// 代理返回结构化错误
const rateLimitError: AgentError = {
  code: 'RATE_LIMITED',
  message: 'API 配额已超出。请在 60 秒后重试。',
  retryable: true,
  retryAfterMs: 60000,
  maxRetries: 3,
  details: {
    quotaType: 'requests_per_minute',
    resetTime: '2025-01-08T10:15:00Z'
  }
};

// 调用代理实现重试逻辑
async function callAgentWithRetry(agent: AgentCard, task: Task, attempt = 1): Promise<Task> {
  try {
    return await callAgent(agent, task);
  } catch (error) {
    if (error instanceof AgentError && error.retryable && attempt <= error.maxRetries) {
      // 带抖动的指数退避
      const baseDelay = error.retryAfterMs || 1000;
      const jitter = Math.random() * 0.1 * baseDelay;
      const delay = baseDelay * Math.pow(2, attempt - 1) + jitter;
      
      await sleep(delay);
      return callAgentWithRetry(agent, task, attempt + 1);
    } else {
      // 不可重试或达到最大尝试次数
      return {
        ...task,
        state: 'failed',
        artifacts: [{
          id: generateId(),
          name: 'error-report',
          parts: [{ kind: 'error', ...error }],
          createdAt: new Date().toISOString(),
          index: 0
        }]
      };
    }
  }
}

新手遗漏: 会立即重试而没有退避,或在第一次失败后就放弃。 专家捕获: 使用结构化错误代码进行智能重试,带有适当的退避和升级机制。

质量门

  • 每封邮件信封都包含唯一的 id、conversationId 和 ISO-8601 格式的 timestamp
  • Parts 对类型安全使用带 kind 字段的判别联合
  • 代理卡发布在可发现的 .well-known/agent.json URL 上
  • 错误对象包含 retryable 布尔值和类型化的 code 枚举
  • 上下文交接包含 token 估算和基于优先级的丢弃
  • 所有模式验证往返:序列化 → 反序列化 → 与原始值相等
  • 二进制内容使用 URI 引用,而不是 base64 嵌入
  • 跨模式版本保持向后兼容性
  • 流式事件包含单调递增的序列号以保证顺序
  • 消息元数据中没有敏感数据(使用适当的认证头)

不适用边界

此技能不应用于:

  • 对话语义:代理之间说什么 → 请使用 agent-conversation-protocols
  • 编排拓扑:代理如何连接 → 请使用 multi-agent-coordination
  • 基础设施设置:部署代理运行时 → 请使用 agentic-infrastructure-2026
  • 单代理框架:构建单个代理 → 请使用 ai-engineer
  • API 设计:设计 REST/GraphQL API → 请使用 api-design-patterns

委托给:

  • 模式验证逻辑 → 对于 Zod/品牌类型,请使用 typescript-advanced-patterns
  • 网络传输 → 对于 HTTP/WebSocket 设置,请使用 systems-architecture
  • 认证流程 → 对于 OAuth2/JWT 实现,请使用 auth-patterns

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

curiositech/windags-skills

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

curiositech/windags-skills

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

curiositech/windags-skills

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

curiositech/windags-skills

Implement WCAG 2.2 AA/AAA compliance with automated testing, keyboard navigation, screen reader support, and focus management. Activate on: accessibility audit, WCAG compliance, keyboard navigation, screen reader, aria attributes, axe-core, focus trap. NOT for: design-level accessibility review (use design-accessibility-auditor), color contrast only (use css-in-js-architect).

curiositech/windags-skills

Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that actually work for neurodivergent minds.

curiositech/windags-skills

Designs digital experiences for ADHD brains using neuroscience research and UX principles. Expert in reducing cognitive load, time blindness solutions, dopamine-driven engagement, and compassionate design patterns. Activate on 'ADHD design', 'cognitive load', 'accessibility', 'neurodivergent UX', 'time blindness', 'dopamine-driven', 'executive function'. NOT for general accessibility (WCAG only), neurotypical UX design, or simple UI styling without ADHD context.

curiositech/windags-skills

>- Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

curiositech/windags-skills

Extend and modify the admin dashboard, developer portal, and operations console. Use when adding new admin tabs, metrics, monitoring features, or internal tools. Activates for dashboard development, analytics, user management, and internal tooling.

curiositech/windags-skills

Conversation patterns and interaction protocols for multi-agent systems. Covers request/response, pub/sub, blackboard, delegation chains, debate, critique, consensus, fan-out/fan-in, supervisor-worker, and peer negotiation. Deep analysis of AutoGen conversation patterns, CrewAI delegation, LangGraph state passing, and FIPA-ACL performatives. Teaches how to design what agents say to each other and in what order. Activate on: "agent conversation", "agent protocol", "multi-agent debate", "agent delegation", "supervisor worker pattern", "agent voting", "consensus protocol", "fan-out fan-in", "agent negotiation", "blackboard pattern", "agent dialogue", "conversation topology", "agent handoff". NOT for: wire format or serialization (use agent-interchange-formats), orchestration infrastructure (use agentic-infrastructure-2026), single agent behavior (use agentic-patterns).

curiositech/windags-skills

Meta-agent for creating new custom agents, skills, and MCP integrations. Expert in agent design, MCP development, skill architecture, and rapid prototyping. Activate on 'create agent', 'new skill', 'MCP server', 'custom tool', 'agent design'. NOT for using existing agents (invoke them directly), general coding (use language-specific skills), or infrastructure setup (use deployment-engineer).

curiositech/windags-skills

AI-powered calendar management and agent-based scheduling coordination. Covers calendar APIs (Google Calendar, CalDAV/iCal), AI scheduling assistants (Reclaim, Clockwise, Motion, Cal.com), building custom calendar agents with MCP, multi-calendar merging, timezone management, focus block protection, meeting fatigue detection, and agent-to-agent meeting negotiation protocols. Activate on: "calendar agent", "AI scheduling", "calendar coordination", "meeting scheduling", "calendar API", "focus time protection", "calendar optimization", "Google Calendar MCP", "Reclaim", "Clockwise", "Motion", "Cal.com", "smart scheduling", "calendar-aware agent", "timezone scheduling", "agent negotiation meetings". NOT for: manual calendar UI component design (use form-validation-architect), project management scheduling or Gantt charts (use project-management-guru-adhd), general time-tracking or pomodoro apps (use adhd-daily-planner for time-awareness), building the agent itself from scratch (use agent-creator).

curiositech/windags-skills

Build and adopt production AI agent infrastructure in 2026. Covers framework selection (LangGraph, CrewAI, AutoGen, MCP), orchestration patterns, evaluation, observability, memory systems, and tool use. Also covers the SOCIAL dimension: how to sell agent infrastructure internally, change management, measuring ROI, building trust in autonomous systems, and scaling adoption across teams. Activate on: "agent infrastructure", "agent framework comparison", "which agent framework", "sell AI tools internally", "agent adoption", "agent observability", "agent evaluation", "MCP architecture", "agentic mesh", "enterprise AI agents", "AI change management", "agent ROI". NOT for: building specific agents (use ai-engineer), designing agent behavior patterns (use agentic-patterns), prompt tuning (use prompt-engineer).

curiositech/windags-skills

Fundamental patterns for effective agentic behavior. Teaches decomposition, tool orchestration, error recovery, context management, quality self-assessment, and knowing when to stop. Model-agnostic principles that make any agent more effective regardless of domain. Activate on: "how should I structure this agent", "agentic workflow", "agent patterns", "multi-step task", "tool orchestration", "/agentic-patterns", "decompose this", "agent best practices", "chain of actions", "when should the agent stop", "agent loop design". NOT for: creating agent infrastructure (use agent-creator), building DAGs (use windags-architect), specific tool implementation.

curiositech/windags-skills

Automated discovery and matching of agent skills for dynamic task routing and capability assessment

curiositech/windags-skills

Cryptographic security for agentic systems — zero-trust agent networking, signed message envelopes (JWS/JWE), capability-based security (ocaps), Merkle tree audit trails, WASM sandboxing, and formal verification. Covers CLI dev tool security, mTLS between agents, permission boundaries (least privilege for AI agents), and supply chain security for skills/plugins. Activate on: "agent security", "zero trust agents", "secure agent communication", "capability-based security", "ocap", "signed messages between agents", "agent audit trail", "sandbox agent execution", "agent permissions", "mTLS agents", "cryptographic verification", "agent supply chain", "OWASP agentic", "prove agent did X", "tamper-proof agent logs". NOT for: application-level SAST scanning (use security-auditor), network firewall rules (use infrastructure), SOC2/HIPAA compliance (organizational), or prompt injection defense (use prompt-engineer).

curiositech/windags-skills

Logic-based agent programming language implementing BDI architecture for practical autonomous agent development

curiositech/windags-skills

>- Design AgentSpeak(L)-style BDI agents with context-guarded plans, selection functions, and intention stacks. Use for interruptible autonomy, agent policy, and multi-agent orchestration in dynamic environments. NOT for simple rule engines, static planners, or centralized workflows.

curiositech/windags-skills

Foundational concurrent computation model where actors communicate exclusively through asynchronous message passing

curiositech/windags-skills

Build production-ready LLM applications, advanced RAG systems, and intelligent agents. Implements vector search, multimodal AI, agent orchestration, and enterprise AI integrations. Use PROACTIVELY for LLM features, chatbots, AI agents, or AI-powered applications.

curiositech/windags-skills

license: Apache-2.0 NOT for unrelated tasks outside this domain.

相关技能