gabotorresruiz commented on code in PR #45084:
URL: https://github.com/apache/superset/pull/45084#discussion_r4233149291


##########
superset/mcp_service/server.py:
##########
@@ -549,10 +559,7 @@ def _serializer(tools: Sequence[Any]) -> list[dict[str, 
Any]]:
         results = _serialize_tools_without_output_schema(tools)
         for tool, data in zip(tools, results, strict=True):
             if desc := data.get("description"):
-                instructions = _request_instructions(tool)
-                data["description"] = _truncate_description(
-                    desc, max(0, max_desc - len(instructions))
-                )
+                data["description"] = _bounded_description(tool, desc, 
max_desc)

Review Comment:
   Closed. At 300 `list_datasets` comes back at 230 characters with the 
`list_metrics`/`get_table` steer intact against 18 on master, nothing is empty 
at 150, 250 or 300 in either `include_schemas` mode, and the eight empty 
descriptions master had at 250 are gone. Every non-`description` field is 
unchanged from master in summary mode, and the 16 `inputSchema` differences in 
full-schema mode are description text with no structural change. 
`test_search_list_datasets_keeps_semantic_view_steer` fails all six 
parametrizations against `325c6ca0`, so it holds the fix. Thanks for taking it 
in this PR rather than deferring it.
   



##########
superset/mcp_service/server.py:
##########
@@ -379,6 +380,18 @@ def _request_instructions(tool: Any) -> str:
     )
 
 
+def _bounded_description(tool: Any, description: str, max_length: int) -> str:
+    """Bound a tool's description, reserving room for its request instructions.
+
+    Request-parameter instructions stay untruncated in the input schema, so
+    their length is deducted from the prose budget. This is the single
+    description-bounding rule shared by tool-search results and the compact
+    native ``tools/list``.
+    """
+    instructions = _request_instructions(tool)
+    return _truncate_description(description, max(0, max_length - 
len(instructions)))

Review Comment:
   Re-measured on this head and the floor half is unchanged: at 
`max_description_length=100` `manage_dashboard_roles` is the one tool listed 
with `"description": ""`, and at 60 it is twenty one. Fine to leave at the 
documented 300. A `max(budget, MIN_PROSE_BUDGET)` floor would end the class 
rather than move it, but not blocking on it.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to