From 07bb26c1d9fe7707bedaf34383e3ae3eb3a565a0 Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Mon, 13 Oct 2025 15:23:01 -0700 Subject: [PATCH] more pr feedback changes --- arch/envoy.template.yaml | 2 +- .../src/handlers/agent_chat_completions.rs | 8 ++++---- .../brightstaff/src/handlers/agent_selector.rs | 18 +++++++++--------- .../src/handlers/integration_tests.rs | 6 +++--- .../src/handlers/pipeline_processor.rs | 10 +++++----- crates/common/src/configuration.rs | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/arch/envoy.template.yaml b/arch/envoy.template.yaml index 33f6020c..1e60bfd5 100644 --- a/arch/envoy.template.yaml +++ b/arch/envoy.template.yaml @@ -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 diff --git a/crates/brightstaff/src/handlers/agent_chat_completions.rs b/crates/brightstaff/src/handlers/agent_chat_completions.rs index 699bcba8..b0715f5d 100644 --- a/crates/brightstaff/src/handlers/agent_chat_completions.rs +++ b/crates/brightstaff/src/handlers/agent_chat_completions.rs @@ -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, agents_list: Arc>>>, listeners: Arc>>, -) -> Result>, AgentChatError> { +) -> Result>, 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) } diff --git a/crates/brightstaff/src/handlers/agent_selector.rs b/crates/brightstaff/src/handlers/agent_selector.rs index 4e338ebc..0fff1198 100644 --- a/crates/brightstaff/src/handlers/agent_selector.rs +++ b/crates/brightstaff/src/handlers/agent_selector.rs @@ -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, - ) -> Result { + ) -> Result { 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 { + ) -> Result { 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 { 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 { 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) -> Listener { + fn create_test_listener(name: &str, agents: Vec) -> Listener { Listener { name: name.to_string(), agents: Some(agents), diff --git a/crates/brightstaff/src/handlers/integration_tests.rs b/crates/brightstaff/src/handlers/integration_tests.rs index 301e69f7..e09ed4f2 100644 --- a/crates/brightstaff/src/handlers/integration_tests.rs +++ b/crates/brightstaff/src/handlers/integration_tests.rs @@ -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 { 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, diff --git a/crates/brightstaff/src/handlers/pipeline_processor.rs b/crates/brightstaff/src/handlers/pipeline_processor.rs index 8eddf899..b62ce175 100644 --- a/crates/brightstaff/src/handlers/pipeline_processor.rs +++ b/crates/brightstaff/src/handlers/pipeline_processor.rs @@ -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, request_headers: &HeaderMap, ) -> Result, 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, diff --git a/crates/common/src/configuration.rs b/crates/common/src/configuration.rs index 46b5a127..c881afa4 100644 --- a/crates/common/src/configuration.rs +++ b/crates/common/src/configuration.rs @@ -26,7 +26,7 @@ pub struct Agent { } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AgentPipeline { +pub struct AgentFilterChain { pub id: String, pub default: Option, pub description: Option, @@ -37,7 +37,7 @@ pub struct AgentPipeline { pub struct Listener { pub name: String, pub router: Option, - pub agents: Option>, + pub agents: Option>, pub port: u16, }