Trading automatic CRM updates for review capacity is defensible when a logistics sales call can produce an unsupported customer commitment; resolve that trade-off by combining text moderation, JSON Schema validation, and a local check of business meaning before admitting an action. TL;DR: treat generated JSON as a proposed transaction. Validate its shape, bind it to the call being processed, and require evidence review before any customer-facing commitment becomes a CRM action. A fast response is useful only after that boundary holds.
How should text moderation and JSON Schema gate a call commitment?
For a bounded production scenario, I would start with one logistics sales-call workflow: a transcript becomes a summary, the summary proposes CRM actions, and a separate consumer decides which actions may be written. Consider a synthetic fixture in which a prospect asks for Friday delivery and the representative promises only to check availability. An extracted action saying that Friday delivery is confirmed would be structurally ordinary and operationally wrong. This is a design exercise, not a reported incident or a measured model result.
Hold the write.
The invariant is that a successful extraction must never grant itself permission to commit a commercial promise. Text moderation asks whether content meets a policy; extraction asks what happened; authorization asks what the system may do next. Those are separate judgments even if a single response contains fields for all three. A moderation pass does not establish that the representative promised a delivery date, and a schema-valid action does not establish that it belongs to the customer whose record is open.
That distinction determines the useful comparison between model candidates. Compare their ability to preserve the representative's uncertainty, flag disallowed content under the same policy, and abstain on ambiguous evidence. Don't interpret the presence of a json_schema request option as proof of business correctness: make the selected runtime's documented enforcement boundary an explicit part of the evaluation, then apply the same local acceptance rules to every candidate. Without comparable measurements and runtime documentation, a model-name comparison cannot settle correctness, pricing, or latency.
For this example, the automatic lane creates internal follow-up tasks only. Anything involving a delivery commitment, a rate agreement, or an unclear speaker goes to review. That narrower lane sacrifices automation coverage to keep the authorization rule inspectable.
2. Choose the operational boundary before buying capacity
A buy-vs-build table should identify who gets paged and who owns the acceptance contract. It shouldn't disguise an unmeasured preference as a benchmark. The alternatives below are deployment choices to investigate, not assertions about the features of any particular service.
| Choice | What the platform team must establish | Capacity and ownership trade-off |
|---|---|---|
| Buy managed inference | Contracted data handling, applicable output constraints, quotas, refusal handling, and measured tail latency | Less inference infrastructure to operate; quota behavior and service dependencies still enter the SLO |
| Build and operate inference | Serving configuration, constrained generation if used, deployment rollback, and sustained load behavior | More scheduling control; the team owns inference capacity and on-call coverage |
| Buy or build a review lane | Reviewer access, evidence display, escalation, and action authorization | Lower automatic coverage; review capacity becomes a dependency that must be planned |
Price is an input to this decision, but a token quote leaves out review work, rejected generations, repeated attempts, and the operational cost of maintaining the gate. Evaluate those against the same accepted-action workload. There is no defensible cheapest choice without that workload and its service boundary.
Capacity planning starts with arrival rate and residence time. As an illustrative planning assumption, 2 calls per second with 3 seconds of average inference residence time imply about 6 requests in flight during steady operation. This is arithmetic for the example, not a throughput claim; bursts, long transcripts, retries, and provider quotas require separate measurements and headroom. A review queue needs its own arrival and service-rate estimates because moving uncertain work there does not make the work disappear.
Review is work.
Keep two clocks. Measure inference latency separately from transcript-to-authorized-action latency, including queueing and review, so an attractive median cannot conceal a CRM workflow that misses its deadline.
3. Implement the preventative path as a local acceptance gate
Start with an intentionally small contract: a call identifier, a moderation verdict, and an array of proposed actions. The only automatic action in this example is an internal follow-up. An action carries a transcript turn identifier, but the consumer must still resolve that turn against the original transcript and authorize the target account before writing. An identifier supplied by a model is a reference to check, not evidence by itself.
Save the following as a Go main package and run it with go run main.go. Its executable checks demonstrate the admission boundary using synthetic responses. No network or CRM connection is needed. The decoder rejects unknown fields, trailing values, duplicate object keys, missing required values, and the wrong call identifier; domain checks then reject actions attached to a non-allow verdict. This implements a narrow application contract, not a general JSON Schema evaluator.
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
)
type Action struct {
Kind string `json:"kind"`
Turn string `json:"turn"`
}
type Decision struct {
CallID string `json:"call_id"`
Verdict string `json:"verdict"`
Actions []Action `json:"actions"`
}
// Walk a JSON value, rejecting duplicate keys at every object level.
func uniqueValue(d *json.Decoder) error {
token, err := d.Token()
if err != nil { return err }
delimiter, compound := token.(json.Delim)
if !compound { return nil }
switch delimiter {
case '{':
seen := map[string]bool{}
for d.More() {
keyToken, err := d.Token()
if err != nil { return err }
key, ok := keyToken.(string)
if !ok || seen[key] { return errors.New("invalid or duplicate key") }
seen[key] = true
if err := uniqueValue(d); err != nil { return err }
}
case '[':
for d.More() {
if err := uniqueValue(d); err != nil { return err }
}
default:
return errors.New("unexpected delimiter")
}
_, err = d.Token()
return err
}
func admit(raw []byte, expectedCall string) (Decision, error) {
var result Decision
if len(raw) > 64*1024 { return result, errors.New("response too large") }
scan := json.NewDecoder(bytes.NewReader(raw))
if err := uniqueValue(scan); err != nil { return result, err }
if _, err := scan.Token(); err != io.EOF {
return result, errors.New("expected one JSON value")
}
d := json.NewDecoder(bytes.NewReader(raw))
d.DisallowUnknownFields()
if err := d.Decode(&result); err != nil { return result, err }
if expectedCall == "" || result.CallID != expectedCall || result.Actions == nil {
return result, errors.New("missing fields or wrong call")
}
switch result.Verdict {
case "allow":
case "review", "deny":
if len(result.Actions) != 0 {
return result, errors.New("non-allow verdict contains actions")
}
default:
return result, errors.New("invalid verdict")
}
for _, action := range result.Actions {
if action.Kind != "internal_follow_up" || action.Turn == "" {
return result, errors.New("unsupported action or missing evidence reference")
}
}
return result, nil
}
func main() {
cases := []struct {
name string
body string
accept bool
}{
{"follow-up", `{"call_id":"call-17","verdict":"allow","actions":[{"kind":"internal_follow_up","turn":"turn-8"}]}`, true},
{"review", `{"call_id":"call-17","verdict":"review","actions":[]}`, true},
{"missing actions", `{"call_id":"call-17","verdict":"allow"}`, false},
{"contradiction", `{"call_id":"call-17","verdict":"deny","actions":[{"kind":"internal_follow_up","turn":"turn-8"}]}`, false},
{"duplicate", `{"call_id":"call-17","verdict":"deny","verdict":"allow","actions":[]}`, false},
{"extra field", `{"call_id":"call-17","verdict":"allow","actions":[],"write":true}`, false},
{"wrong call", `{"call_id":"call-18","verdict":"allow","actions":[]}`, false},
{"trailing value", `{"call_id":"call-17","verdict":"allow","actions":[]} {}`, false},
}
for _, test := range cases {
_, err := admit([]byte(test.body), "call-17")
if (err == nil) != test.accept { panic(test.name) }
}
fmt.Println("8 admission checks passed; no CRM writes performed")
}
The 64 KiB limit is an example response budget. Enforce a transport read limit before buffering in a real client; checking a slice's length cannot undo an allocation that already happened. The duplicate-key pass is deliberate because the Go JSON decoder documents handling repeated keys, while RFC 8259 warns that receivers can disagree about duplicate member names.
There is another boundary to keep explicit: Go's decoder matches struct keys without regard to case. If exact property spelling is part of the external contract, validate the raw object against that contract before this typed admission step. For a JSON Schema contract, define required properties, allowed values, array item shapes, and the additional-properties policy, pin its dialect, and test the actual validator. Typed decoding alone does not prove schema conformance.
A passing result still authorizes no write.
The write consumer needs authenticated account context, evidence resolution, and an idempotency mechanism using a stable action identifier across retries. Persist the accepted decision and its policy version before attempting a side effect so a timeout can be investigated without asking the model to reinvent the action.
4. Roll out against correctness and queue budgets
Use the executable cases as boundary checks, then build a labeled evaluation set from approved, appropriately handled transcripts. Include the Friday-delivery ambiguity, quoted abusive language, negated commitments, speaker corrections, missing turns, and repeated delivery of the same job. Label moderation outcomes and permissible CRM actions separately. Otherwise a correct moderation label can conceal a bad extraction.
A proposed rollout policy could require every parser rejection and every unresolved evidence reference to produce zero automatic writes, while reserving a separate SLO for the time to an authorized action. Choose numerical latency and error-budget targets from the business deadline and measured traffic; this note supplies neither production measurements nor a universal target. Report incorrect accepted actions, missed permissible actions, review arrivals, and age of the oldest review item alongside throughput. An empty error log is insufficient evidence.
Deploy through a shadow stage that records decisions without writing CRM actions. Compare those decisions against labels, inspect disagreements, and only then enable a bounded automatic lane with a rollback switch. Bound retries and keep them inside the job deadline: repeated invalid output must terminate in a recorded rejection or review item rather than an unbounded attempt to obtain acceptable JSON.
This advice has a limit. If the output is a draft summary shown to a human and never triggers a write, the transaction machinery may be disproportionate. If the workflow can create a binding delivery commitment, the small follow-up contract above is insufficient and needs explicit approval controls. The decision rule remains structured output correctness under the real authorization policy, with latency and operating effort measured around that rule.
Sources
References for the parsing and validation boundaries discussed above:
Top comments (0)