Skip to content

Commit 54fd6e7

Browse files
author
User
committed
feat: store env context in data/env.txt file
1 parent 7d5452e commit 54fd6e7

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/agent/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ impl AgentContext {
549549
add_env_message(
550550
&mut message,
551551
self.memory_index.clone(),
552+
&self.data_dir,
552553
&self.config.workspace,
553554
self.process_registry.clone(),
554555
)

src/agent/utils.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub async fn add_env_message<'a>(
5151
memory_index: Arc<
5252
tokio::sync::RwLock<InMemoryVectorIndex<rig_fastembed::EmbeddingModel, memory::Entity>>,
5353
>,
54+
data_dir: &'a Path,
5455
workspace: &'a Path,
5556
process_registry: Arc<RwLock<ProcessRegistry>>,
5657
) {
@@ -116,19 +117,19 @@ pub async fn add_env_message<'a>(
116117
)
117118
})
118119
.join("\n");
119-
content.push(UserContent::text(
120-
subst::substitute(
121-
ENV_DETAILS,
122-
&HashMap::from([
123-
("TIME", chrono::Local::now().to_rfc2822().as_str()),
124-
("WORKING_DIR", &workspace),
125-
("MEMORY_ENTRIES", &memory_entries),
126-
("COMMANDS", &commands),
127-
("FILES", files),
128-
]),
129-
)
130-
.unwrap(),
131-
));
120+
let env_content = subst::substitute(
121+
ENV_DETAILS,
122+
&HashMap::from([
123+
("TIME", chrono::Local::now().to_rfc2822().as_str()),
124+
("WORKING_DIR", &workspace),
125+
("MEMORY_ENTRIES", &memory_entries),
126+
("COMMANDS", &commands),
127+
("FILES", files),
128+
]),
129+
)
130+
.unwrap();
131+
fs::write(data_dir.join("env.txt"), &env_content).unwrap();
132+
content.push(UserContent::text(env_content));
132133
}
133134
}
134135

0 commit comments

Comments
 (0)