pub trait HttpAgentAdapter:
Send
+ Sync
+ 'static {
// Required methods
fn provider_name(&self) -> &'static str;
fn endpoint_url(&self, model: &str) -> String;
fn auth_headers(&self) -> Vec<(String, String)>;
fn build_request(&self, config: &AgentConfig) -> Result<Value, AgentError>;
fn parse_response(
&self,
body: &Value,
config: &AgentConfig,
) -> Result<TurnResult, AgentError>;
fn parse_sse_line(&self, line: &str) -> Option<SseDelta>;
fn fold_sse_deltas(
&self,
deltas: Vec<SseDelta>,
config: &AgentConfig,
) -> Result<TurnResult, AgentError>;
fn compute_cost(
&self,
model: &str,
input_tokens: u64,
output_tokens: u64,
) -> Option<f64>;
fn resolve_model(&self, model: &str) -> String;
}Expand description
Internal trait implemented by each HTTP provider backend.
The generic HttpAgentProvider calls these methods to build requests,
parse responses, and configure authentication. The agentic loop, retry,
and timeout are handled by the wrapper.
Required Methods§
Sourcefn provider_name(&self) -> &'static str
fn provider_name(&self) -> &'static str
Provider name for logging and errors.
Sourcefn endpoint_url(&self, model: &str) -> String
fn endpoint_url(&self, model: &str) -> String
Full endpoint URL for the given model.
Sourcefn auth_headers(&self) -> Vec<(String, String)>
fn auth_headers(&self) -> Vec<(String, String)>
Authentication and provider-specific headers.
Sourcefn build_request(&self, config: &AgentConfig) -> Result<Value, AgentError>
fn build_request(&self, config: &AgentConfig) -> Result<Value, AgentError>
Build the initial JSON request body from an AgentConfig.
Sourcefn parse_response(
&self,
body: &Value,
config: &AgentConfig,
) -> Result<TurnResult, AgentError>
fn parse_response( &self, body: &Value, config: &AgentConfig, ) -> Result<TurnResult, AgentError>
Parse a non-streaming response body into a TurnResult.
Sourcefn parse_sse_line(&self, line: &str) -> Option<SseDelta>
fn parse_sse_line(&self, line: &str) -> Option<SseDelta>
Parse a single SSE data: line into a streaming delta.
Sourcefn fold_sse_deltas(
&self,
deltas: Vec<SseDelta>,
config: &AgentConfig,
) -> Result<TurnResult, AgentError>
fn fold_sse_deltas( &self, deltas: Vec<SseDelta>, config: &AgentConfig, ) -> Result<TurnResult, AgentError>
Fold accumulated SSE deltas into a complete TurnResult.
Sourcefn compute_cost(
&self,
model: &str,
input_tokens: u64,
output_tokens: u64,
) -> Option<f64>
fn compute_cost( &self, model: &str, input_tokens: u64, output_tokens: u64, ) -> Option<f64>
Compute cost in USD from token counts. Returns None if unknown.
Sourcefn resolve_model(&self, model: &str) -> String
fn resolve_model(&self, model: &str) -> String
Resolve model alias (e.g. “sonnet”) to a provider-specific model ID.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".