Hashtag and caption limits in a Sume output schema, checked post-run
Use pattern, maxItems and maxLength in a Sume output_schema so captions and hashtags are checked after the run. A violation returns null output, not bad data.

Can a Sume schema enforce a hashtag format and a caption length?
Yes. The structured-output subset enforces pattern, format, minItems, maxItems, minimum, maximum, enum and const, and Sume validates the result after the run with Ajv. A caption with maxLength over the limit, or a sixth hashtag when maxItems is 5, makes the run fail with output_schema_unsatisfied; output is null and output_error says why.
What does the schema look like?
Every object needs additionalProperties: false and every property must be required. The pattern below accepts a hash, then letters, digits or underscores, and nothing else, so spaces and punctuation inside a tag are caught.
{
"type": "object",
"additionalProperties": false,
"required": ["caption", "hashtags"],
"properties": {
"caption": {"type": "string", "minLength": 20, "maxLength": 150},
"hashtags": {
"type": "array", "minItems": 3, "maxItems": 5,
"items": {"type": "string", "pattern": "^#[A-Za-z0-9_]{2,30}$"}
}
}
}
What happens when the agent gets it wrong?
The check is a gate after the run, not a prompt the agent must obey. Your code gets no output from a failed check, so the right reaction is a retry with a clearer instruction, not an import of whatever text came back. Keep the limits in the instruction as well, so the agent aims for them in the first place.
A practical routine is to start with the limits you need today, run five or ten rows, and read which constraint fails most. If one rule fails often, the agent probably cannot see it, so restate it in the instruction. Mind two limits. Platform rules change, so keep the numbers in one place and check the platform's own page before you hard-code them. And pattern is a regular expression on the string: it can enforce shape, not meaning, so it cannot tell a relevant hashtag from an irrelevant one.
- Use
maxItemsfor the tag count andpatternfor each tag's shape. - Set
minLengthso an empty caption is not valid. - Treat
output_schema_unsatisfiedas retryable with a new idempotency key. - Never send
output_schematogether withresponse_format; that is a400.
Sources
Related posts
More in Formats
- Know a Sume bulk batch is done: count terminal webhooks vs item count
A Sume bulk queue has no webhook. Put a webhook_url on each item, verify the signature, dedupe by request_id and count terminal events to the item count.
- Localized video batch: one Sume bulk queue per language
Split a multilingual batch into one Sume bulk queue per language so each language gets its own concurrency, spend cap, idempotency key and retry.
- Make Iterator and Array aggregator: build a Sume bulk items array
In Make, an Iterator splits an array into bundles and an Array aggregator joins them. Use the pair to turn sheet rows into a Sume bulk items array.
- Map Sume bulk queue results back to spreadsheet rows by item index
A Sume bulk queue lists items in the order you submitted. Use each item's index to write results back to the right spreadsheet row, and handle run_id null.
Written by Sume