fix: support custom headers for A2A agents#3406
Open
TannyXie wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end support for per-external-agent custom HTTP headers in A2A calls, including persistence in the backend DB, propagation through the backend HTTP client/service layer, SDK agent proxy support, and frontend UI/service wiring to edit these settings.
Changes:
- Persist
custom_headersfor external A2A agents (DB schema + API endpoint) and pass them through backend A2A calls. - Extend SDK A2A agent models/proxy to carry and apply
custom_headers. - Add frontend API/service methods and UI controls to edit custom headers, plus tests for header building/propagation.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/sdk/core/agents/test_a2a_agent_proxy.py | Adds assertions for default/custom custom_headers in SDK agent info conversion. |
| test/backend/utils/test_a2a_http_client.py | Adds unit test coverage for merging custom headers into A2A request headers. |
| test/backend/services/test_a2a_client_service.py | Updates expectations for build_a2a_headers(..., custom_headers=None) call signature. |
| sdk/nexent/core/agents/agent_model.py | Adds custom_headers to external agent config model and maps it into A2AAgentInfo. |
| sdk/nexent/core/agents/a2a_agent_proxy.py | Applies custom_headers when building outbound request headers for SDK proxy calls. |
| frontend/services/api.ts | Adds a new REST endpoint helper for updating agent settings. |
| frontend/services/a2aService.ts | Adds custom_headers to types and implements updateAgentSettings service call. |
| frontend/app/[locale]/agents/components/a2a/A2AAgentDiscoveryModal.tsx | Adds UI for editing custom headers JSON and wiring to update protocol + settings. |
| deploy/sql/migrations/v2.3.0_0702_add_a2a_call_settings.sql | Adds custom_headers JSONB column to external agent table. |
| backend/utils/a2a_http_client.py | Extends build_a2a_headers to accept and merge custom_headers. |
| backend/services/a2a_client_service.py | Reads custom_headers from DB agent record and passes them into request header builder. |
| backend/database/db_models.py | Adds custom_headers column to the ORM model for external A2A agents. |
| backend/database/a2a_agent_db.py | Persists and validates custom_headers and returns them in agent DTOs. |
| backend/apps/a2a_client_app.py | Adds /agents/{id}/settings endpoint and request model for updating call settings. |
| backend/agents/create_agent_info.py | Includes custom_headers when building external agent config from DB records. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+534
to
+541
| for key, value in custom_headers.items(): | ||
| header_name = str(key).strip() | ||
| if not header_name: | ||
| raise ValueError("custom header names cannot be empty") | ||
| if any(ch in header_name for ch in "\r\n:"): | ||
| raise ValueError(f"invalid custom header name: {header_name}") | ||
| sanitized[header_name] = str(value) | ||
| return sanitized |
Comment on lines
+563
to
+565
| if custom_headers is not None: | ||
| setattr(agent, "custom_headers", sanitized_headers) | ||
| agent.updated_by = user_id |
Comment on lines
+49
to
+54
| class UpdateAgentCallSettingsRequest(BaseModel): | ||
| """Request to update call settings for an external A2A agent.""" | ||
| custom_headers: Optional[Dict[str, str]] = Field( | ||
| default=None, | ||
| description="Custom HTTP headers to include when calling the agent" | ||
| ) |
Comment on lines
143
to
+147
| setSaving(true); | ||
| onProtocolChange(String(agent.id), selectedProtocol); | ||
| const saved = await onSettingsChange(String(agent.id), { | ||
| protocolType: selectedProtocol, | ||
| customHeaders: parsedHeaders, | ||
| }); |
| protocol_type = Column(String(20), default=PROTOCOL_JSONRPC, | ||
| doc="Protocol type for calling this agent") | ||
|
|
||
| custom_headers = Column(JSON, doc="Custom HTTP headers for calling this agent") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3244
Tests