No Model Requests • AI Agent SDK
no_model_requests: Block real model requests for the duration of the “with“ block.
no_model_requests
Function
</div>
This function is defined in the guard module.
Block real model requests for the duration of the `with` block.
Composes with a suite-wide :func:allow_model_requests call and with other `no_model_requests` blocks. Rather than saving and restoring the global flag — which lets an inner or cross-thread scope exiting first re-enable requests while an outer scope is still open — this increments a block counter, so requests stay blocked until every open scope has exited::
with no_model_requests(): agent.start(“hello”) # raises ModelRequestBlocked
Signature
def no_model_requests() -> Iterator[None]Returns
ResponseField
Iterator[None]The result of the operation.
Source
View on GitHubpraisonaiagents/model_harness/guard.py at line 140