feat(microsoft-ai): described query results and last-result capture#146
Merged
Conversation
Add ExecuteQueryWithDescription(sqlQuery, resultDescription): same execution as ExecuteQuery, but the model supplies a short description of the result set (column meanings, filters, caveats) in the same tool call. Hosts that hand the raw rows to an orchestrator can skip the final prose-generation turn, cutting one model round-trip per question. Expose AgentQLPlugin.LastSuccessfulResult (CapturedQueryResult: SQL, rows, row count, optional description) so hosts no longer wrap ExecuteQuery to harvest verified rows. Failed queries never overwrite a prior capture; a zero-row success is captured — it is an answer, not a failure. The self-correction guard recognises either execute variant as grounding (new ExecuteQueryWithDescriptionToolName constant); the schema workflow and reminder texts refer to the query execution tool generically.
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.
Summary
Hosts that feed query rows to an orchestrator agent currently need the model to write a prose answer (an extra round-trip) and need to wrap
ExecuteQueryto harvest the rows. This adds a first-class alternative: the model describes the result set in the same tool call that executes it, and the plugin captures the last successful result for the host.Code changes
AgentQLPlugin.ExecuteQueryWithDescription(sqlQuery, resultDescription)— identical execution and JSON shape toExecuteQuery; the description is recorded host-side only (a test locks in that it never leaks into the model-facing JSON).AgentQLPlugin.LastSuccessfulResult(CapturedQueryResult: Sql, Data, RowCount, Description) — per-scope capture; failed queries never overwrite a prior capture; a zero-row success is captured.SelfCorrectingChatClient— newExecuteQueryWithDescriptionToolNameconstant;SummarizeExecuteQueriesmatches either execute variant; reminder + schema workflow texts name the execute tool generically.No breaking changes — additive API; the only consumer-visible wording change is the genericized schema/reminder text (CHANGELOG'd).