11use bytes:: Bytes ;
2- use common:: configuration:: { Agent , AgentFilterChain , Listener , ModelAlias , SpanAttributes } ;
2+ use common:: configuration:: { AgentFilterChain , Listener , ModelAlias , SpanAttributes } ;
33use common:: consts:: {
44 ARCH_IS_STREAMING_HEADER , ARCH_PROVIDER_HINT_HEADER , REQUEST_ID_HEADER , TRACE_PARENT_HEADER ,
55} ;
@@ -46,7 +46,6 @@ pub async fn llm_chat(
4646 span_attributes : Arc < Option < SpanAttributes > > ,
4747 state_storage : Option < Arc < dyn StateStorage > > ,
4848 listeners : Arc < RwLock < Vec < Listener > > > ,
49- agents_list : Arc < RwLock < Option < Vec < Agent > > > > ,
5049) -> Result < Response < BoxBody < Bytes , hyper:: Error > > , hyper:: Error > {
5150 let request_path = request. uri ( ) . path ( ) . to_string ( ) ;
5251 let request_headers = request. headers ( ) . clone ( ) ;
@@ -87,7 +86,6 @@ pub async fn llm_chat(
8786 request_path,
8887 request_headers,
8988 listeners,
90- agents_list,
9189 )
9290 . instrument ( request_span)
9391 . await
@@ -106,7 +104,6 @@ async fn llm_chat_inner(
106104 request_path : String ,
107105 mut request_headers : hyper:: HeaderMap ,
108106 listeners : Arc < RwLock < Vec < Listener > > > ,
109- agents_list : Arc < RwLock < Option < Vec < Agent > > > > ,
110107) -> Result < Response < BoxBody < Bytes , hyper:: Error > > , hyper:: Error > {
111108 // Set service name for LLM operations
112109 set_service_name ( operation_component:: LLM ) ;
@@ -264,22 +261,19 @@ async fn llm_chat_inner(
264261 // Check if any model listener (no agents) has a filter_chain configured
265262 {
266263 let listeners_guard = listeners. read ( ) . await ;
267- let filter_chain : Option < Vec < String > > = listeners_guard
264+ let model_listener = listeners_guard
268265 . iter ( )
269- . find ( |l| l. agents . is_none ( ) && l. filter_chain . is_some ( ) )
270- . and_then ( |l| l. filter_chain . clone ( ) ) ;
266+ . find ( |l| l. agents . is_none ( ) && l. filter_chain . is_some ( ) ) ;
267+
268+ let filter_chain = model_listener. and_then ( |l| l. filter_chain . clone ( ) ) ;
269+ let agent_map = model_listener
270+ . and_then ( |l| l. filter_agents . clone ( ) )
271+ . unwrap_or_default ( ) ;
271272
272273 if let Some ( ref fc) = filter_chain {
273274 if !fc. is_empty ( ) {
274275 debug ! ( filter_chain = ?fc, "processing model listener filter chain" ) ;
275276
276- // Build agent map from agents_list
277- let agents_guard = agents_list. read ( ) . await ;
278- let agent_map: HashMap < String , Agent > = agents_guard
279- . as_ref ( )
280- . map ( |agents| agents. iter ( ) . map ( |a| ( a. id . clone ( ) , a. clone ( ) ) ) . collect ( ) )
281- . unwrap_or_default ( ) ;
282-
283277 // Create a temporary AgentFilterChain to reuse PipelineProcessor
284278 let temp_filter_chain = AgentFilterChain {
285279 id : "model_listener" . to_string ( ) ,
0 commit comments