Skip to content

feat(microsoft-ai): described query results and last-result capture#146

Merged
daniel3303 merged 1 commit into
mainfrom
feature/execute-query-with-description
Jun 9, 2026
Merged

feat(microsoft-ai): described query results and last-result capture#146
daniel3303 merged 1 commit into
mainfrom
feature/execute-query-with-description

Conversation

@daniel3303

Copy link
Copy Markdown
Owner

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 ExecuteQuery to 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 to ExecuteQuery; 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 — new ExecuteQueryWithDescriptionToolName constant; SummarizeExecuteQueries matches either execute variant; reminder + schema workflow texts name the execute tool generically.
  • Tests: capture semantics (with/without description, empty result, failure no-overwrite) and guard runs with the described variant (grounded success, failed-then-retry). 170/170 passing.

No breaking changes — additive API; the only consumer-visible wording change is the genericized schema/reminder text (CHANGELOG'd).

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.
@daniel3303 daniel3303 self-assigned this Jun 9, 2026
@daniel3303 daniel3303 merged commit 132933d into main Jun 9, 2026
4 checks passed
@daniel3303 daniel3303 deleted the feature/execute-query-with-description branch June 9, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant