fix: Fixed a bug where --agent-variable values were not being passed to the agents
This commit is contained in:
@@ -204,6 +204,7 @@ impl Agent {
|
||||
|
||||
pub fn init_agent_variables(
|
||||
agent_variables: &[AgentVariable],
|
||||
pre_set_variables: Option<&AgentVariables>,
|
||||
no_interaction: bool,
|
||||
) -> Result<AgentVariables> {
|
||||
let mut output = IndexMap::new();
|
||||
@@ -214,6 +215,10 @@ impl Agent {
|
||||
let mut unset_variables = vec![];
|
||||
for agent_variable in agent_variables {
|
||||
let key = agent_variable.name.clone();
|
||||
if let Some(value) = pre_set_variables.and_then(|v| v.get(&key)) {
|
||||
output.insert(key, value.clone());
|
||||
continue;
|
||||
}
|
||||
if let Some(value) = agent_variable.default.clone() {
|
||||
output.insert(key, value);
|
||||
continue;
|
||||
|
||||
+10
-4
@@ -2607,8 +2607,11 @@ impl Config {
|
||||
None => return Ok(()),
|
||||
};
|
||||
if !agent.defined_variables().is_empty() && agent.shared_variables().is_empty() {
|
||||
let new_variables =
|
||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
||||
let new_variables = Agent::init_agent_variables(
|
||||
agent.defined_variables(),
|
||||
self.agent_variables.as_ref(),
|
||||
self.info_flag,
|
||||
)?;
|
||||
agent.set_shared_variables(new_variables);
|
||||
}
|
||||
if !self.info_flag {
|
||||
@@ -2626,8 +2629,11 @@ impl Config {
|
||||
let shared_variables = agent.shared_variables().clone();
|
||||
let session_variables =
|
||||
if !agent.defined_variables().is_empty() && shared_variables.is_empty() {
|
||||
let new_variables =
|
||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
||||
let new_variables = Agent::init_agent_variables(
|
||||
agent.defined_variables(),
|
||||
self.agent_variables.as_ref(),
|
||||
self.info_flag,
|
||||
)?;
|
||||
agent.set_shared_variables(new_variables.clone());
|
||||
new_variables
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user