[Feature] Add AI execution statistics to query profiles and audit logs
Feature request
Is your feature request related to a problem? Please describe.
The asynchronous AI execution framework introduced in #76816 has no query-scoped visibility into model request counts, retry/timeout behavior, cumulative HTTP time, or provider-reported token usage. Operators need these signals in the existing query Profile and audit log, including when detailed Profile collection is disabled.
Describe the solution you'd like
Carry numeric AI execution statistics through the existing terminal task callback, query-statistics reporting, Profile counters, and audit-event pipeline. Expose task/request/retry/timeout/error counts, HTTP time, and independently reported prompt/completion/total token usage with a coverage count for each field.
Preserve the distinction between unavailable usage and explicitly reported zero. Keep the statistics optional for non-AI queries. Reuse the current query ownership, reporting, and counter aggregation mechanisms; do not introduce a separate reporting service or log model inputs, outputs, credentials, or provider errors.
Describe alternatives you've considered
Process-wide metrics cannot attribute work to a particular query. Parsing raw provider logs would introduce sensitive payload handling and would not integrate with the existing query statistics. Token estimation and billing are separate capabilities, not substitutes for observed execution statistics.
Additional context
This is a scoped follow-up to #76816 and contributes to the broader AI roadmap in #60002. It does not depend on unmerged AI function or TopN PRs. Failed, cancelled, or mixed-version queries can have partial observations under the existing reporting semantics; this feature is not an exactly-once billing ledger.
Source: StarRocks/starrocks