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.
How we took care of it.
- The APIM policy lets through only openai/gpt-oss-120b.
- It runs whoever calls APIM, even a script that skips the harness.
| It reads | the model name in every request to APIM |
| Kind | rule |
| Provided by | Azure APIM |
| If it fails | 403 model_not_allowed |
| Where in the code | infra/policies/groq-api.xml:24 |
| Runs at | 2 · 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>