more pr feedback changes

This commit is contained in:
Adil Hafeez 2025-10-13 15:23:01 -07:00
parent e498b41e5b
commit 07bb26c1d9
6 changed files with 24 additions and 24 deletions

View file

@ -321,7 +321,7 @@ static_resources:
random_sampling:
value: {{ arch_tracing.random_sampling }}
{% endif %}
stat_prefix: agents_traffic
stat_prefix: {{ listener.name | replace(" ", "_") }}_traffic
codec_type: AUTO
scheme_header_transformation:
scheme_to_overwrite: https

View file

@ -14,7 +14,7 @@ use crate::router::llm_router::RouterService;
/// Main errors for agent chat completions
#[derive(Debug, thiserror::Error)]
pub enum AgentChatError {
pub enum AgentFilterChainError {
#[error("Agent selection error: {0}")]
Selection(#[from] AgentSelectionError),
#[error("Pipeline processing error: {0}")]
@ -51,7 +51,7 @@ async fn handle_agent_chat(
router_service: Arc<RouterService>,
agents_list: Arc<tokio::sync::RwLock<Option<Vec<common::configuration::Agent>>>>,
listeners: Arc<tokio::sync::RwLock<Vec<common::configuration::Listener>>>,
) -> Result<Response<BoxBody<Bytes, hyper::Error>>, AgentChatError> {
) -> Result<Response<BoxBody<Bytes, hyper::Error>>, AgentFilterChainError> {
// Initialize services
let agent_selector = AgentSelector::new(router_service);
let pipeline_processor = PipelineProcessor::default();
@ -88,7 +88,7 @@ async fn handle_agent_chat(
"Failed to parse request body as ChatCompletionsRequest: {}",
err
);
AgentChatError::RequestParsing(err)
AgentFilterChainError::RequestParsing(err)
})?;
// Extract trace parent for routing
@ -141,5 +141,5 @@ async fn handle_agent_chat(
response_handler
.create_streaming_response(llm_response)
.await
.map_err(AgentChatError::from)
.map_err(AgentFilterChainError::from)
}

View file

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use common::configuration::{
Agent, AgentPipeline, Listener, ModelUsagePreference, RoutingPreference,
Agent, AgentFilterChain, Listener, ModelUsagePreference, RoutingPreference,
};
use hermesllm::apis::openai::Message;
use tracing::{debug, warn};
@ -65,7 +65,7 @@ impl AgentSelector {
messages: &[Message],
listener: &Listener,
trace_parent: Option<String>,
) -> Result<AgentPipeline, AgentSelectionError> {
) -> Result<AgentFilterChain, AgentSelectionError> {
let agents = listener
.agents
.as_ref()
@ -113,9 +113,9 @@ impl AgentSelector {
/// Get the default agent or the first agent if no default is specified
fn get_default_agent(
&self,
agents: &[AgentPipeline],
agents: &[AgentFilterChain],
listener_name: &str,
) -> Result<AgentPipeline, AgentSelectionError> {
) -> Result<AgentFilterChain, AgentSelectionError> {
agents
.iter()
.find(|a| a.default.unwrap_or(false))
@ -133,7 +133,7 @@ impl AgentSelector {
/// Convert agent descriptions to routing preferences
fn convert_agent_description_to_routing_preferences(
&self,
agents: &[AgentPipeline],
agents: &[AgentFilterChain],
) -> Vec<ModelUsagePreference> {
agents
.iter()
@ -151,7 +151,7 @@ impl AgentSelector {
#[cfg(test)]
mod tests {
use super::*;
use common::configuration::{AgentPipeline, Listener};
use common::configuration::{AgentFilterChain, Listener};
fn create_test_router_service() -> Arc<RouterService> {
Arc::new(RouterService::new(
@ -162,8 +162,8 @@ mod tests {
))
}
fn create_test_agent(name: &str, description: &str, is_default: bool) -> AgentPipeline {
AgentPipeline {
fn create_test_agent(name: &str, description: &str, is_default: bool) -> AgentFilterChain {
AgentFilterChain {
id: name.to_string(),
description: Some(description.to_string()),
default: Some(is_default),
@ -171,7 +171,7 @@ mod tests {
}
}
fn create_test_listener(name: &str, agents: Vec<AgentPipeline>) -> Listener {
fn create_test_listener(name: &str, agents: Vec<AgentFilterChain>) -> Listener {
Listener {
name: name.to_string(),
agents: Some(agents),

View file

@ -16,7 +16,7 @@ use crate::router::llm_router::RouterService;
#[cfg(test)]
mod integration_tests {
use super::*;
use common::configuration::{Agent, AgentPipeline, Listener};
use common::configuration::{Agent, AgentFilterChain, Listener};
fn create_test_router_service() -> Arc<RouterService> {
Arc::new(RouterService::new(
@ -58,7 +58,7 @@ mod integration_tests {
},
];
let agent_pipeline = AgentPipeline {
let agent_pipeline = AgentFilterChain {
id: "terminal-agent".to_string(),
filter_chain: vec!["filter-agent".to_string(), "terminal-agent".to_string()],
description: Some("Test pipeline".to_string()),
@ -98,7 +98,7 @@ mod integration_tests {
};
// Create a pipeline with empty filter chain to avoid network calls
let test_pipeline = AgentPipeline {
let test_pipeline = AgentFilterChain {
id: "terminal-agent".to_string(),
filter_chain: vec![], // Empty filter chain - no network calls needed
description: None,

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use common::configuration::{Agent, AgentPipeline};
use common::configuration::{Agent, AgentFilterChain};
use common::consts::{ARCH_UPSTREAM_HOST_HEADER, ENVOY_RETRY_HEADER};
use hermesllm::apis::openai::{ChatCompletionsRequest, Message};
use hyper::header::HeaderMap;
@ -48,13 +48,13 @@ impl PipelineProcessor {
pub async fn process_filter_chain(
&self,
initial_request: &ChatCompletionsRequest,
agent_pipeline: &AgentPipeline,
agent_filter_chain: &AgentFilterChain,
agent_map: &HashMap<String, Agent>,
request_headers: &HeaderMap,
) -> Result<Vec<Message>, PipelineError> {
let mut chat_completions_history = initial_request.messages.clone();
for agent_name in &agent_pipeline.filter_chain {
for agent_name in &agent_filter_chain.filter_chain {
debug!("Processing filter agent: {}", agent_name);
let agent = agent_map
@ -195,8 +195,8 @@ mod tests {
}
}
fn create_test_pipeline(agents: Vec<&str>) -> AgentPipeline {
AgentPipeline {
fn create_test_pipeline(agents: Vec<&str>) -> AgentFilterChain {
AgentFilterChain {
id: "test-agent".to_string(),
filter_chain: agents.iter().map(|s| s.to_string()).collect(),
description: None,

View file

@ -26,7 +26,7 @@ pub struct Agent {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentPipeline {
pub struct AgentFilterChain {
pub id: String,
pub default: Option<bool>,
pub description: Option<String>,
@ -37,7 +37,7 @@ pub struct AgentPipeline {
pub struct Listener {
pub name: String,
pub router: Option<String>,
pub agents: Option<Vec<AgentPipeline>>,
pub agents: Option<Vec<AgentFilterChain>>,
pub port: u16,
}