-
Notifications
You must be signed in to change notification settings - Fork 34
fix(agentgateway): guard mcp list_tools null responses #226
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
Open
tiagoek
wants to merge
14
commits into
main
Choose a base branch
from
fix/agentgateway-list-tools-none-guard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
83c5dae
fix(agentgateway): guard list_tools None response in LoB flow
tiagoek 6d63e65
chore: bump version to 0.35.1 and format test_lob.py
tiagoek 9977ebf
fix(agentgateway): extend None guard to customer flow and address rev…
tiagoek e260431
fix(agentgateway,telemetry): MCP OTel unwrap and LoB 403 hint
tiagoek 0fc99d3
docs(agentgateway,telemetry): document MCP LoB troubleshooting and au…
tiagoek 6b398fc
fix(agentgateway,telemetry): fix user-guide eof and 403 log noise
tiagoek aa08f9c
fix(agentgateway): justify fragment skip exception handling (py-el-02)
tiagoek bd58a2c
fix(agentgateway): document intentional fragment skip (py-el-02)
tiagoek 28c63d8
fix(agentgateway): comment non-403 fragment skip path (py-el-02)
tiagoek 4eb8965
fix(agentgateway): document httpx fragment skip (py-el-02)
tiagoek a473774
fix(telemetry): drop MCP unwrap from auto_instrument
tiagoek 9f837a9
chore: ruff format auto_instrument after unwrap removal
tiagoek b71d7e2
Add PY-EL-02 sdk-review suppression for fragment tool-list handler.
tiagoek d20b8db
fix(agentgateway): address review feedback on logs and docs
tiagoek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,6 +325,14 @@ async def list_server_tools( | |
| else fragment_name | ||
| ) | ||
| result = await session.list_tools() | ||
| if result is None or result.tools is None: | ||
| logger.warning( | ||
| "list_tools() returned no tools (response=%r); fragment %r skipped — " | ||
| "check MCP server health and OpenTelemetry MCP instrumentation", | ||
| result, | ||
| fragment_name, | ||
| ) | ||
| return [] | ||
| return [ | ||
| MCPTool( | ||
| name=t.name, | ||
|
|
@@ -388,12 +396,35 @@ async def get_mcp_tools_lob( | |
| len(server_tools), | ||
| fragment_name, | ||
| ) | ||
| # intentional: fragment failure must not abort remaining fragments | ||
| # (HTTPStatusError: 403 → warning + continue; other status → exception log + skip) | ||
| except httpx.HTTPStatusError as exc: | ||
| if exc.response.status_code == 403: | ||
| logger.warning( | ||
| "HTTP 403 listing tools from fragment '%s' with system token — " | ||
| "pass user_token to list_mcp_tools() for user-scoped tool discovery", | ||
| fragment_name, | ||
| ) | ||
| continue | ||
| logger.exception( | ||
| "Failed to load tools from fragment '%s' — skipping", | ||
| fragment_name, | ||
| ) | ||
| # intentional: fragment failure must not abort remaining fragments | ||
| # (unexpected errors → exception log + skip) | ||
| except Exception: | ||
|
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. This should still be executed if all fragments fail to load. And who requested this behaviour? |
||
| logger.exception( | ||
| "Failed to load tools from fragment '%s' — skipping", | ||
| fragment_name, | ||
| ) | ||
|
|
||
| if fragments and not tools: | ||
| logger.warning( | ||
| "No MCP tools loaded from %d fragment(s) for tenant '%s'", | ||
| len(fragments), | ||
| tenant_subdomain, | ||
| ) | ||
|
|
||
| logger.info("Loaded %d MCP tool(s) from %d fragment(s)", len(tools), len(fragments)) | ||
| return tools | ||
|
|
||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Why review OTel instrumentation?