Compare commits
2
Commits
d6447603bc
...
70b6d51b55
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b6d51b55
|
||
|
|
9e5e8a60f2
|
@@ -573,6 +573,25 @@ impl Agent {
|
|||||||
_ => bail!("No return value from '_instructions' function"),
|
_ => bail!("No return value from '_instructions' function"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn test_new(config: AgentConfig) -> Self {
|
||||||
|
Self {
|
||||||
|
name: config.name.clone(),
|
||||||
|
config,
|
||||||
|
shared_variables: Default::default(),
|
||||||
|
session_variables: None,
|
||||||
|
shared_dynamic_instructions: None,
|
||||||
|
session_dynamic_instructions: None,
|
||||||
|
functions: Functions::default(),
|
||||||
|
rag: None,
|
||||||
|
graph_rags: Default::default(),
|
||||||
|
model: Model::default(),
|
||||||
|
vault: std::sync::Arc::new(Vault::default()),
|
||||||
|
is_graph: false,
|
||||||
|
enabled_tools: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoleLike for Agent {
|
impl RoleLike for Agent {
|
||||||
|
|||||||
@@ -827,7 +827,12 @@ impl RequestContext {
|
|||||||
let mut role = if let Some(session) = self.session.as_ref() {
|
let mut role = if let Some(session) = self.session.as_ref() {
|
||||||
session.to_role()
|
session.to_role()
|
||||||
} else if let Some(agent) = self.agent.as_ref() {
|
} else if let Some(agent) = self.agent.as_ref() {
|
||||||
agent.to_role()
|
let mut role = agent.to_role();
|
||||||
|
if role.reasoning_effort().is_none() {
|
||||||
|
role.set_reasoning_effort(app.reasoning_effort.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
role
|
||||||
} else if let Some(role) = self.role.as_ref() {
|
} else if let Some(role) = self.role.as_ref() {
|
||||||
role.clone()
|
role.clone()
|
||||||
} else {
|
} else {
|
||||||
@@ -4134,6 +4139,7 @@ mod tests {
|
|||||||
use super::super::mcp_factory::McpFactory;
|
use super::super::mcp_factory::McpFactory;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::config::AppState;
|
use crate::config::AppState;
|
||||||
|
use crate::config::agent::AgentConfig;
|
||||||
use crate::function::{ToolCall, skill};
|
use crate::function::{ToolCall, skill};
|
||||||
use crate::mcp::{McpServer, McpServersConfig, McpTransportType};
|
use crate::mcp::{McpServer, McpServersConfig, McpTransportType};
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
@@ -4317,6 +4323,42 @@ mod tests {
|
|||||||
assert_eq!(extracted.name(), "");
|
assert_eq!(extracted.name(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn extract_role_agent_without_reasoning_effort_inherits_app_config() {
|
||||||
|
let mut ctx = create_test_ctx();
|
||||||
|
ctx.agent = Some(Agent::test_new(AgentConfig {
|
||||||
|
name: "test-agent".to_string(),
|
||||||
|
reasoning_effort: None,
|
||||||
|
..AgentConfig::default()
|
||||||
|
}));
|
||||||
|
let app = AppConfig {
|
||||||
|
reasoning_effort: Some("max".to_string()),
|
||||||
|
..AppConfig::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let extracted = ctx.extract_role(&app).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(extracted.reasoning_effort(), Some("max".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn extract_role_agent_with_explicit_reasoning_effort_takes_priority_over_app_config() {
|
||||||
|
let mut ctx = create_test_ctx();
|
||||||
|
ctx.agent = Some(Agent::test_new(AgentConfig {
|
||||||
|
name: "test-agent".to_string(),
|
||||||
|
reasoning_effort: Some("low".to_string()),
|
||||||
|
..AgentConfig::default()
|
||||||
|
}));
|
||||||
|
let app = AppConfig {
|
||||||
|
reasoning_effort: Some("max".to_string()),
|
||||||
|
..AppConfig::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let extracted = ctx.extract_role(&app).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(extracted.reasoning_effort(), Some("low".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_inject_skill_instructions_requires_function_calling() {
|
fn should_inject_skill_instructions_requires_function_calling() {
|
||||||
let app = AppConfig {
|
let app = AppConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user