Skip to content

fix: support custom headers for A2A agents#3406

Open
TannyXie wants to merge 1 commit into
ModelEngine-Group:developfrom
TannyXie:hotfix/3244-a2a-custom-headers
Open

fix: support custom headers for A2A agents#3406
TannyXie wants to merge 1 commit into
ModelEngine-Group:developfrom
TannyXie:hotfix/3244-a2a-custom-headers

Conversation

@TannyXie

Copy link
Copy Markdown

Summary

  • persist and pass custom headers for A2A agent calls
  • add frontend fields and service wiring for custom headers
  • cover A2A HTTP client and proxy header propagation

Fixes #3244

Tests

  • Not run in this PR preparation step.

Copilot AI review requested due to automatic review settings July 11, 2026 14:13
@TannyXie TannyXie requested review from Dallas98 and WMC001 as code owners July 11, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_headers for 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")
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