Skip to content

fix: Improve validation logic for task handler configuration#98

Merged
edenreich merged 1 commit intomainfrom
fix/validate-task-handler-configurations-during-runtime
Oct 11, 2025
Merged

fix: Improve validation logic for task handler configuration#98
edenreich merged 1 commit intomainfrom
fix/validate-task-handler-configurations-during-runtime

Conversation

@edenreich
Copy link
Copy Markdown
Contributor

Summary

Improves the task handler validation logic in A2AServerBuilder to provide more flexible configuration while maintaining proper validation based on agent capabilities.

Problem

The previous validation logic was too strict - it always required a background task handler to be configured, even when streaming was enabled. This prevented valid configurations where only a streaming handler was needed.

Solution

The validation now follows a three-step approach:

  1. Check if at least one handler exists: First validates that either a polling or streaming task handler is configured
  2. Validate streaming requirements: If streaming is enabled in agent capabilities, ensure a streaming handler is configured
  3. Validate background requirements: If streaming is not enabled, ensure a background/polling handler is configured

Changes

server/server_builder.go:322-342

  • First checks if both handlers are nil → returns general error message
  • Then checks streaming-specific requirements
  • Finally checks background-specific requirements
  • Provides clear, actionable error messages for each case

server/server_builder_test.go:431

  • Updated test assertion to expect the new general error message when no handlers are configured

Benefits

  • ✅ Allows streaming-only configurations when appropriate
  • ✅ Allows background-only configurations when streaming is disabled
  • ✅ Provides clear, context-specific error messages
  • ✅ Maintains backward compatibility with existing code

Test Plan

All existing tests pass, including:

  • TestA2AServerBuilder_Build_RequiresTaskHandlers - validates all error cases
  • Tests for streaming-only and background-only configurations
  • Tests for invalid configurations

🤖 Generated with Claude Code

Signed-off-by: Eden Reich <eden.reich@gmail.com>
@edenreich edenreich merged commit 34d6354 into main Oct 11, 2025
1 check passed
@edenreich edenreich deleted the fix/validate-task-handler-configurations-during-runtime branch October 11, 2025 14:50
ig-semantic-release-bot bot added a commit that referenced this pull request Oct 11, 2025
## [0.14.0](v0.13.1...v0.14.0) (2025-10-11)

### ✨ Features

* Add the callbacks ready to be used by the agent ([#94](#94)) ([84632f3](84632f3))
* **types:** Refactor Part deserialization to use concrete types ([#104](#104)) ([22d192e](22d192e)), closes [#102](#102)

### ♻️ Improvements

* Consolidate the logic of the agent and remove redundancy ([#93](#93)) ([54e5e71](54e5e71))
* **docker-compose:** Remove port mappings for server service to avoid confusion ([3df7b08](3df7b08))
* **server:** Remove handler duplication between A2AServerImpl and DefaultA2AProtocolHandler ([#101](#101)) ([75b9c20](75b9c20))

### 🐛 Bug Fixes

* Improve validation logic for task handler configuration ([#98](#98)) ([34d6354](34d6354))

### 👷 CI

* Add Prettier setup and formatting steps for Go and markdown files ([#105](#105)) ([f2a1994](f2a1994))

### 📚 Documentation

* **examples:** Add input-required flow examples ([#96](#96)) ([17764f3](17764f3))

### 🔧 Miscellaneous

* **deps:** Update claude-code to 2.0.8 and install gh cli version 2.81.0 in flox environment ([4d6e41a](4d6e41a))
@ig-semantic-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant