mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
fix agent description and pre-commit
This commit is contained in:
parent
974141b539
commit
07208f95ab
5 changed files with 15 additions and 48 deletions
|
|
@ -2,7 +2,7 @@
|
|||
nodaemon=true
|
||||
|
||||
[program:brightstaff]
|
||||
command=sh -c "RUST_LOG=debug /app/brightstaff 2>&1 | tee /var/log/brightstaff.log | while IFS= read -r line; do echo '[brightstaff]' \"$line\"; done"
|
||||
command=sh -c "RUST_LOG=info /app/brightstaff 2>&1 | tee /var/log/brightstaff.log | while IFS= read -r line; do echo '[brightstaff]' \"$line\"; done"
|
||||
stdout_logfile=/dev/stdout
|
||||
redirect_stderr=true
|
||||
stdout_logfile_maxbytes=0
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ async fn handle_agent_chat(
|
|||
&chat_completions_request.messages,
|
||||
&listener,
|
||||
trace_parent,
|
||||
&agent_map,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ impl AgentSelector {
|
|||
messages: &[Message],
|
||||
listener: &Listener,
|
||||
trace_parent: Option<String>,
|
||||
agent_map: &HashMap<String, Agent>,
|
||||
) -> Result<AgentFilterChain, AgentSelectionError> {
|
||||
let agents = listener
|
||||
.agents
|
||||
|
|
@ -83,7 +82,7 @@ impl AgentSelector {
|
|||
}
|
||||
|
||||
let usage_preferences = self
|
||||
.convert_agent_description_to_routing_preferences(agents, agent_map)
|
||||
.convert_agent_description_to_routing_preferences(agents)
|
||||
.await;
|
||||
debug!(
|
||||
"Agents usage preferences for agent routing str: {}",
|
||||
|
|
@ -142,40 +141,15 @@ impl AgentSelector {
|
|||
async fn convert_agent_description_to_routing_preferences(
|
||||
&self,
|
||||
agents: &[AgentFilterChain],
|
||||
agent_map: &HashMap<String, Agent>,
|
||||
) -> Vec<ModelUsagePreference> {
|
||||
let mut preferences = Vec::new();
|
||||
|
||||
for agent_chain in agents {
|
||||
// Get the actual agent from the agent_map
|
||||
let agent = agent_map.get(&agent_chain.id);
|
||||
|
||||
// Determine the description to use
|
||||
let description = if let Some(agent) = agent {
|
||||
// Check if this is an MCP agent (URL starts with mcp://)
|
||||
if agent.url.starts_with("mcp://") {
|
||||
debug!(
|
||||
"Agent {} is an MCP agent, fetching tool description from: {}",
|
||||
agent.id, agent.url
|
||||
);
|
||||
|
||||
//TODO: fetch description from mcp server
|
||||
|
||||
"MCP tool description placeholder from config".to_string()
|
||||
} else {
|
||||
// Not an MCP agent, use description from config
|
||||
agent_chain.description.clone().unwrap_or_default()
|
||||
}
|
||||
} else {
|
||||
// Agent not found in map, use description from config
|
||||
agent_chain.description.clone().unwrap_or_default()
|
||||
};
|
||||
|
||||
preferences.push(ModelUsagePreference {
|
||||
model: agent_chain.id.clone(),
|
||||
routing_preferences: vec![RoutingPreference {
|
||||
name: agent_chain.id.clone(),
|
||||
description,
|
||||
description: agent_chain.description.clone().unwrap_or_default(),
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
|
@ -288,14 +262,8 @@ mod tests {
|
|||
create_test_agent("agent2", "Second agent description", false),
|
||||
];
|
||||
|
||||
let agent_structs = vec![
|
||||
create_test_agent_struct("agent1"),
|
||||
create_test_agent_struct("agent2"),
|
||||
];
|
||||
let agent_map = selector.create_agent_map(&agent_structs);
|
||||
|
||||
let preferences = selector
|
||||
.convert_agent_description_to_routing_preferences(&agents, &agent_map)
|
||||
.convert_agent_description_to_routing_preferences(&agents)
|
||||
.await;
|
||||
|
||||
assert_eq!(preferences.len(), 2);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ impl PipelineProcessor {
|
|||
|
||||
let start_time = SystemTime::now();
|
||||
let start_instant = Instant::now();
|
||||
|
||||
|
||||
// Extract trace context from OpenTelemetry
|
||||
let current_cx = opentelemetry::Context::current();
|
||||
let span_ref = current_cx.span();
|
||||
|
|
@ -118,11 +118,11 @@ impl PipelineProcessor {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
|
||||
chat_history_updated = self
|
||||
.execute_filter(&chat_history_updated, agent, request_headers)
|
||||
.await?;
|
||||
|
||||
|
||||
let end_time = SystemTime::now();
|
||||
let elapsed = start_instant.elapsed();
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ impl PipelineProcessor {
|
|||
elapsed.as_secs_f64() * 1000.0,
|
||||
chat_history_updated.len()
|
||||
);
|
||||
|
||||
|
||||
// Build span with trace context
|
||||
if let Some(collector) = trace_collector {
|
||||
let mut span_builder = SpanBuilder::new(format!("filter_execution: {}", agent_name))
|
||||
|
|
@ -142,14 +142,14 @@ impl PipelineProcessor {
|
|||
.with_attribute("filter_name", agent_name.to_string())
|
||||
.with_attribute("tool_name", tool_name.to_string())
|
||||
.with_attribute("duration_ms", format!("{:.2}", elapsed.as_secs_f64() * 1000.0));
|
||||
|
||||
|
||||
if !trace_id.is_empty() {
|
||||
span_builder = span_builder.with_trace_id(trace_id);
|
||||
}
|
||||
if let Some(parent_id) = parent_span_id {
|
||||
span_builder = span_builder.with_parent_span_id(parent_id);
|
||||
}
|
||||
|
||||
|
||||
let span = span_builder.build();
|
||||
collector.record_span("brightstaff", span);
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ impl PipelineProcessor {
|
|||
) -> Result<HeaderMap, PipelineError> {
|
||||
let mut headers = request_headers.clone();
|
||||
headers.remove(hyper::header::CONTENT_LENGTH);
|
||||
|
||||
|
||||
headers.insert(
|
||||
ARCH_UPSTREAM_HOST_HEADER,
|
||||
hyper::header::HeaderValue::from_str(agent_id)
|
||||
|
|
@ -249,7 +249,7 @@ impl PipelineProcessor {
|
|||
agent_id: &str,
|
||||
) -> Result<reqwest::Response, PipelineError> {
|
||||
let request_body = serde_json::to_string(json_rpc_request)?;
|
||||
|
||||
|
||||
debug!("Sending MCP request to agent {}: {}", agent_id, request_body);
|
||||
|
||||
let response = self
|
||||
|
|
@ -420,7 +420,7 @@ impl PipelineProcessor {
|
|||
debug!("Sending initialized notification for agent {}", agent_id);
|
||||
|
||||
let headers = self.build_mcp_headers(&HeaderMap::new(), agent_id, Some(session_id))?;
|
||||
|
||||
|
||||
let response = self
|
||||
.client
|
||||
.post(format!("{}/mcp", self.url))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Each agent runs as an independent MCP server and exposes tools that can be calle
|
|||
- **Description**: Rewrites user queries using LLM for better retrieval
|
||||
- **Port**: 10500
|
||||
|
||||
### Context Builder Agent
|
||||
### Context Builder Agent
|
||||
- **Tool**: `chat_completions`
|
||||
- **Description**: Augments queries with relevant context from knowledge base
|
||||
- **Port**: 10501
|
||||
|
|
@ -76,7 +76,7 @@ agent_filters:
|
|||
- id: query_rewriter
|
||||
url: mcp://host.docker.internal:10500
|
||||
tool: rewrite_query_with_archgw # MCP tool name
|
||||
|
||||
|
||||
- id: context_builder
|
||||
url: mcp://host.docker.internal:10501
|
||||
tool: chat_completions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue