Skip to content
LakeSharkDocumentation
ANSWERSETS / DOCUMENTATION

Output rules

Choose the API response format and optionally restrict responses to exact approved values.

Open Answers, choose an AnswerSet, then select Output rules. You can see the effective policy without editing it. Select Edit output rules to make a change. Every save creates a new auditable AnswerSet revision.

Output rules have two separate decisions:

  1. Response format: What type of value should the application receive?
  2. Allowed responses: Can any value of that type be returned, or only values you approve?

You do not need JSON knowledge to restrict text or Yes / No answers.

Choose the response format

Format Example API response value Recommended use
Text “Approved” Human-readable answers
Number 42 Counts, measurements, numeric outputs
Yes / No true Binary responses
JSON {“status”:“approved”} Structured API integrations
List of items [“Step 1”,“Step 2”] Multiple short strings

LakeShark applies output type rules on the AnswerSet runtime. Choose JSON rather than just instructing a model to output JSON when your application expects structured data.

Build a dynamic JSON response

For JSON AnswerSets that allow Any valid response, enable Use a JSON response template in the editor. LakeShark can compose JSON from request context, the question, and the resolved answer without another AI call.

For example, a template may assign {"$ref":"context.username"} to the user field and {"$ref":"answer.text"} to the color field. Missing inputs cause a clear error, not a fabricated value. Templates cannot be combined with fixed approved values.

Follow the JSON response templates guide for supported expressions, complete request and response examples, limits, and security considerations.

Choose allowed responses

Any valid response allows responses that conform to the selected format and the configured Knowledge, instructions, and governance.

Only approved values permits exactly the values you enter. When the result does not match, LakeShark rejects it rather than silently adding or inventing another allowed value.

Approved text

Choose Text, then Only approved values. Add one line per allowed result, such as:

  • Approved
  • Needs review
  • Rejected

The values are stored and compared as strings, not parsed as JSON.

Strict JSON references

Under JSON → Only approved values, a single structured entry may contain $ref placeholders:

{"color":{"$ref":"answer.text"}}

LakeShark resolves the raw answer first and assembles {"color":"green"} when the grounded result is green. This enforces the declared JSON structure, not an enumerated set of color values. Only one dynamic entry is supported per list. For exact approved outcomes, use ordinary literal JSON entries with no references. The two modes cannot be mixed in one list.

Read JSON response templates for supported references and error handling.

Approved JSON

Choose JSON, then Only approved values. Each entry is one complete JSON value, not a snippet or comma-separated set.

{"decision":"approved","source":"policy"}

Add another entry for a separate allowed outcome:

{"decision":"needs_review","source":"policy"}

Objects, arrays, quoted JSON strings, numbers, booleans and null are valid JSON values. The editor validates each entry before saving, including duplicate values and size limits. JSON object field order does not create a different approved value.

For a JSON string, include the double quotes: "approved" is a JSON string while {"status":"approved"} is a JSON object.

Approved numeric or Yes / No values

Choose Number and enter allowed numeric results, without units or quotes. For example, 0, 1, and 2 are distinct numbers.

Choose Yes / No and select the allowed values (true, false, or both). Do not enter the text “true” and expect it to be a JSON boolean.

List of items currently supports flexible outputs only in the customer editor. Do not configure fixed lists through this UI. The backend also enforces a workspace-specific list size entitlement.

Edit, save, and test

  1. Open Output rules → Edit output rules.
  2. Choose a response format.
  3. Select Only approved values if you want a fixed list.
  4. Add and validate each allowed value.
  5. Set learning review mode independently of output restrictions.
  6. Save the revision and return to Output rules to inspect the new effective policy.
  7. Open Test and try an allowed response and an unexpected response.

Request attempts to return an unapproved result should fail rather than result in a substituted value. Production application calls use Question Keys through the Question API, which must enforce the AnswerSet’s configured restrictions.

Learning is separate from approved outputs

Knowledge generation and runtime learning can produce draft proposals, but those drafts are not additions to the allowed-value list. Learning promotion and output enforcement are independent controls. Use manual review for sensitive or regulated applications.

Supported limits and troubleshooting

  • At most 50 approved entries
  • Each approved value is limited to 8,192 bytes of serialized JSON
  • The total serialized allowed-value collection is limited to 65,536 bytes
  • Unsupported or malformed JSON is rejected before saving
  • A changed output policy creates an AnswerSet revision

If you cannot save, inspect the message next to the invalid value. Check that a Number is not a quoted string, a boolean is selected correctly, and JSON object keys use double quotes.

For API details, see Answers API. To test with a real application credential, use Question Keys.