Skip to content

Document ai.params redact_prompt, auto_correct, and utility_model#452

Open
Devon-White wants to merge 11 commits into
mainfrom
Devon/swml-redaction-params
Open

Document ai.params redact_prompt, auto_correct, and utility_model#452
Devon-White wants to merge 11 commits into
mainfrom
Devon/swml-redaction-params

Conversation

@Devon-White

@Devon-White Devon-White commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the three shipped-but-undocumented AI content-redaction params to the SWML TypeSpec schema and the ai.params reference page. Addresses the reference-page acceptance criterion of #450; the conceptual Content Redaction guide is deliberately deferred to a follow-up PR.

All types, defaults, and behavior were verified against the mod_openai source (not just the issue text):

  • redact_prompt (string) — plain-language description of content to mask (----) from everything the platform records or transmits: logs, events, webhook payloads, the call timeline, and the post-conversation call_log/raw_call_log. Non-empty value enables; omit to disable. Explicitly states the caller still hears the content and the AI model still receives the real text each turn — redaction protects recorded/transmitted data only, and is best-effort.
  • auto_correct (boolean, default false) — utility-pass cleanup of caller speech-to-text. Documents a source-verified constraint the issue draft missed: it is mutually exclusive with enable_text_normalization (which defaults on and wins, so enable_text_normalization: false is required for auto_correct to take effect). When combined with redact_prompt, cleanup and redaction run in a single pass.
  • utility_model (string, defaults to the value of ai_model) — model for the lightweight redaction/cleanup passes, documented with the same allowed-models phrasing and default convention as thinking_model.

Changes

  • specs/swml/calling/Methods/ai/ai_params.tsp — three new fields on AIParams (auto_correct and redact_prompt beside enable_text_normalization; utility_model beside thinking_model)
  • fern/products/swml/pages/reference/methods/calling/ai/ai_params/index.mdx — three matching <ParamField> entries in the corresponding page sections
  • specs/swml/calling/tsp-output/@typespec/json-schema/SWMLObject.json — regenerated (checked-in output)
  • fern/apis/signalwire-rest/openapi.yaml — regenerated: the calling-api imports the SWML module, so SWML.Calling.AIParams is emitted into the REST OpenAPI and picks up the three new fields. This also means the Fabric AI-agent REST resource documents them for free (see below).
  • Removed specs/signalwire-rest/fabric-api/ai-agent/models/ai/ai_params.tsp — dead code. The Fabric AI-agent spec already reuses SWML.Calling.AIParams via model AIAgent is AIObject (core.tsp imports the SWML ai module); this hand-copied duplicate was never imported or compiled, had drifted ~40 fields behind the shared model, and carried the backend's digit_termiantors typo. Deleting it leaves the emitted openapi.yaml byte-identical (verified by rebuild).

Verification

  • yarn build:swml-calling and yarn build:signalwire-rest compile clean; tsp format unchanged
  • All three fields emit into SWMLObject.json and into SWML.Calling.AIParams in openapi.yaml with correct shapes (plain string / boolean | SWMLVar with default: false / SupportedAIModels union)

Part of #450

Adds the three shipped-but-undocumented AI params to the SWML TypeSpec
schema (AIParams) and the ai_params reference page, per issue #450.
Types, defaults, and behavior verified against mod_openai source:
redact_prompt masks recorded/transmitted content only (model still
receives real text), auto_correct is mutually exclusive with
enable_text_normalization, and utility_model defaults to ai_model.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The calling-api imports the SWML module, so SWML.Calling.AIParams is
emitted into the checked-in openapi.yaml and picks up redact_prompt,
auto_correct, and utility_model.
The Fabric AI-agent spec already reuses SWML.Calling.AIParams via
'model AIAgent is AIObject' (core.tsp imports the SWML ai module), so
the hand-copied AIParams in ai-agent/models/ai/ai_params.tsp was never
imported or compiled. It had drifted ~40 fields behind the SWML model
and carried the backend's digit_termiantors typo. Deleting it changes
nothing in the emitted openapi.yaml (verified: rebuild is byte-identical);
the REST surface already picks up redact_prompt, auto_correct, and
utility_model through the shared SWML model. The Rails backend merges
unrecognized params verbatim into the generated SWML document
(params_serializer.rb), so the shared model matches actual behavior.
@Devon-White Devon-White linked an issue Jul 7, 2026 that may be closed by this pull request
3 tasks
Devon-White and others added 8 commits July 7, 2026 12:33
Removes implementation-flavored wording (model round-trip, utility
passes, per-turn phrasing) in favor of end-user language, states the
latency benefit plainly, and turns the best-effort caveat into
actionable guidance.
The GitHub-side merge of main combined the emitted artifact textually, so
the new auto_correct field kept its pre-#474 'boolean | SWMLVar' anyOf.
Rebuilding through @signalwire/typespec-openapi3 collapses it to bare
boolean, matching the SWMLVar-only-in-SWML-JSON-schema invariant.
Conceptual guide for the ai.params redaction feature (redact_prompt,
auto_correct, utility_model) under the platform AI guides, following the
house guide skeleton: hook + minimal example first, the record-vs-model
distinction as the single load-bearing warning, behavior-level explanation
only (no marking/log internals), performance tuning with the
enable_text_normalization interaction, a customer-verifiable test flow,
and honest limitations including the audio-recording carve-out.
Mermaid mental-model diagram up front (live conversation vs records, same
styling as the prompt-engineering diagram), surface-by-surface table in
'How it works', Tip/Note callouts for utility_model and the
enable_text_normalization prerequisite, Steps for the verify flow, and a
CardGroup for next steps.
The emitted SWML JSON schema types enable_text_normalization as a union of
string consts (heard/spoken/both/true/on/false/off/none) — boolean false is
schema-invalid, and unquoted false/off in YAML parse as booleans. Use quoted
"off" in both formats. All four guide examples (YAML+JSON, minimal+full)
now validate against SWMLObject.json via ajv (draft 2020-12).
Source-verified all four redaction-adjacent params in mod_openai:

- utility_model/thinking_model validate via valid_thinking_model()
  (app_config.c), a case-insensitive substring match over an 18-model
  list — the docs' 'Allowed values are gpt-4o-mini, gpt-4.1-mini, and
  gpt-4.1-nano' claim was false. Reworded to examples, and documented
  the real failure mode: unrecognized values are silently ignored and
  the agent's main model is used (um = utility_model ?: model->name at
  every call site).
- auto_correct: switch_true() header parse; mutual exclusion confirmed
  at session.c:1526 (text normalization on -> auto_correct disabled
  with a warning). Reference wording now says enable_text_normalization
  "off" (string) to match the schema type, as the guide does.
- enable_text_normalization: session.c accepts exactly
  false/off/none/heard/spoken/both/true/on case-insensitively, default
  both — spec union matches; unrecognized values keep the default.
- redact_prompt: plain string header, no validation, non-empty enables;
  combined cleanup+redaction single pass confirmed in
  auto_correct_user_text() (ai_utils.c).

Regenerated SWML JSON schema and REST openapi.yaml (description-only
deltas).
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.

Document AI content redaction (redact_prompt, auto_correct, utility_model)

1 participant