Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added file data part and data data part to a2a agents
  • added support for generic .well-known path that adheres to the A2A protocol

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 14, 2026 4:59am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 14, 2026

Greptile Summary

This PR enhances A2A agent communication by adding support for DataPart and FilePart message components, enabling agents to send structured data and files alongside text messages. The implementation also adds generic .well-known/agent.json path support with fallback to Sim Studio's root URL agent card discovery for backward compatibility.

Key Changes:

  • Added data (JSON) and files (array) parameters to a2a_send_message tool
  • Implemented proper parsing of data URIs for base64-encoded files and URL references
  • Enhanced error handling with try-catch blocks around client creation and message sending
  • Removed streaming-specific tool and route (likely consolidated into main implementation)
  • Updated UI blocks and documentation to expose new capabilities

Issues Found:

  • Data URI parsing logic has a bug where non-matching data URIs are not handled (line 111-117 in send-message route)

Confidence Score: 4/5

  • Safe to merge after fixing the data URI parsing bug
  • The PR implements well-structured A2A protocol enhancements with proper type safety and error handling. One logical bug exists in the data URI parsing that could cause incorrect file handling for malformed data URIs. The .well-known fallback implementation is sound. Removal of streaming tool appears intentional and clean.
  • apps/sim/app/api/tools/a2a/send-message/route.ts requires the data URI parsing fix

Important Files Changed

Filename Overview
apps/sim/app/api/tools/a2a/send-message/route.ts Added support for DataPart and FilePart in A2A messages with proper error handling and data URI parsing
apps/sim/lib/a2a/utils.ts Implemented fallback logic for agent card discovery supporting both standard A2A path and Sim Studio compatibility
apps/sim/tools/a2a/types.ts Added type definitions for A2ASendMessageFileInput to support file and data parameters in messages
apps/sim/blocks/blocks/a2a.ts Added UI configuration for data and files fields in A2A send message block

Sequence Diagram

sequenceDiagram
    participant Client
    participant SendMessageAPI
    participant A2AUtils
    participant A2AClient
    participant ExternalAgent

    Client->>SendMessageAPI: POST /api/tools/a2a/send-message
    Note over Client,SendMessageAPI: {agentUrl, message, data, files, apiKey}
    
    SendMessageAPI->>SendMessageAPI: Validate request (Zod schema)
    SendMessageAPI->>SendMessageAPI: Parse data field (JSON)
    SendMessageAPI->>SendMessageAPI: Process files (URL/base64)
    
    SendMessageAPI->>A2AUtils: createA2AClient(agentUrl, apiKey)
    A2AUtils->>ExternalAgent: GET /.well-known/agent.json
    alt Standard A2A path succeeds
        ExternalAgent-->>A2AUtils: Agent card
    else Standard path fails
        A2AUtils->>ExternalAgent: GET {agentUrl} (root URL)
        ExternalAgent-->>A2AUtils: Agent card
    end
    A2AUtils-->>SendMessageAPI: A2A Client
    
    SendMessageAPI->>SendMessageAPI: Build Message with Parts
    Note over SendMessageAPI: TextPart + DataPart + FilePart[]
    
    SendMessageAPI->>A2AClient: sendMessage({message})
    A2AClient->>ExternalAgent: Send A2A message
    
    alt Response is Message
        ExternalAgent-->>A2AClient: Message response
        A2AClient-->>SendMessageAPI: Message object
        SendMessageAPI->>SendMessageAPI: Extract text content
        SendMessageAPI-->>Client: {content, taskId, state: "completed"}
    else Response is Task
        ExternalAgent-->>A2AClient: Task response
        A2AClient-->>SendMessageAPI: Task object
        SendMessageAPI->>SendMessageAPI: Extract last agent message
        SendMessageAPI-->>Client: {content, taskId, state, artifacts, history}
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (3)

  1. apps/sim/app/api/tools/a2a/send-message-stream/route.ts, line 65-72 (link)

    logic: message construction doesn't include DataPart and FilePart logic that was added to non-streaming endpoint

    The implementation needs to match /api/tools/a2a/send-message/route.ts lines 78-136

  2. apps/sim/app/api/tools/a2a/send-message-stream/route.ts, line 20-26 (link)

    logic: streaming endpoint missing data and files support

    The schema needs to be updated to match the non-streaming endpoint (/api/tools/a2a/send-message/route.ts lines 13-28). Add FileInputSchema, and include data and files fields in the validation schema.

  3. apps/sim/tools/a2a/send_message_stream.ts, line 10-33 (link)

    logic: tool params missing data and files fields that were added to a2aSendMessageTool

16 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 4b026ad into staging Jan 14, 2026
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/a2a branch January 14, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants