Mock Provider
The Mock provider is designed for testing purposes, allowing you to develop and test agents without making actual API calls or incurring costs. It returns predictable responses by converting input text to pig latin and generates random embeddings.
Configuration
Basic Setup
Configure the Mock provider in your agent:
class MockAgent < ApplicationAgent
generate_with :mock
# @return [ActiveAgent::Generation]
def ask
prompt(message: params[:message])
end
endBasic Usage Example
response = MockAgent.with(message: "What is ActiveAgent?").ask.generate_nowResponse Example
Configuration File
Set up Mock provider in config/active_agent.yml:
mock: &mock
service: "Mock"
model: "mock-model"Environment Variables
No environment variables are required for the Mock provider. It doesn't make external API calls.
Provider-Specific Parameters
Required Parameters
service- Must be set to "Mock"model- Any string value (e.g., "mock-model") - not used functionally
Optional Parameters
instructions- System instructions (passed through but not enforced)stream- Enable streaming simulation (boolean, default: false)
The Mock provider accepts most standard parameters for compatibility but doesn't enforce them:
temperature,top_p,max_tokens- Accepted but ignoredresponse_format- Accepted but not validated or enforced- Tool/function definitions - Accepted but tools won't be called
Mock-Specific Features
Pig Latin Responses
The Mock provider converts user messages to pig latin for predictable, deterministic output:
test "converts input to pig latin" do
response = MockAgent.with(message: "Hello world").ask.generate_now
doc_example_output(response)
assert response.success?
# Mock provider converts to pig latin
assert_includes response.message.content.downcase, "ello"
endResponse Example
Conversion Rules:
- Words starting with vowels: add "way" to the end ("apple" → "appleway")
- Words starting with consonants: move consonants to end and add "ay" ("hello" → "ellohay")
- Preserves punctuation and capitalization
Offline Development
Work on your application without network connectivity:
test "works offline without API calls" do
# Mock provider doesn't make network requests
response = MockAgent.with(message: "Offline test").ask.generate_now
doc_example_output(response)
assert response.success?
assert_not_nil response.message.content
endResponse Example
Response Structure
Mock responses follow the same structure as real providers for seamless testing:
test "returns proper response structure" do
response = MockAgent.with(message: "Test message").ask.generate_now
doc_example_output(response)
assert_equal "assistant", response.message.role
assert_not_nil response.raw_response
assert_not_nil response.message.content
endResponse Example
Limitations
No Real AI Responses
The Mock provider doesn't use actual AI models. Responses are deterministic pig latin transformations, not intelligent completions.
No Tool Calling
The Mock provider doesn't support function/tool calling. Tools defined in agents using the Mock provider will not be invoked.
Limited Structured Output
The Mock provider accepts structured output parameters but doesn't validate or enforce schemas. Responses will still be pig latin text, not structured JSON.
Related Documentation
- Providers Overview
- Anthropic Provider - Anthropic Claude configuration
- Configuration Guide
- Testing Guide