Repository navigation
Fixes #7951: Add bounded local and remote MCP resource admission - #8095
BobSong-dev wants to merge 67 commits into
Conversation
…ateway-p105 # Conflicts: # shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/AgentGatewayPlugin.java # shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpHttpHandler.java # shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java # shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…audit-7950-integration
…resource-admission-7951
|
Thanks for your review. But it depends on the forward PR.so it caused failure. |
…resource-admission-7951 # Conflicts: # shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java
Aias00
left a comment
There was a problem hiding this comment.
Large but well-organized PR. Three coherent areas:
- Agent resource admission -
AgentMcpResourceAdmission/AgentResourceAdmissionenforce allow-lists (mirroring the existing tool/path admission model) and integrate intoAgentMcpDispatcherandAgentMcpHttpHandler. - AI proxy observability -
AiRequestObservation,AiUpstreamUsageTap,AiObservationSupport, outbound trace context, and Prometheus collectors (AgentAdmissionMetricsCollector,AgentCatalogMetricsCollector,AgentRuntimeMetricsReporter) extend the metrics story. - Audit bridge -
AgentInvocationAuditBridgecomposes an optional audit sink with the existing observers without altering traffic, swallowing sink failures.
The audit safely() wrapping and the decision/reason mapping in emit() are sensible.
Coordination needed:
- This PR and #7669 both modify
AgentMcpDispatcher.java(resource path). They should be merged in sequence; #7669 first if it carries the base resource dispatcher, then rebase #8095. Please confirm the merge order and resolve any dispatcher conflicts. AiProxyApiKeyServiceImpl.convertnow returnsid; verify the admin UI/serialization expects the key id field.
Approving the design; please coordinate the #7669/#8095 ordering.
…to integration/agent-gateway-p105 # Conflicts: # .github/scripts/test-agent-gateway-migrations.py # shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java # shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java # shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
|
Hi @BobSong-dev, this PR was approved, but the squash-merge could not be completed because it now has merge conflicts. This PR and #7669 both modify Please rebase your branch onto the latest |
…nt-gateway-audit-7950-integration # Conflicts: # shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpDispatcher.java # shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpExecutionContext.java # shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpHttpHandler.java # shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java # shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPluginTest.java # shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java # shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java # shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-ai-proxy/src/main/java/org/apache/shenyu/springboot/starter/plugin/ai/proxy/AiProxyPluginConfiguration.java
…nt-gateway-audit-7950-integration # Conflicts: # shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java # shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…n/admission-publication-20261105
…n/admission-publication-20261105
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8095 +/- ##
=============================================
+ Coverage 61.49% 72.26% +10.77%
- Complexity 8818 18871 +10053
=============================================
Files 1261 1812 +551
Lines 39273 70642 +31369
Branches 3725 8361 +4636
=============================================
+ Hits 24151 51052 +26901
- Misses 12952 15312 +2360
- Partials 2170 4278 +2108
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
FINAL synthesis of PR #8095 (apache/shenyu) at head ab421f7. Cross-file review of 37 partitions (complete_diff true, CI passed) shows all_parts_passed=false due to two child NEEDS_CHANGES with HIGH defects: missing AtomicInteger import in AgentToolRegistryTest.java (part-17) and incorrect audit target assertion in AgentInvocationAuditBridgeTest.java (part-7). No other cross-file blockers identified. Verdict NEEDS_CHANGES.
Evidence
- part-17 blocking finding: AtomicInteger used but not imported (line 61, RIGHT, HIGH)
- part-7 blocking finding: assertion expects target 'fallback' but observation context 'one' has no target (line 60, RIGHT, HIGH)
- FINAL synthesis: all_parts_passed=false, complete_diff=true, CI passed=true, head ab421f7
Recommended next steps
- Add missing import java.util.concurrent.atomic.AtomicInteger in shenyu-plugin/shenyu-plugin-agent-gateway/src/test/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentToolRegistryTest.java
- Fix incorrect target assertion at line 60 of shenyu-common/src/test/java/org/apache/shenyu/common/audit/AgentInvocationAuditBridgeTest.java to align with observation context
- Re-run CI and partition reviews after test fixes
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 52bc6ca4-a601-4f4b-9dae-26878243c2ca · Commit: ab421f7f4bb219a495e371ed7e28f956541e453d
Review verdict: NEEDS_CHANGES
SYNTHESIS/FINAL: Assessed all 37 child partition summaries. Global complete_diff=true, CI passed=true, but all_parts_passed=false because part-17 and part-7 returned NEEDS_CHANGES with anchored HIGH defects. Per rules, child NEEDS_CHANGES cannot be overridden to PASS. The defects are concrete: missing import causing compilation failure and incorrect test assertion contradicting sibling tests. No other cross-file blockers evident. Therefore FINAL verdict is NEEDS_CHANGES.
Publication: REQUEST_CHANGES (VERIFIED_BLOCKING_FINDINGS)
- shenyu-plugin/shenyu-plugin-agent-gateway/src/test/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentToolRegistryTest.java:61 [RIGHT] AtomicInteger is used but not imported; missing 'import java.util.concurrent.atomic.AtomicInteger;' will cause compilation failure of the test.
- shenyu-common/src/test/java/org/apache/shenyu/common/audit/AgentInvocationAuditBridgeTest.java:60 [RIGHT] Assertion expects logical audit record (records.get(2)) to have target "fallback", but observation was created with context("one") without a target; attempt targets are set on separate attempt contexts. This contradicts sibling tests where logical target derives from observation context, likely causing test failure or wrong contract enforcement.
Review details
Recommendation: Do not merge until the two test defects are fixed. 1) Add import java.util.concurrent.atomic.AtomicInteger; to AgentToolRegistryTest.java (line 61). 2) Correct the logical audit record target assertion in AgentInvocationAuditBridgeTest.java line 60 to match observation context without target. After fixes, re-run CI and partition reviews.
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
FINAL synthesis of PR #8095 (apache/shenyu) at head c3487f5. Across 37 partition reviews, 36 passed and part-17 (AgentToolRegistryTest.java) returned NEEDS_CHANGES due to missing imports for AtomicInteger and Set, causing test compilation failure. CI status is complete but passed=false. Complete diff was reviewed in partitions (global_complete_diff=true). Cross-file interactions among admission controller, config, plugin wiring, and audit appear consistent in passing partitions, but the test compilation blocker and failed CI prevent a PASS. Verdict: NEEDS_CHANGES.
Evidence
- Child review part-17: NEEDS_CHANGES with HIGH findings on AgentToolRegistryTest.java lines 61 and 77 (missing AtomicInteger and Set imports)
- CI summary: complete=true, passed=false, check_count=9
- all_parts_passed=false; global_complete_diff=true; head_sha=c3487f5070d2ba889f206a2fe7b4991195b5b3ab
Recommended next steps
- Add imports for java.util.concurrent.atomic.AtomicInteger and java.util.Set in shenyu-plugin/shenyu-plugin-agent-gateway/src/test/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentToolRegistryTest.java
- Re-run CI to confirm compilation and tests pass after import fix
- Validate cross-module contracts with prerequisite PRs since PR is draft building on unmerged work
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: f65486a0-5d0e-4ea6-81c0-5de8ebd6404a · Commit: c3487f5070d2ba889f206a2fe7b4991195b5b3ab
Review verdict: NEEDS_CHANGES
FINAL scope synthesis from 37 partition reviews. Per rules, child NEEDS_CHANGES cannot be overridden. part-17 identified concrete HIGH severity blocking defects: missing imports for AtomicInteger and Set in AgentToolRegistryTest.java (RIGHT side lines 61,77) causing compilation failure. Additionally CI passed=false though complete. complete_diff=true and head_sha set. Cross-file assessment of other partitions shows no contradictory HIGH/CRITICAL defects, but the test compile blocker and CI failure necessitate NEEDS_CHANGES. Limitations: no local test execution; prerequisite PRs (#8002,#7860,#7921) not independently verified; partition reviews relied on supplied diff segments only.
Publication: REQUEST_CHANGES (VERIFIED_BLOCKING_FINDINGS)
- shenyu-plugin/shenyu-plugin-agent-gateway/src/test/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentToolRegistryTest.java:61 [RIGHT] AtomicInteger is used but no import for java.util.concurrent.atomic.AtomicInteger is present in the added imports; compilation will fail.
- shenyu-plugin/shenyu-plugin-agent-gateway/src/test/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentToolRegistryTest.java:77 [RIGHT] Set.of is used but no import for java.util.Set is present in the added imports; compilation will fail.
Review details
PR #8095 introduces bounded MCP resource admission with audit and metrics. Partition review found one blocking issue: AgentToolRegistryTest.java lacks imports for java.util.concurrent.atomic.AtomicInteger (line 61) and java.util.Set (line 77), which will fail test compilation. All other 36 partitions passed without HIGH/CRITICAL defects. CI is currently failing. Recommend adding the missing imports and ensuring CI passes before merge; also confirm integration with prerequisite PRs (#8002, #7860, #7921) as noted in PR description.
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
Synthesis of PR #8095 (apache/shenyu) at head c3487f5 implementing bounded local and remote MCP resource admission. All 37 partition reviews returned PASS with no HIGH/CRITICAL findings; complete_diff=true and all_parts_passed=true. However CI status shows passed=false across 38 checks, and the PR is a draft dependent on unmerged prerequisites. Therefore FINAL PASS cannot be granted; verdict INCONCLUSIVE.
Evidence
- Attached review summary: all_parts_passed=true, complete_diff=true, 37/37 partition verdicts PASS with empty blocking_findings
- CI object in attachment: check_count=38, complete=true, passed=false, legacy_state=pending
- Multiple partition notes state PR builds on unmerged prerequisites (#8002, #7860, #7921) and is not independently mergeable
Recommended next steps
- Investigate and resolve CI failures (38 checks reported, passed=false)
- Merge prerequisite PRs #8002, #7860, #7921 before integrating this draft
- Re-run full cross-module test suite with prerequisites to confirm admission contracts
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 372c954e-259e-4e3f-a370-76a0c1bb5556 · Commit: c3487f5070d2ba889f206a2fe7b4991195b5b3ab
Review verdict: INCONCLUSIVE
FINAL synthesis scope: all 37 child partition reviews returned PASS with no HIGH/CRITICAL findings, complete_diff=true and all_parts_passed=true. However the governing rule requires CI passed before a FINAL PASS, and the attached CI data shows passed=false (38 checks complete). Additionally, the PR is a draft that explicitly depends on unmerged prerequisite PRs, so cross-file contract correctness cannot be fully confirmed from static partition reviews alone. With no concrete blocking defect to justify NEEDS_CHANGES but inability to confirm PASS, the only admissible verdict is INCONCLUSIVE.
Publication: COMMENT (INCONCLUSIVE_REVIEW)
Review details
Based on the frozen partition reviews, all supplied code segments are clean, but CI did not pass and the PR relies on unmerged prerequisite work. Recommend not merging until CI is green and prerequisites are integrated. Verdict: INCONCLUSIVE.
Thank you for reviewing this again. I checked the complete file at the reviewed commit c3487f5: java.util.Set is already imported at line 38, and java.util.concurrent.atomic.AtomicInteger at line 40. Both imports also exist on master, so they do not appear as added lines in this PR’s diff. To rule out stale compiled classes, I ran a clean JDK 21 build and the related tests. All 157 selected tests passed, including all 19 tests in AgentToolRegistryTest, with no failures, errors, or skips. I also updated the PR description to clarify the dependency status: #7860 and #7921 have merged, while #8002 remains the outstanding prerequisite. Could you please take another look at the two import findings against the complete file? Thank you for your time. |
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
WHOLE_PR review at the pinned head is INCONCLUSIVE: the frozen versioned-diff evidence was fully delivered, but CI is complete and not passing, and the attachment lacks failure logs needed to verify a HIGH/CRITICAL source-level blocker.
Evidence
- Frozen attachment: scope WHOLE_PR, VERSIONED_DIFF, file_count 59, complete_diff true; engine read progress records 283241/283241 diff characters delivered with no unread pages; coverage notes no local tests executed.
- CI evidence: complete=true, check_count=93, passed=false; failed checks at the head SHA include build, e2e, compat_java21 (admin, shenyu-admin), and e2e-storage (shenyu-e2e-case-storage, e2e-mysql-compose). The attachment provides conclusions and run IDs but no failure logs.
- Targeted pinned-head reads verified malformed Javadoc in new AgentResourceAdmission.java RIGHT lines 61 and 73, but no CI log proves these lines caused the failed build; no source-level HIGH/CRITICAL defect is established.
Recommended next steps
- Collect the four failed CI job logs for head 226f40e and fix the verified root cause.
- Rerun CI after the #8002 dependency synchronization described in the PR description.
- Return for re-review with passing CI evidence or a source-level failure cause anchored to changed lines.
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 2243019f-645f-43e1-bbaa-abf851f9f28f · Commit: 226f40eb24a8f154c42f61044c4432225f798dec
Review verdict: INCONCLUSIVE
Scope is the complete #8095 change at head 226f40e. Full diff coverage is recorded, but PASS requires passing CI and CI is explicitly failed with four failed checks, so PASS is not supported. NEEDS_CHANGES is also not supported because the frozen evidence contains no failure logs and no verified HIGH/CRITICAL defect anchored to a changed path, side and line. The missing CI root-cause evidence makes the analysis incomplete; therefore the explicit verdict is INCONCLUSIVE with no blocking findings.
Publication: COMMENT (INCONCLUSIVE_REVIEW)
…dgets Address the review of apache#8411. The remote binding compared the whole Config record, which now contains the request/response budgets, against the config returned by the credential resolver. Any resolver written before this feature rebuilds that target from the four reference fields and therefore carries the 8192 defaults, so every non-default budget failed with "Missing or mismatched service credential binding" and the data-sync update was silently dropped. Binding identity is name/endpoint/credentialRef/credentialVersion only (Config#bindsTo); budgets stay trusted transport configuration. The file resolver no longer mirrors budgets into its comparison, and the Config javadoc now states that record equals/hashCode still cover the complete snapshot, budgets included. Also make the documented limit relationship accurate: remoteResponseBytes bounds upstream JSON-RPC wire bytes, while the response the rule renders is bounded by the rule handle's maxResponseBytes in AgentHttpToolExecutor. The two are independent and both must pass, so a 1 MiB remote budget is only usable when the entry budget is raised as well. Document the resulting memory bound (8 Servers x 64 in-flight x remoteResponseBytes, ~512 MiB only at the hard maximum, 4 MiB at the defaults) and state explicitly that this change adds no aggregate admission limit, which stays with apache#8095. Finally use the imported AgentGatewayAggregationConfig instead of inline FQNs and give the budget range rule a single error message in budget() and validateRemotePayloadBudget().
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
WHOLE_PR review of #8095 (bounded local and remote MCP resource admission, audit bridge, metrics, docs, and Spring Boot wiring): the entire 283,244-character pinned diff was read and cross-file contracts were spot-checked on the frozen head, but CI has not completed and the PR still carries an unmerged dependency, so no definitive PASS or NEEDS_CHANGES verdict is supported.
Evidence
- Coverage: frozen VERSIONED_DIFF fully consumed with complete_diff=true; all pages read to has_more=false (next_unread_offset 283244 = total_characters 283244) for the empty path, plus the complete AgentResourceAdmission.java sub-path; targeted resource_read/resource_search on pinned head 5c87f99 located AgentResourceAdmission, AgentMcpResourceAdmission, AgentMcpDispatcher and AgentToolRegistry references.
- CI is unfinished: ci.check_count=11 while every enumerated check has status=queued and conclusion=null; legacy_state=pending, status_count=0, failed_checks=[], passed=false. No passing CI exists to satisfy the PASS requirement.
- PR description states the branch 'still depends on #8002' and will be 'synchronized with master' after that merge so the final patch contains only the resource-admission delta, meaning the reviewed head carries a non-final patch.
Recommended next steps
- Re-evaluate once the 11 reported CI checks leave the queued/pending state and their conclusions are available.
- Re-review after the branch is rebased on master following the #8002 merge, so the patch contains only the resource-admission delta.
- Verify admission wiring across AgentGatewayPluginConfiguration, AiProxyPluginConfiguration, MetricsReporter and the new agent-audit starter once CI is green.
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 505c8798-f3db-48db-9b02-f50f0305be7c · Commit: 5c87f99f2baf7cd485fff193117d6d9fe0bc8dd6
Review verdict: INCONCLUSIVE
Scope was WHOLE_PR with full diff coverage on head 5c87f99 and no tool failures; no concrete HIGH/CRITICAL blocking defect was verified, so NEEDS_CHANGES is unjustified (and no tests were executed by the reviewer). However PASS explicitly requires passing CI, and the frozen CI snapshot shows 11 checks all queued/pending with passed=false and status_count=0; the PR additionally depends on unmerged #8002, so the reviewed patch is not final. Because this evidence is incomplete, the explicit verdict must be INCONCLUSIVE rather than PASS.
Publication: COMMENT (INCONCLUSIVE_REVIEW)
Fixes #7951
Dependency
This PR is ready for review and still depends on #8002. The request-scoped MCP client and execution prerequisites #7860 and #7921 were merged into master on October 30, 2026, and their merge commits are ancestors of this branch. The branch also contains the current #8002 head,
b9a5bdc72. After #8002 is merged, this branch will be synchronized with master so the final patch contains only the resource-admission delta.Background
Agent Gateway MCP execution currently has no upper bound on concurrent local tool executions or calls to an individual remote MCP server. A burst of tool calls can therefore monopolize gateway threads or outgoing connections, and one slow remote server can affect unrelated callers.
Changes
-32026with HTTP429, and queue deadline expiry returns-32026with HTTP504.global,local, andremote) without tool, subject, tenant, or endpoint labels.Verification
Review follow-up at
c3487f507The complete
AgentToolRegistryTest.javaalready importsjava.util.Setat line 38 andjava.util.concurrent.atomic.AtomicIntegerat line 40. Both imports also exist on master; they are unchanged context rather than added lines in this PR's diff.AgentToolRegistryTest,AgentResourceAdmissionTest,AgentMcpHttpHandlerTest,AgentGatewayPluginConfigurationTest,AgentInvocationAuditBridgeTest, andAiRequestObservationTest— 157 tests, 0 failures, 0 errors, 0 skipped.clean testand rebuilt test sources, rather than relying on previously compiled classes. Lifecycle Checkstyle passed.Earlier implementation verification
shenyu-common: 655 tests, 0 failures, 0 errors, 1 pre-existing skip.shenyu-plugin-agent-gateway: 620 tests, 0 failures, 0 errors, 0 skipped.shenyu-spring-boot-starter-plugin-agent-gateway: 196 tests, 0 failures, 0 errors, 0 skipped.shenyu-plugin-metrics: 26 tests, 0 failures, 0 errors, 0 skipped.shenyu-plugin-ai-proxypassed 337 tests with 0 failures, errors, and skips on Windows; the same module passed on RISC-V/QEMU.git diff --checkchecks passed for the verified module scope; the cached whitespace check only reported pre-existing warnings from master.These earlier results apply to their original implementation snapshots, not a new full-suite run on the latest head.