Skip to main content

Output Controls

Financial Compliance

financial-compliance checks model answers for financial phrases. It blocks an answer that contains a phrase you list, such as "guaranteed return", and puts a disclaimer in front of an answer that looks like investment advice.

It does not check that a financial statement is correct or suitable for a person, and it does not make you compliant with a regulation. It runs only with stream: false.

Configuration​

Save this as policy-config.yaml and apply it to a test agent with the config-first workflow.

policy-config.yaml
pack:
  name: financial-compliance-example
  version: 1.0.0
  enabled: true
policies:
  chain:
    - financial-compliance
policy:
  financial-compliance:
    blocked_patterns:
      - you should buy
      - you should sell
      - guaranteed return
      - strong buy
      - strong sell
    required_disclaimers:
      - This is not financial advice.
      - >-
        Consult a qualified financial advisor before making
        investment decisions.

Verify the result​

Use controlled provider responses: telling a model to return a phrase does not guarantee that it does.

Provider responseResult
This has a guaranteed return.Blocked with financial.blocked. The client gets no text.
Buy a ticket.Disclaimer added with financial.disclaimer_injected, a false match
Hello.Returned unchanged with financial.clean

Compare the client response with the nested result in the runtime event.

Fields​

FieldTypeDefaultDescription
blocked_patternslist of strings[]Literal substrings that block the answer. Case does not matter. Not regular expressions.
required_disclaimerslist of strings[]Lines joined with line breaks and put before an answer that looks like advice. Empty uses This is not financial advice.

How it works​

  1. The gateway takes the text of the complete model response.
  2. The control lowercases it and looks for each blocked_patterns entry. A match blocks with financial.blocked.
  3. Otherwise, text that contains buy , sell , you should invest, guaranteed returns, target price, strong buy, or strong sell counts as advice.
  4. Advice that does not already start with the disclaimer gets the disclaimer and two line breaks in front of it, with financial.disclaimer_injected.
  5. Anything else is returned with financial.clean.

The details contain looks_like_advice and disclaimer_injected, or blocked: true.

Phase and verdicts​

ItemValue
Phaseoutput
Request familiesChat Completions, Completions, Responses, Messages
Verdictsallow, block
Reason codesfinancial.clean, financial.disclaimer_injected, financial.blocked

Examples​

Disclaimer only:

Inside policy-config.yaml
policy:
  financial-compliance:
    required_disclaimers:
      - This is not financial advice.
      - Review any financial decisions with a licensed advisor.

Block strong recommendations and price targets:

Inside policy-config.yaml
policy:
  financial-compliance:
    blocked_patterns:
      - you should buy
      - target price
      - guaranteed return
    required_disclaimers:
      - This is not financial advice.

Limits and failure behavior​

  • A block returns HTTP 400 with error code content_policy_violation.
  • The advice check matches substrings: buy a ticket and sell your car get a disclaimer.
  • The control compares the start of the answer with your full disclaimer. An answer that starts with a different disclaimer still gets yours.
  • blocked_patterns also matches inside longer words and in quoted or negated text: strong buy matches this is not a strong buy.
  • With stream: true, the gateway buffers the response but does not run the control.
  • There is no action field. For a disclaimer-only setup, leave blocked_patterns empty.
  • A when condition does not limit this control. Use routes.

Next steps​