-
Notifications
You must be signed in to change notification settings - Fork 458
fix(client): add extra_params option to RestTransport for provider-specific query params (Fixes #1089) #1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,18 +84,29 @@ def _parse_rest_error( | |
|
|
||
| @trace_class(kind=SpanKind.CLIENT) | ||
| class RestTransport(ClientTransport): | ||
| """A REST transport for the A2A client.""" | ||
| """A REST transport for the A2A client. | ||
|
|
||
| Args: | ||
| httpx_client: The async HTTP client to use for requests. | ||
| agent_card: The AgentCard describing the remote agent. | ||
| url: The base URL of the agent. | ||
| extra_params: Optional query parameters to append to every | ||
| request URL. Useful for provider-specific requirements, such | ||
| as ``{'alt': 'sse'}`` for Google A2A API streaming endpoints. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| httpx_client: httpx.AsyncClient, | ||
| agent_card: AgentCard, | ||
| url: str, | ||
| extra_params: dict[str, str] | None = None, | ||
| ): | ||
| """Initializes the RestTransport.""" | ||
| self.url = url.removesuffix('/') | ||
| self.httpx_client = httpx_client | ||
| self.agent_card = agent_card | ||
| self._extra_params = extra_params or {} | ||
|
|
||
| async def send_message( | ||
| self, | ||
|
|
@@ -376,6 +387,7 @@ async def _send_stream_request( | |
| self._handle_http_error, | ||
| self._handle_sse_error, | ||
| json=json, | ||
| params=self._extra_params or None, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The To ensure consistency and correctness, |
||
| **http_kwargs, | ||
| ): | ||
| event: StreamResponse = Parse(sse_data, StreamResponse()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safer to create a copy of the passed
extra_paramsdictionary to prevent any external mutations to the dictionary from unexpectedly affecting the transport's behavior.References