Trying to teach GPT-6.1 KQL

I tried building a Kusto Query Language (KQL) skill to help AI coding agents write better queries. The goal was fewer mistakes on the awkward cases, such as duplicate rows or events exactly on a time boundary.

After several rounds of changes and testing, I’ve decided to stop working on the general-purpose version. gpt-6.1-sol was already doing fine without it.

What I’ve tried

I’ve put together guidance and examples covering joins, JSON parsing, time-series analysis, geospatial functions such as spatial clustering, and stateful processing with scan.

Early evals showed extra cost without consistent gains in correctness, so I removed basic examples and shortened the instructions. Detailed references stayed available for the agent to read when needed.

I’ve expanded the evals to 33 cases, including 18 complex cases. In most tests, I described the problem, provided sample data, and asked the model to write the query from scratch.

One case involved billing over overlapping entitlements. Prices could change partway through an interval, overlapping coverage couldn’t be charged twice, and fractional seconds still mattered. The query also had to return tenants with no activity. KQL can express all of that in a single query.

For the final comparison, I’ve used gpt-6.1-sol through a custom Copilot CLI runner in 66 fresh sessions, split equally between skill and no skill. Both sides received identical inputs, without reference answers. Queries for 31 cases ran on Microsoft Fabric Eventhouse against expected results; the other 2 tested strategy and clarification. The checks compared the returned values, not just whether a query ran without errors.

The results

MetricWithout the skillWith the skill
Correct on the first attempt33/3332/33
Correct after 1 allowed correction33/3333/33
Generation and repair credits55.4169.60
Model calls3381

The skill cost 25.6% more, with no improvement in final correctness. On the complex cases alone, first-attempt scores were 18/18 without the skill and 17/18 with it. Skill costs were about 20% higher on that subset.

It even loaded for the simple-query control, despite instructions to skip it. Same correct query, extra work.

For me, the useful combination is already there: KQL can express the calculation, and the model can turn a description into a working query. The extra instructions weren’t improving that.

What does work

What I’ve found useful is a custom agent built around a specific dataset. It knows the schema, what each table or view represents, and the relationships and join keys between them. That context covers things the model can’t safely guess from column names: which source to trust, what a row represents, and which joins could double-count the data.

That gives it a basis for choosing the right sources and interpreting the results. The model already knows KQL; it needs help understanding my data.