# Preserve selected SQL through Provider and diagnostic results

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "diagnostic-sql-text-continuity-2026-09-07",
  "problems": [{
    "problemId": "selected-query-text-lost-or-rejected",
    "summary": "Wetech and Clinic SQL summary text is omitted, and diagnostic packet parsing rejects legitimate SQL content.",
    "status": "candidate",
    "applicability": "Agent9 Wetech and Clinic TopSQL/Slow Query and shared diagnostic evidence/result parsing.",
    "issueKeys": ["APID-29464"],
    "sourceRefs": ["https://tidb.atlassian.net/browse/APID-29464#problem:selected-query-text-lost-or-rejected"],
    "signalTextIncludesAny": ["SQL text omitted", "diagnostic_scenarioEvidence_sensitive_value"],
    "observedThrough": "2026-09-07",
    "effectiveAt": null,
    "verifiedAt": null,
    "attemptedAction": "Preserve Wetech and Clinic list and selected-query SQL text and remove keyword-based rejection or Digest rewriting from diagnostic handoffs and decision packets.",
    "evidenceUrl": "https://github.com/tidbcloud/aisupport/pull/1378"
  }]
}
-->

Owner: Wetech and Clinic Managed Tool Provider Executors for query text; shared AOS
Scenario Diagnostic input/result parsing for content continuity. Source: operator
review and direct local reproduction against merged PR #1378 at `958b73ba`.
This is not a claim that the old APID-29464 replay hit a size limit or this parser.

Wetech already requests query for Digest-selected executions but previously
omitted it from returned rows. Preserve that exact API-returned text with its own
plan, instance and timings. Both Providers retain SQL text in TopSQL and Slow
Query discovery, with six-character Digests and no detailed discovery plans.
Wetech v52 and Clinic v29 carry these Provider changes. The merged source preserves PR #1380's
6-to-64-character input schema and metric time facts, and PR #1381's plan
missing/parse/decode diagnostics. The runner reduces whole
list rows under the existing per-fact limit, preserving SQL whitespace and valid
JSON rather than slicing the generic 4,000-character preview.

Remove safeText and credentialSafeText keyword heuristics from diagnostic data
parsing and remove blanket 64-hex rewriting from diagnostic prompt serialization.
SQL text, literals such as password=sample-data, comments and full Digests are
ordinary diagnostic data, including when cited in a diagnosis. Provider compact
projection still owns default six-character Digest display. The diagnostic Skill
and prompt allow load-bearing SQL excerpts. Structure, provenance, role boundaries,
read-only execution and the existing 16,384-unit/128-KiB budgets remain intact.
Agent9's actual injected-secret output check remains the credential boundary;
this change does not modify Agent9, Organization Auth or customer publication.

Verification: local production converter, handoff, diagnostic prompt and packet
parser regression cases preserve SQL and full Digests. Broad discovery, per-fact
size and evidence-provenance tests remain applicable. Deployment and one isolated
APID-29464 read replay are pending; no new ticket outcome or publication is claimed.

History: safeText originated in PR #569 (`a56e419d`, 2026-07-31), whose timeout
progress-preservation design explicitly excluded raw SQL and sensitive Provider
payloads from compact scenario packets. PR #975 (`37a1e741`, 2026-08-18) then
restricted full Digests to acquisition context and rewrote diagnostic inputs.
The operator clarified that this intermediate disclosure boundary is inappropriate:
query text and identifiers are necessary diagnostic evidence, and context-size
management must not become keyword-based rejection of legitimate conclusions.
