fix: cover CPEX plugin regressions#4629
Merged
Merged
Conversation
48684b5 to
47cf841
Compare
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
8ea8c75 to
abe3f31
Compare
Signed-off-by: Brian Hussey <brian.hussey@ie.ibm.com>
brian-hussey
approved these changes
May 28, 2026
brian-hussey
left a comment
Member
There was a problem hiding this comment.
Approved based on previous approval.
Member
|
Tests previously passed, only outstanding issue was .secrets.baseline update, merged once that passed. |
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.
🐛 Bug-fix PR
📌 Summary
Fixes CPEX migration regressions found after the internal plugin framework was replaced:
cpex.framework.external.mcp.server.runtimeinstead of the deleted in-repo framework runtime.prompt_post_fetchwith CPEX hook policies could duplicate prompt messages when a post-hook modified nested prompt result content.ResourceContentneeded to serialize MCP resource MIME type asmimeType, notmime_type, on alias-aware dumps.resources/readnow has regression coverage for duplicate URI collisions, includingtime://formatsstyle resources.🔁 Reproduction Steps
prompts/getformcp-plugin-parity-db-directwithPromptOutputSentinelPluginenabled; before the fix it returned two identical messages afterprompt_post_fetch.ResourceContent(..., mime_type="text/plain")withmodel_dump(by_alias=True); the MCP response shape must usemimeType.🐞 Root Cause
PromptResultobject directly intoPromptPosthookPayloadallowed the policy merge path to wrap and re-apply the nestedmessageslist, producing duplicate messages.ResourceContentdid not inherit the alias-aware base model, so alias serialization did not consistently produce MCP camelCase.💡 Fix Description
cpex.framework.external.mcp.server.runtime.PromptResultmodel.ResourceContentuse the alias-aware base model and added serialization coverage formimeType.🧪 Verification
uv run pytest tests/unit/mcpgateway/plugins/test_cpex_migration_paths.py tests/unit/mcpgateway/test_schemas.py tests/unit/mcpgateway/services/test_prompt_service.py tests/unit/mcpgateway/plugins/plugins/test_prompt_output_sentinel.py -q --tb=shortuv run pytest tests/unit/mcpgateway/services/test_resource_service.py::TestReadResourceCoverageEdges::test_read_resource_server_scoped_uri_lookup_avoids_duplicate_uri_collisions tests/unit/mcpgateway/services/test_resource_service.py::TestReadResourceCoverageEdges::test_read_resource_generic_uri_lookup_reports_ambiguity -q --tb=shortuv run ruff check tests/unit/mcpgateway/plugins/test_cpex_migration_paths.py mcpgateway/services/prompt_service.py tests/unit/mcpgateway/services/test_prompt_service.py mcpgateway/common/models.py tests/unit/mcpgateway/test_schemas.pygit diff --checkPYTHONPATH=/tmp/contextforge-plugins-framework uv run pytest tests/unit/mcpgateway/plugins/test_cpex_migration_paths.py tests/unit/mcpgateway/services/test_prompt_service.py::TestPromptService::test_get_prompt_post_hook_policy_does_not_duplicate_prompt_messages tests/unit/mcpgateway/plugins/plugins/test_prompt_output_sentinel.py tests/unit/mcpgateway/test_schemas.py::TestMCPTypes::test_resource_content_serializes_mcp_mime_type_alias -q --tb=shortprompts/getrequest against a fresh plugin-enabled server returned one sentinel-appended message📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)