diff options
| author | sigoden <sigoden@gmail.com> | 2024-12-13 19:43:38 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-13 19:43:38 +0800 |
| commit | 737580bb87f3b1d2f040dd7a4ddacca3595915a0 (patch) | |
| tree | 7b8a43dd84e425abca352b98c564392cf7d6fac6 /src/config/mod.rs | |
| parent | c0f34d45319f1f3e9d0db21b591a452eacfca21a (diff) | |
| download | aichat-737580bb87f3b1d2f040dd7a4ddacca3595915a0.tar.gz | |
fix: agent variables don't initialized if start session with last message (#1054)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index f82cecc..48ca390 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1047,8 +1047,10 @@ impl Config { } } } + let mut new_session = false; if let Some(session) = session.as_mut() { if session.is_empty() { + new_session = true; if let Some((input, output)) = &self.last_message { if self.agent.is_some() == input.with_agent() { let ans = Confirm::new( @@ -1064,7 +1066,7 @@ impl Config { } } self.session = session; - self.init_agent_session_variables()?; + self.init_agent_session_variables(new_session)?; Ok(()) } @@ -2033,12 +2035,12 @@ impl Config { Ok(()) } - fn init_agent_session_variables(&mut self) -> Result<()> { + fn init_agent_session_variables(&mut self, new_session: bool) -> Result<()> { let (agent, session) = match (self.agent.as_mut(), self.session.as_mut()) { (Some(agent), Some(session)) => (agent, session), _ => return Ok(()), }; - if session.is_empty() { + if new_session { let shared_variables = agent.shared_variables().clone(); let session_variables = if !agent.defined_variables().is_empty() && shared_variables.is_empty() { |
