Mock Provider
Test AI-dependent AL without network or API keys.
"AIOS Mock" ships in AI Open SDK (core). It is an in-memory provider for text and image generation: no HTTP and no API keys.
Core and provider logic that you cover in CI should pass with Mock. Live API keys stay out of the pipeline.
Why it matters
AI calls are side effects. With Mock you assert on prompts, structured output, and tool loops deterministically:
- Tests run without secrets or network
- Failures stay reproducible
- Provider outages do not block CI
Setup
- Depend on AI Open SDK (core).
- Queue the next response (or error / tool call) on the factory.
- Call
"AIOS Client"withMock.Model(...)orMock.ImageModel(...).
Mock: Codeunit "AIOS Mock";
Client: Codeunit "AIOS Client";
Result: Codeunit "AIOS Generate Result";
begin
Mock.SetNextResponse('Hello from mock');
Result := Client.GenerateText(Mock.Model('mock-model'), 'Hello');
end;
The queued response comes back verbatim, which is what makes assertions stable:
Hello from mockSo the test asserts on a known value rather than on whatever a live model happened to say:
Assert.AreEqual('Hello from mock', Result.Output(), 'Unexpected output');Image: Mock.SetNextImageBase64(...) then Client.GenerateImage(Mock.ImageModel(...), ...).
Full factory surface: Mock provider. Contribution rule: mock-provider tests cover provider or client logic you touch. See Contributing.