ReqLLM-specific adapter helpers for the native provider.
MingaAgent.Providers.Native owns orchestration policy: turn flow, retry, cost, compaction, approvals, tool coordination, context updates, and event normalization. This module owns the ReqLLM-shaped details needed to make one provider request and decode one provider response.
Summary
Types
Streaming LLM client compatible with ReqLLM.stream_text/3.
Raw ReqLLM usage payload before Native normalizes it into TurnUsage.
Callbacks used while streaming a provider response.
Neutralized tool-call payload emitted by ReqLLM streaming.
Decoded result from one provider response.
Functions
Returns true when the exact route's source model provider is Anthropic.
Creates a ReqLLM tool-call value for assistant messages.
Returns the default ReqLLM streaming client.
Processes a ReqLLM stream response into a neutral turn result.
Runs one ReqLLM streaming request attempt. Retry ownership stays in Native.
Builds request-local options from one immutable resolved selection.
Builds the summary callback expected by the compaction subsystem.
Builds the provider-specific tool value for a canonical tool declaration.
Validates an already-resolved model selection before ReqLLM sees it.
Types
@type llm_client() :: (LLMDB.Model.t(), [ReqLLM.Message.t()], keyword() -> {:ok, ReqLLM.StreamResponse.t()} | {:error, term()})
Streaming LLM client compatible with ReqLLM.stream_text/3.
@type raw_usage() :: %{ optional(:input_tokens) => non_neg_integer(), optional(:output_tokens) => non_neg_integer(), optional(:input) => non_neg_integer(), optional(:output) => non_neg_integer(), optional(:cache_read_input_tokens) => non_neg_integer(), optional(:cache_creation_input_tokens) => non_neg_integer(), optional(:cached_input) => non_neg_integer(), optional(:cached_tokens) => non_neg_integer(), optional(:cache_creation) => non_neg_integer(), optional(:cache_creation_tokens) => non_neg_integer(), optional(:cache_read) => non_neg_integer(), optional(:cache_write) => non_neg_integer(), optional(:total_cost) => number(), optional(:cost) => number() }
Raw ReqLLM usage payload before Native normalizes it into TurnUsage.
@type stream_callbacks() :: [ on_text: (String.t() -> term()), on_thinking: (String.t() -> term()), on_tool_call: (tool_call() -> term()) ]
Callbacks used while streaming a provider response.
@type tool_call() :: MingaAgent.Providers.Native.ReqLLMAdapter.ToolCall.t()
Neutralized tool-call payload emitted by ReqLLM streaming.
@type turn_result() :: MingaAgent.Providers.Native.ReqLLMAdapter.TurnResult.t()
Decoded result from one provider response.
Functions
@spec anthropic_model?(MingaAgent.ModelSelection.t()) :: boolean()
Returns true when the exact route's source model provider is Anthropic.
@spec assistant_tool_call(String.t(), String.t(), map()) :: ReqLLM.ToolCall.t()
Creates a ReqLLM tool-call value for assistant messages.
@spec default_client() :: llm_client()
Returns the default ReqLLM streaming client.
@spec process_stream(ReqLLM.StreamResponse.t(), stream_callbacks()) :: {:ok, turn_result()} | {:error, term(), String.t()}
Processes a ReqLLM stream response into a neutral turn result.
@spec stream(llm_client(), LLMDB.Model.t(), [ReqLLM.Message.t()], keyword()) :: {:ok, ReqLLM.StreamResponse.t()} | {:error, term()}
Runs one ReqLLM streaming request attempt. Retry ownership stays in Native.
@spec stream_opts( MingaAgent.ModelSelection.t(), [ReqLLM.Tool.t()], MingaAgent.Config.t(), keyword() ) :: {:ok, keyword()} | {:error, {:credential_unavailable, String.t()}}
Builds request-local options from one immutable resolved selection.
@spec summary_client( llm_client(), MingaAgent.ModelSelection.t(), MingaAgent.Config.t(), keyword() ) :: MingaAgent.Compaction.summary_fn()
Builds the summary callback expected by the compaction subsystem.
@spec tool(MingaAgent.Tool.Spec.t(), MingaAgent.Tool.Spec.callback(), map()) :: ReqLLM.Tool.t()
Builds the provider-specific tool value for a canonical tool declaration.
@spec validate_selection(MingaAgent.ModelSelection.t()) :: :ok | {:error, String.t(), :invalid_selection}
Validates an already-resolved model selection before ReqLLM sees it.