diff options
| author | sigoden <sigoden@gmail.com> | 2024-11-30 08:40:58 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-30 08:40:58 +0800 |
| commit | 50bbfc4541bf2cb2ecb28f2fed3b9b3ab7d5005b (patch) | |
| tree | 5eaa0a1092320dfceeb980a728cc943f0cc8c258 /src/config/mod.rs | |
| parent | 580b40e895f6b5d4b9ee350bfd0066cfe4ae5bcc (diff) | |
| download | aichat-50bbfc4541bf2cb2ecb28f2fed3b9b3ab7d5005b.tar.gz | |
refactor: improve code regarding tools/agents (#1021)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index e578620..31337cd 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -3,7 +3,7 @@ mod input; mod role; mod session; -pub use self::agent::{list_agents, Agent}; +pub use self::agent::{list_agents, Agent, AgentVariables}; pub use self::input::Input; pub use self::role::{ Role, RoleLike, CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, SHELL_ROLE, @@ -1487,10 +1487,13 @@ impl Config { if parts.len() != 2 { bail!("Usage: .variable <key> <value>"); } - let key = parts[0]; - let value = parts[1]; match self.agent.as_mut() { Some(agent) => { + if let Some(session) = self.session.as_ref() { + session.guard_empty()?; + } + let key = parts[0]; + let value = parts[1]; agent.set_variable(key, value)?; if let Some(session) = self.session.as_mut() { session.sync_agent(agent, true); @@ -2009,9 +2012,6 @@ impl Config { &all_variables, self.print_info_only, )?; - if shared_variables.is_empty() { - agent.set_shared_variables(new_variables.clone()); - } agent.set_session_variables(Some(new_variables)); session.sync_agent(agent, false); Ok(()) |
