Test helpers for driving agents deterministically without an API key.
import Agentix.Test in your test module to get:
install_mock_provider/0— makeAgentix.Test.MockProviderthe active provider and start it.completion/2— build a scripted response spec (text, tool calls, thinking, and an optional structured:object).error/2andtransport_error/1— build a scripted failure spec so the mock provider returns{:error, reason}(an HTTP status error or a connection drop), for exercising the retry path.assert_tool_called/2andassert_suspended_on/2— assert on what the agent durably recorded (the canonical log and pending tool calls), not on internal state, so the assertions hold across a kill/resume.
These run async: false (the mock provider is globally named and the audit/provider
config is process-global).
Summary
Functions
Asserts the conversation is suspended on a pending tool call named tool_name.
Asserts the conversation's log contains a :tool_call event for tool_name.
Builds a response spec for the mock provider.
Builds a failure spec: the next stream/3 call returns {:error, reason} where
reason is a ReqLLM.Error.API.Request carrying status (the HTTP code). Matches
the shape ReqLLM surfaces for 4xx/5xx so Agentix.Retry's classifier sees real data.
Installs the mock provider (sets config :agentix, :provider and starts it).
Safe to call repeatedly — resets the script if already running.
Builds a failure spec for a transport-level error (connection drop / timeout):
stream/3 returns {:error, reason} with status: nil and the transport reason
as the cause — the shape ReqLLM produces when the socket fails before any HTTP status.
Functions
Asserts the conversation is suspended on a pending tool call named tool_name.
Asserts the conversation's log contains a :tool_call event for tool_name.
Builds a response spec for the mock provider.
Options: :tool_calls (a list of {name, arguments_map}), :thinking (reasoning
text), :usage (a usage map), :object (a structured-output value placed in the
finalized message's metadata["object"]). Pass the result to
Agentix.Test.MockProvider.script/1.
@spec error( pos_integer(), keyword() ) :: map()
Builds a failure spec: the next stream/3 call returns {:error, reason} where
reason is a ReqLLM.Error.API.Request carrying status (the HTTP code). Matches
the shape ReqLLM surfaces for 4xx/5xx so Agentix.Retry's classifier sees real data.
Options: :reason (the message string), :retry_after (seconds, placed in the
retry-after response header for the backoff to honor).
@spec install_mock_provider() :: :ok
Installs the mock provider (sets config :agentix, :provider and starts it).
Safe to call repeatedly — resets the script if already running.
Builds a failure spec for a transport-level error (connection drop / timeout):
stream/3 returns {:error, reason} with status: nil and the transport reason
as the cause — the shape ReqLLM produces when the socket fails before any HTTP status.