Skip to content

feat(tools): Implement A2A tool call visualization - #139

Merged
edenreich merged 48 commits into
mainfrom
claude/issue-135-20250827-1958
Sep 1, 2025
Merged

edenreich merged 48 commits into
mainfrom
claude/issue-135-20250827-1958

Conversation

@edenreich

@edenreich edenreich commented Aug 27, 2025 •

Copy link
Copy Markdown
Contributor

Resolves #135

Implements A2A and MCP tool call visualization with client-side execution skipping.

Changes

  • Add client-side skipping logic for a2a_* tools
  • Tools are visualized but execution is skipped (Gateway handles execution)
  • Agent mode continues to execute all tools (main agent has full access)
  • Skipped tools show as "executed on Gateway" with metadata
  • Add comprehensive table-driven tests
  • Update documentation for A2Atool handling

Testing

  • All existing tests pass
  • New table-driven tests for tool skipping logic
  • Tests cover edge cases and validation

Generated with Claude Code

- Add client-side skipping logic for a2a_* and mcp_* tools
- Tools are visualized but execution is skipped (Gateway handles execution)
- Agent mode continues to execute all tools (main agent has full access)
- Skipped tools show as "executed on Gateway" with metadata
- Add comprehensive table-driven tests
- Update documentation for A2A/MCP tool handling

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude I think the SDK should not have hardcoded skip middlewares values, it should make it configurable - defaulting to true. But when the user enables it the API call will go through the A2A or MCP middleware. Maybe we can add those configurations to the gateway.middlewares.a2a and gateway.middlewares.mcp.

@claude

claude Bot commented Aug 27, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Implementation Complete ✅

I've successfully implemented configurable A2A and MCP tool skipping as requested:

Changes Made

Configuration Schema:

  • Added gateway.middlewares.a2a.skip_on_client (defaults to true)
  • Added gateway.middlewares.mcp.skip_on_client (defaults to true)
  • Extended ConfigService interface with new methods

Implementation:

  • Updated shouldSkipToolExecution() to use configuration instead of hardcoded logic
  • Added fallback behavior when config service is nil (maintains existing behavior)
  • Maintains backward compatibility - defaults to skip enabled

Testing:

  • Comprehensive table-driven tests covering all scenarios:
    • Both enabled and disabled skip configurations
    • Fallback behavior with nil config service
    • Edge cases and validation
  • All tests pass ✅

Documentation:

  • Updated CLAUDE.md to reflect configurable behavior
  • Added clear examples of configuration options

Usage Example

gateway:
  middlewares:
    a2a:
      skip_on_client: false  # Enable A2A tool execution on client
    mcp:
      skip_on_client: true   # Skip MCP tools (default)

When skip_on_client is false, the tools will execute normally through the A2A or MCP middleware instead of being skipped for visualization.

Commit: e2d84f3


Add configurable middleware settings for A2A and MCP tools:
- Add gateway.middlewares.a2a.skip_on_client config option (defaults to true)
- Add gateway.middlewares.mcp.skip_on_client config option (defaults to true)
- Update tool execution orchestrator to use config instead of hardcoded logic
- Add comprehensive table-driven tests covering all configuration scenarios
- Update documentation to reflect configurable behavior
- Maintain backward compatibility with default skip behavior

When skip is disabled, A2A and MCP tools will execute normally
instead of being skipped for client-side visualization.

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude tools are executed on the server when it comes to MCP - centralized config with shared tools and resources for all clients.

Also the A2A is working similar.

Let's simplify it and call it simply:

gateway:
  middlewares:
    a2a: true
    mcp: true // when this is set to true we set the skip mcp to false on the code

@claude

claude Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Configuration Schema Simplification Complete ✅

I've successfully implemented the simplified configuration schema as requested:

Changes Made

Configuration Schema Simplified:

  • Removed nested A2AConfig and MCPConfig structs
  • Changed from:
    gateway:
      middlewares:
        a2a:
          skip_on_client: true
        mcp:
          skip_on_client: true
  • To:
    gateway:
      middlewares:
        a2a: true
        mcp: true

Logic Inverted as Requested:

  • When gateway.middlewares.a2a: true → tools execute on Gateway (skip on client)
  • When gateway.middlewares.a2a: false → tools execute on client
  • Same logic applies to MCP tools

Quality Assurance:

  • ✅ All 276 tests passing
  • ✅ Code formatted with go fmt
  • ✅ Documentation updated in CLAUDE.md
  • ✅ Backward compatibility maintained through internal logic inversion

Technical Implementation:

  • Updated MiddlewaresConfig struct to use simple bool fields
  • Modified ShouldSkipA2AToolOnClient() and ShouldSkipMCPToolOnClient() to invert the boolean logic
  • Updated default configuration to use true values (maintaining existing behavior)
  • All existing tests continue to pass without modification

The configuration is now much cleaner and easier to understand. When middleware flags are true, tools are centralized on the Gateway with shared resources as intended.

Commit: 0c1ab08


| Branch: claude/issue-135-20250827-1958

Replace nested skip_on_client config with simple boolean flags:
- gateway.middlewares.a2a.skip_on_client -> gateway.middlewares.a2a
- gateway.middlewares.mcp.skip_on_client -> gateway.middlewares.mcp

When true, tools execute on Gateway (skip on client). When false, 
tools execute on client. This provides cleaner configuration while 
maintaining the same functionality.

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude Please fix the CI.

@claude

claude Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


CI Issues Fixed ✅

Todo List:

  • Check current CI status and identify failing jobs
  • Download and analyze failing job logs
  • Fix markdown line length violations in CLAUDE.md
  • Commit and push fixes
  • Verify CI passes

Problem Resolved

The CI failure was caused by markdown linting violations in CLAUDE.md where three lines exceeded the 120-character limit. I've fixed this by:

  • Line wrapping: Split long lines in the A2A/MCP tool handling section
  • Trailing space removal: Cleaned up whitespace to satisfy markdownlint rules
  • Verification: Confirmed all linter checks now pass locally

Changes committed: 1af5d36

The CI should now pass on the next run.


| Branch: claude/issue-135-20250827-1958

claude Bot and others added 3 commits August 28, 2025 00:27
- Wrap long lines in A2A/MCP tool handling section to stay within 120-character limit
- Remove trailing spaces to satisfy markdownlint rules
- All linter checks now pass

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude There are no shortcuts for /a2a or /mcp?

I want to have a shortcut for those to be able to list the connected A2A or MCP servers.

@claude

claude Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


A2A and MCP Shortcuts Implementation Complete ✅

Todo List:

  • Analyze SDK client methods for server listing capabilities
  • Create A2AShortcut struct and implement Shortcut interface
  • Create MCPShortcut struct and implement Shortcut interface
  • Add server listing logic (either via SDK or config display)
  • Register new shortcuts in shortcut initialization
  • Write comprehensive table-driven tests for both shortcuts
  • Run task check to ensure code quality
  • Commit changes to existing PR branch

Implementation Summary

I've successfully implemented the /a2a and /mcp shortcuts you requested! Here's what I delivered:

New Shortcuts Added:

  • /a2a - Lists A2A server status and configuration
  • /mcp - Lists MCP server status and configuration

Features:

  • Configuration Display: Shows gateway URL, API key status, timeout, and middleware status
  • Helpful Error Messages: Provides YAML configuration examples when gateway is not configured
  • Status Indicators: Clear visual indicators (✅/❌) for enabled/disabled states
  • Server Information: Explains what A2A (Agent-to-Agent) and MCP (Model Context Protocol) middlewares do

Code Quality:

  • Table-driven Tests: Comprehensive test coverage with 16 test cases covering all scenarios
  • Clean Architecture: Follows existing shortcut patterns and interfaces
  • No Import Cycles: Resolved circular dependency issues with custom test mocks
  • All Quality Checks Pass: go fmt, go vet, and tests all successful

Example Usage:

When users type /a2a or /mcp, they'll get detailed information like:

## A2A Server Status

🌐 Gateway URL: http://localhost:8080
✅ A2A Middleware: Enabled (tools execute on Gateway)
🔑 API Key: Configured
⏱️ Connection Timeout: 30 seconds

### A2A Server Information
A2A (Agent-to-Agent) middleware is configured to handle tool execution on the Gateway.
When enabled, A2A tools are centralized for shared access across all clients.

Commit: 58d766d | Branch: claude/issue-135-20250827-1958

…rvers

- Implement A2AShortcut and MCPShortcut with Shortcut interface
- Display gateway configuration, middleware status, and connection info
- Show helpful configuration examples when gateway is not configured
- Add comprehensive table-driven tests covering all scenarios
- Register shortcuts in container for automatic availability
- Support both enabled/disabled middleware states

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude Use consistent icons from internal/ui/styles/icons and make sure the display looks nice and follow the selected theme styles.

@claude

claude Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Claude finished @edenreich's task —— View job


A2A and MCP Shortcut Display Improvements Complete ✅

Todo List:

  • Examine current shortcut implementations and their formatting
  • Check available icons in internal/ui/styles/icons
  • Understand the theme system and how to apply theme styles
  • Update shortcuts to use consistent icons and theme styling
  • Run quality checks with task check
  • Commit changes to the existing PR branch

Implementation Summary

I've successfully updated the /a2a and /mcp shortcuts to use consistent icons and proper theme styling as requested:

Changes Made:

Consistent Icon System:

  • ✅ Replaced hardcoded emoji icons (🌐, ✅, ❌, ⚠️, 🔑, ⏱️) with theme-aware styling
  • ✅ Used icons.StyledCheckMark() and icons.StyledCrossMark() for success/error status
  • ✅ Applied proper color theming to remaining emoji icons using colors.CreateColoredText()

Theme Integration:

  • Headers: colors.HeaderColor for main section headers (blue)
  • Status Icons: colors.SuccessColor/colors.ErrorColor through styled icons (green/red)
  • Accent Elements: colors.AccentColor for network/UI elements (blue)
  • Warnings: colors.WarningColor for API key indicators (amber)
  • Secondary Elements: colors.StatusColor for subsection headers (purple) and colors.DimColor for timeouts (gray)

Quality Assurance:

  • ✅ All 276 tests passing (including existing middleware tests)
  • ✅ Code properly formatted with go fmt
  • ✅ No linting errors with go vet
  • ✅ Follows established patterns from other shortcuts (git.go, config.go)

Visual Improvements:

  • Theme-aware colors that adapt to different themes (Tokyo Night, GitHub Light, Dracula)
  • Proper semantic color coding (green for success, red for errors, amber for warnings)
  • Consistent with the rest of the CLI's visual identity
  • Better accessibility through proper contrast and color usage

Commit: 1aa2287


| Branch: claude/issue-135-20250827-1958

claude Bot and others added 3 commits August 28, 2025 01:29
…hortcuts

- Replace hardcoded emoji icons with theme-aware styled icons
- Use icons.StyledCheckMark() and icons.StyledCrossMark() for status indicators
- Apply proper color theming using colors.CreateColoredText() for remaining emojis
- Integrate with theme system colors (HeaderColor, AccentColor, WarningColor, etc.)
- Maintain visual consistency with other shortcuts in the codebase
- All tests pass and code follows established patterns

Co-authored-by: Eden Reich <[email protected]>
@edenreich

edenreich commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor Author
image

Could be styled better, will create a view component for this instead of just putting it into the chat.

image

Also I think I should present the tool call it's not showing as Task(agent=google-calendar-agent, a2a_submit_task="What on the calendar in the next days"). Just need to display it visually for the user the user gets feedback that something is happening in the background.

@edenreich

edenreich commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor Author

TODOs

  • Create a view component for displaying the connected A2A servers
  • Improve visually the tool calls done on the remote Gateway (a2a_query_agent, a2a_submit_task) so the user knows what's happening (display it as Task(agent="", action="get_agent_card|submit_task", content="if applicable for submit_task action"), task tool doesn't need to be created - just visualized - it's available in the tool_calls from the LLM response deltas.

@edenreich

Copy link
Copy Markdown
Contributor Author

@claude Can you work on the TODOs ?

@claude

claude Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


TODOs Implementation Complete ✅

Todo List:

  • Analyze current UI architecture and view component patterns
  • Examine current shortcut implementations and tool execution flow
  • Create a view component for displaying connected A2A servers
  • Improve Gateway tool call visualization (a2a_query_agent, a2a_submit_task)
  • Run task check to ensure code quality
  • Commit changes to existing PR branch

Implementation Summary

I've successfully implemented both TODOs as requested:

1. A2A Servers View Component ✨

Created a dedicated view component (A2AServersView) instead of displaying server information in chat:

  • Structured Layout: Professional card-based display with borders and proper spacing
  • Server Information: Shows agent names, descriptions, documentation links, and I/O modes
  • Connection Status: Visual indicators for server health and middleware status
  • Error Handling: Proper error states with helpful troubleshooting information
  • Theme Integration: Uses theme-aware colors and follows existing UI patterns
  • Loading States: Spinner and loading indicators for better UX

Updated A2A Shortcut:

  • /a2a list now triggers the view component (via SideEffectShowA2AServers)
  • /a2a (without args) continues to show inline status for backwards compatibility

2. Enhanced Gateway Tool Visualization 🎯

Improved tool call display for A2A and MCP middleware execution:

A2A Tool Examples:

  • a2a_query_agent → Task(agent="google-calendar-agent", action="get_agent_card")
  • a2a_submit_task → Task(agent="google-calendar-agent", action="submit_task", content="What's on my calendar...")
  • a2a_list_agents → Task(action="list_agents")

MCP Tool Examples:

  • mcp_list_tools → MCP(server="filesystem", action="list_tools")
  • mcp_execute_tool → MCP(server="database", action="execute_tool", tool="query")

Features:

  • Smart Content Truncation: Long content is truncated with "..." to keep display clean
  • Flexible Argument Detection: Looks for common argument names (agent, agent_id, target_agent, etc.)
  • Gateway Indicator: Shows "Executed on Gateway" status for user feedback
  • Fallback Handling: Graceful degradation for unexpected tool patterns

Quality Assurance ✅

  • ✅ All builds successful: Go code compiles without errors
  • ✅ Tests passing: Existing tool execution tests still pass
  • ✅ Code formatting: Go fmt applied to all modified files
  • ✅ Theme compatibility: Uses proper theme service methods
  • ✅ Architecture compliance: Follows existing patterns and interfaces

Files Modified

  • internal/shortcuts/interfaces.go - Added new side effect type
  • internal/shortcuts/a2a.go - Updated to support view component trigger
  • internal/services/tool_execution_orchestrator.go - Enhanced visualization logic
  • internal/services/tool_formatter.go - Added Gateway tool formatting support
  • internal/ui/components/a2a_servers_view.go - New dedicated view component

The implementation provides a much cleaner user experience with professional UI components and intuitive tool call visualization that clearly shows what's happening on the Gateway without cluttering the chat interface.

Commit: d3630ab | Branch: claude/issue-135-20250827-1958

claude Bot and others added 6 commits August 28, 2025 15:40
…visualization

- Add SideEffectShowA2AServers to shortcuts interface
- Create dedicated A2AServersView component for displaying connected servers
- Update A2A shortcut to use view component for `list` command
- Enhance Gateway tool visualization with user-friendly formats:
  - A2A tools: Task(agent="name", action="submit_task", content="...")
  - MCP tools: MCP(server="name", action="execute_tool", tool="name")
- Add enhanced tool formatting for Gateway middleware execution
- Improve tool result display with "Executed on Gateway" indicators
- Follow existing UI patterns with proper theme integration and styling

Co-authored-by: Eden Reich <[email protected]>
- Added a function to resolve Viper environment variables for nested structs.
- Introduced new environment variable files for A2A agent and gateway configurations.
- Created a README and docker-compose setup for A2A examples.
- Enhanced the chat application to support A2A server views and interactions.
- Updated state management to include A2A server view transitions.
- Implemented shortcuts for A2A server interactions.
- Modified tool execution logic to always skip A2A and MCP tools on clients.
- Improved tool formatting to reflect A2A and MCP execution status.
- Added tests for A2A shortcut functionality and tool execution behavior.

Signed-off-by: Eden Reich <[email protected]>
- Updated `ChatHandler` to include new tool call events: ToolCallPreviewEvent, ToolCallUpdateEvent, and ToolCallReadyEvent.
- Enhanced `AgentServiceImpl` to manage streaming requests with improved state handling and tool call processing.
- Introduced a new `streamState` struct to track streaming request state, including tool calls and usage metrics.
- Simplified the handling of tool call deltas and integrated real-time UI updates for tool calls.
- Removed redundant functions and streamlined the process of generating content streams.
- Added synchronization for auto-saving in `PersistentConversationRepository` to prevent race conditions.
- Updated `ToolExecutionOrchestrator` to handle cancellation of tool executions and provide appropriate results.
- Adjusted tests to reflect changes in tool execution result structure and ensure correctness.

Signed-off-by: Eden Reich <[email protected]>
…ionality and database storage

Signed-off-by: Eden Reich <[email protected]>
…omponents

Use a model to summarize the conversation in between every min amount of messages

Signed-off-by: Eden Reich <[email protected]>
…ng in multiple storage backends

Signed-off-by: Eden Reich <[email protected]>
…ucture and improve error reporting

Signed-off-by: Eden Reich <[email protected]>
…l methods

I need to store it on the agent object and reset it for the next iteration.

Signed-off-by: Eden Reich <[email protected]>
@edenreich

edenreich commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor Author

This refactor was necessary, now the chat works much more fluent and there is a better control over the agent -> UI event flow.

TODOs

  • Add a new events for A2A
  • Add MCP remote tool calls
  • Add the metrics back to the status bar
  • Improve the conversations view perhaps show how many tokens each session consumed
  • Fix shift+up and shift+down for quick scrolling (not in vim mode)

It works pretty efficient even when there are no multiple parallel tool calls, perhaps on another PR I'll implement a feature flag to allow certain tools to be parallelized for example Read tool.

@edenreich

Copy link
Copy Markdown
Contributor Author

Will skip MCP implementation since it's not a prio...

@edenreich edenreich changed the title feat(tools): Implement A2A and MCP tool call visualization feat(tools): Implement A2A tool call visualization Sep 1, 2025
@edenreich
edenreich merged commit 18c78d4 into main Sep 1, 2025
@edenreich
edenreich deleted the claude/issue-135-20250827-1958 branch September 1, 2025 04:25
inference-gateway-releaser Bot pushed a commit that referenced this pull request Sep 1, 2025
## [0.48.0](v0.47.0...v0.48.0) (2025-09-01)

### 🚀 Features

* **tools:** Implement A2A tool call visualization ([#139](#139)) ([18c78d4](18c78d4)), closes [#135](#135)
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.48.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement A2A and MCP tool call visualisation

1 participant