feat: Tabular SK analysis — pagination, auto-trim, return_columns forwarding, and 100 K handoff limit (#893)#894
Open
vivche wants to merge 14 commits intomicrosoft:Developmentfrom
Open
Conversation
…ntent - Rename all spec files to use sample_ prefix for consistency - Convert asset spec files from .json to .yaml format - Sync spec content (security, components, paths) with Cosmos DB source of truth - Replace hardcoded dev222288 instance URL with YOUR-INSTANCE placeholder - Add missing sysparm_input_display_value param to incident update operation - Expand updateIncident requestBody with full field set and descriptions - Alphabetize Incident and Asset schema properties across all specs - Update SERVICENOW_ASSET_MANAGEMENT_SETUP.md links to new filenames/paths
…agent prompts - Replace passive 'extract the INSTANCE part' guidance with explicit step-by-step instructions for deriving the real instance subdomain from the plugin base URL - Add SELF-CHECK rule: never output 'INSTANCE', 'YOUR-INSTANCE', or 'yourinstance' as placeholder text in any displayed URL - Rewrite HOW TO EXTRACT section to use generic [instance-name] pattern (template-friendly) with dev222288 kept only as a concrete example - Apply consistent wording to both servicenow_agent_instructions.txt and servicenow_kb_management_agent_instructions.txt
… stats queries - Switch all stats date filters from sys_created_on to opened_at to match portal counts - Add YEAR QUERY RULE: named year always uses YYYY-MM-DD range, never 'This year' - Add two-call pattern for breakdowns: grand total + grouped (handles null-category records) - Replace ASCII bar chart with markdown table (avoids rendering as solid black boxes) - Add (No category) row handling for blank groupby_value responses - Enforce exact table structure: single Total row, no split totals - Fix text search to always query both short_description AND description fields - Update OpenAPI spec to match: opened_at for stats, dual-field text search, sysparm_count required=true - Add FIELD RULE explaining opened_at vs sys_created_on distinction
Fix 1: run_tabular_sk_analysis always used the default Azure OpenAI endpoint from app settings, causing DeploymentNotFound 404 when the active chat model was resolved via the multi-endpoint feature. Added gpt_endpoint, gpt_api_version_override, gpt_auth, and gpt_provider override parameters to run_tabular_sk_analysis and run_tabular_analysis_with_multi_file_support, and updated all four call sites to pass multi-endpoint credentials when active. Fix 2: Semantic Kernel's KernelArguments type-coercion on Python 3.13 raises FunctionExecutionException for Optional[str] parameters typed as 'typing.Optional[str]'. Updated all Optional[str] kernel function parameters in tabular_processing_plugin.py to use 'str | None' union syntax which is natively supported in Python 3.13.
…3_OPTIONAL_FIX.md Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…velopment into fix/tabular-sk-multiendpoint-py313-optional
…rd, elapsed logging (v0.241.009) - Add _auto_trim_df_for_output(max_chars=50K): two-phase trim (drop heavy cols, truncate rows) - _filter_rows_across_sheets: add return_columns/start_row, remove capacity cap, add note/has_more fields - _query_tabular_data_across_sheets: same pattern as filter_rows cross-sheet - filter_rows public: add return_columns + start_row params, single-sheet pagination + auto-trim - query_tabular_data public: same as filter_rows - route_backend_chats: import time, _analysis_start_time, per-attempt elapsed, 20K->100K truncation guard, total_elapsed_seconds at exit points
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.
Description
Summary
This PR delivers five enhancements to the Tabular Semantic Kernel analysis pipeline that together prevent silent data truncation on large Excel / CSV files and give the LLM finer control over what data it retrieves per tool call.
Change 1 — Pagination (
start_row/max_rows/has_more/next_start_row)Every analysis tool in
TabularProcessingPluginnow accepts:start_rowstr"0"max_rowsstr"100"Every tool response now includes:
has_moretruewhen rows were truncated by the page limitnext_start_rowstart_rowon the next calltotal_matchedThe LLM is instructed (via the
@kernel_functiondocstrings) to call the same tool again withstart_row = next_start_rowwhenhas_moreistrue.Change 2 — Auto-trim (
_auto_trim_df_for_output)A new private helper estimates the serialised JSON size from a 20-row sample. When the estimated output would exceed the 50 K-char per-tool budget and
return_columnswas not supplied by the caller:has_more = Truefires and pagination picks up the remainder.A
trimmed_columns_excludedfield in the tool response lists any dropped columns so the LLM knows what was omitted.Change 3 —
return_columnsforwardingThe existing
return_columnsparameter was already accepted by some tools but not threaded through to the DataFrame slice. This PR ensures it is applied consistently across all eleven analysis tools and that_auto_trim_df_for_outputis skipped wheneverreturn_columnsis supplied (the caller has already projected to the columns they need).Change 4 — Handoff limit raised to 100 K
max_handoff_charsinroute_backend_chats.pywas raised from24_000to100_000. AWARNING-levellog_eventis emitted when truncation still occurs, including the original and truncated lengths, so operators can detect and investigate cases where even 100 K is insufficient.Change 5 — Elapsed timing logging
Each SK tabular analysis invocation now logs the wall-clock elapsed time at
INFOlevel, making it straightforward to correlate slow responses with large files or high row counts.Files Changed
application/single_app/semantic_kernel_plugins/tabular_processing_plugin.py_auto_trim_df_for_output;return_columnsforwardingapplication/single_app/route_backend_chats.pymax_handoff_chars24 K → 100 K; truncationWARNINGlog; elapsed timingdocs/explanation/feature/v0.241.008/TABULAR_SK_PAGINATION_AUTOTRIM_AND_HANDOFF_TRUNCATION.mdTesting
gpt-5.1models.filter_rowscall withstart_row = next_start_rowreturned the correct continuation page.trimmed_columns_excludedlisted the omitted columns in the response.return_columnsconfirmed: tool response contained only the requested columns with no auto-trim applied.WARNINGfires only for pathological cases.