fix(ui): show federated prompt arguments in Admin UI instead of empty list#3602
fix(ui): show federated prompt arguments in Admin UI instead of empty list#3602crivetimihai merged 2 commits intomainfrom
Conversation
|
@shoummu1 - can you please resolve conflicts? |
92e2aea to
3393c27
Compare
|
@marekdano Thanks! I've rebased and resolved the conflicts in this PR. |
marekdano
left a comment
There was a problem hiding this comment.
Summary
This PR addresses prompt argument display issues in the Admin UI and reverts a previous database schema change for A2A agents.
✅ Positive Changes
1. Prompt Argument Schema Population (gateway_service.py)
- Added _build_prompt_argument_schema() static method to properly convert MCP prompt arguments into JSON schema format
- Method correctly handles: empty arguments, missing attributes, descriptions, and required fields
- Integrated into both _sync_gateway_metadata() and _update_or_create_prompts()
- Excellent test coverage with 3 comprehensive unit tests
2. UI Fix (admin.js)
- Fixed empty arguments display to show "No arguments" instead of empty JSON object
- Improved user experience when viewing prompts without arguments
3. Test Quality
- Well-structured tests for _build_prompt_argument_schema()
- Tests cover edge cases (empty, missing attributes, None descriptions)
- Updated existing tests to expect proper schema structure
Code Quality:
- ✅ Follows coding standards (type hints, docstrings)
- ✅ Good test coverage for new functionality
- ✅ Proper error handling in _build_prompt_argument_schema()
It was also manually tested, and I can confirm that arguments in prompts display as expected.
LGTM
3393c27 to
2e9c062
Compare
…ents display in Admin UI Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
…and real arguments Cover the new argument_schema integration in _update_or_create_prompts: - arguments=None handling in _build_prompt_argument_schema - new prompts with real arguments populate argument_schema correctly - argument_schema change alone triggers prompt update - no update when argument_schema is unchanged Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
35d6a71 to
729d68c
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Rebased onto main (clean, no conflicts) and added 4 tests for full differential coverage of the new code paths.
Backend review — All 4 locations where argument_schema={} was hardcoded are now correctly using _build_prompt_argument_schema(). The helper is consistent with the existing inline pattern in prompt_service.py, with the intentional difference that required is derived from MCP metadata rather than template placeholders — correct for federated prompts. Change detection at line 4322 properly handles None from old DB rows via or {}.
Frontend review — The || {} → || [] fix is correct (prompt.arguments is an array). The "No arguments" fallback is a good UX improvement. Compatible with buildPromptTestForm() which already expects array items with name/description/required.
Security — No new endpoints, no auth changes, no unsanitized user input. No issues.
Tests added (commit 729d68c):
test_build_prompt_argument_schema_arguments_none— handlesarguments=Nonetest_update_or_create_prompts_new_prompt_with_arguments— real arguments flow through toargument_schematest_update_or_create_prompts_argument_schema_change_triggers_update— schema-only change triggers updatetest_update_or_create_prompts_no_update_when_schema_unchanged— no spurious update when schema is identical
All 49 tests pass.
… list (#3602) * populate prompt argument_schema from MCP metadata and fix empty arguments display in Admin UI Signed-off-by: Shoumi <shoumimukherjee@gmail.com> * test: add differential coverage for argument_schema change detection and real arguments Cover the new argument_schema integration in _update_or_create_prompts: - arguments=None handling in _build_prompt_argument_schema - new prompts with real arguments populate argument_schema correctly - argument_schema change alone triggers prompt update - no update when argument_schema is unchanged Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Shoumi <shoumimukherjee@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com> Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
… list (IBM#3602) * populate prompt argument_schema from MCP metadata and fix empty arguments display in Admin UI Signed-off-by: Shoumi <shoumimukherjee@gmail.com> * test: add differential coverage for argument_schema change detection and real arguments Cover the new argument_schema integration in _update_or_create_prompts: - arguments=None handling in _build_prompt_argument_schema - new prompts with real arguments populate argument_schema correctly - argument_schema change alone triggers prompt update - no update when argument_schema is unchanged Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Shoumi <shoumimukherjee@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com> Signed-off-by: KRISHNAN, SANTHANA <sk8069@exo.att.com>
📌 Summary
Prompts registered via federated MCP servers always showed an empty argument list in the Admin UI. The arguments panel displayed
{}instead of the actual argument names, descriptions, and required flags defined in the upstream MCP server.🔗 Related Issue
Closes: #3447
🔁 Reproduction Steps
See #3447. Briefly:
greet_user(name, style)).{}and the Test Prompt form shows no input fields.🐞 Root Cause
In
gateway_service.py, every code path that creates or updates a federatedDbPrompthardcodedargument_schema={}, discarding the argument metadata returned by the upstream server in theprompts/listMCP response.As a result,
convert_prompt_to_read()inprompt_service.py(which reconstructs theargumentslist by iterating overargument_schema["properties"]) always returned an empty list, so the UI had nothing to render.Additionally, in
admin.jsthe fallback for missing arguments used|| {}(an object) instead of|| [](an array), and there was no human-readable "No arguments" message for prompts that genuinely have none.💡 Fix Description
Backend (
gateway_service.py):_build_prompt_argument_schema(prompt)that converts the MCPargumentslist (items withname,description,required) into the internal{"type": "object", "properties": {...}, "required": [...]}JSON schema — consistent with whatprompt_service.pyalready does for user-created prompts.argument_schema={}was hardcoded: federation create, federation orphan-reassign,_update_or_create_promptscreate branch, and_update_or_create_promptsupdate branch.argument_schemato the change-detection condition so that an upstream argument change triggers a DB update.Frontend (
admin.js):|| {}→|| []fallback in the edit modal (correct type forvalidateJson).JSON.stringify(prompt.arguments || {})in the view details panel with a conditional that renders"No arguments"when the list is empty and a formatted JSON array otherwise.🧪 Verification
make lintmake testmake coverage📐 MCP Compliance (if relevant)
prompts/listargument metadata:name,description,required)✅ Checklist
make black isort pre-commit)