feat(agentgateway): enrich AGW execution flow logs - #292
Open
ricardosrib wants to merge 5 commits into
Open
Conversation
cassiofariasmachado
previously approved these changes
Aug 28, 2026
| body = None | ||
| rpc_error = JsonRpcError.parse(body) if body else None | ||
| if rpc_error: | ||
| logger.error( |
Contributor
There was a problem hiding this comment.
Just to confirm, is this the logger from core that Jean implemented?
Contributor
Author
There was a problem hiding this comment.
This is plain logger from the Python standard library
Contributor
There was a problem hiding this comment.
We should use the one from our telemetry module, can you check?
Contributor
Author
There was a problem hiding this comment.
Are you referring to _provider.py? That's only needed when you want these logs to flow through OTel rather than just printing to the console. What's the expected logging behavior here?
Contributor
|
Great work! |
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.
Description
Improves error logging in the Agent Gateway MCP client.
1. Add
JsonRpcError.parsefor HTTP error bodiesWhen AGW returns a non-2xx response with a JSON-RPC body, the error code and message are now extracted and shown inline instead of dumping the raw response text.
2. Guard
exc.response.textwithtry/except httpx.ResponseNotReadstreamable_http_clientcallsraise_for_status()before buffering the response body. Accessing.textin that state raisedResponseNotRead, crashing the SDK with no error log produced.3. Add
McpErrorbranch to_log_mcp_server_errorAGW returns HTTP 200 with a JSON-RPC error in the SSE body for protocol-level failures. The MCP client surfaces these as
McpError, which previously fell through to the genericelsebranch and logged only— skippingwith no error details.4. Improve
elsebranchThe exception type and message are now included on the log line itself. The full traceback is still attached via
exc_info.5. Add URL to tool warnings/errors in
call_mcp_tool_lobandcall_mcp_tool_customer6. Log
User auth token obtainedat INFO in all threeget_user_authreturn pathsConfirms the token was successfully obtained and consumed across the customer and LoB flows.
7. Remove duplicate
get_user_authcall inlist_mcp_toolsLoB branchThe LoB branch was calling
get_user_authtwice, causing a redundant duplicate INFO log per invocation.8. Replace implicit duplicate
get_user_authincall_mcp_toolLoB branch with an explicit errorRaises
AgentGatewaySDKErrorwhenuser_tokenis missing, making the requirement explicit instead of relying on a side-effect call.Logs before/after
1. HTTPStatusError + JSON-RPC body
2. HTTPStatusError + plain body
3. HTTPStatusError + ResponseNotRead
4. McpError
5. BaseExceptionGroup wrapping McpError
6. Else branch (unexpected exception)
Type of Change
How to Test
User auth token obtained — gateway: '<url>'appears exactly once at INFO level.JSON-RPC -32600: <message>instead of— skipping._log_mcp_server_errorbranches, import and call it directly withhttpx.HTTPStatusError,McpError, and a genericRuntimeError— each should produce a distinct, self-contained ERROR log line.