cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 2 · Before the model › model allow-list

Agent Harness Tutorial · End to end · Zoom level 3

How we take care of it: model allow-list

model allow-list catches any model but gpt-oss-120b.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readsthe model name in every request toAPIMmodel allow-listrule · Azure APIMpassCarries onfailIf it fails403 model_not_allowedWHERE IN THE CODE: infra/policies/groq-api.xml:24
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. The APIM policy lets through only openai/gpt-oss-120b.
  2. It runs whoever calls APIM, even a script that skips the harness.
It readsthe model name in every request to APIM
Kindrule
Provided byAzure APIM
If it fails403 model_not_allowed
Where in the codeinfra/policies/groq-api.xml:24
Runs at2 · Before the model
Real exampleFlow 18: a call for llama-3.3-70b got 403 in 250 ms.

More on this: The APIM gateway.

How it is done: the real code

Cut from the live repositories each time the site is built, so it always matches what runs.

    <!-- Tier 4a A8: only an allowed model gets through. Checked first, so a refused
         request costs no Content Safety call and no tokens. The agent checks the
         same list (approved_models); this is the second wall, at the door. -->
    <set-variable name="model" value="@{
        var body = context.Request.Body.As<JObject>(preserveContent: true);
        return body == null ? "" : ((string)body["model"] ?? "");
    }" />
    <choose>
      <when condition="@(!"{{allowed-models}}".Split(',').Select(m => m.Trim()).Contains((string)context.Variables["model"]))">
        <return-response>
          <set-status code="403" reason="Model not allowed" />
          <set-header name="x-content-safety" exists-action="override"><value>skipped; prompt=skipped; completion=skipped</value></set-header>
          <set-header name="Content-Type" exists-action="override"><value>application/json</value></set-header>
          <set-body>@(new JObject(new JProperty("error", new JObject(new JProperty("code", "model_not_allowed"), new JProperty("message", "This agent may not use model '" + (string)context.Variables["model"] + "'.")))).ToString())</set-body>
        </return-response>
      </when>
    </choose>