move working_stack code to correct file

This commit is contained in:
Kent Overstreet 2026-04-04 17:00:01 -04:00
parent e9d803c4ea
commit 375a8d9738
5 changed files with 24 additions and 30 deletions

View file

@ -29,10 +29,8 @@ use tools::{ToolCall, FunctionCall, summarize_args};
use crate::user::log::ConversationLog;
use crate::agent::api::types::*;
use crate::agent::context::{
ConversationEntry, ContextState, ContextBudget,
working_stack_instructions_path, working_stack_file_path,
};
use crate::agent::context::{ConversationEntry, ContextState, ContextBudget};
use crate::agent::tools::working_stack;
use crate::user::ui_channel::{ContextSection, SharedContextState, StreamTarget, StatusInfo, UiMessage, UiSender};
/// Result of a single agent turn.
@ -720,7 +718,7 @@ impl Agent {
}
// Working stack — instructions + items as children
let instructions = std::fs::read_to_string(working_stack_instructions_path())
let instructions = std::fs::read_to_string(working_stack::instructions_path())
.unwrap_or_default();
let mut stack_children = vec![ContextSection {
name: "Instructions".into(),
@ -941,21 +939,12 @@ impl Agent {
/// Called after any change to context state (working stack, etc).
fn refresh_context_state(&mut self) {
self.publish_context_state();
self.save_working_stack();
}
/// Persist working stack to disk.
fn save_working_stack(&self) {
if let Ok(json) = serde_json::to_string(&self.context.working_stack) {
let _ = std::fs::write(working_stack_file_path(), json);
}
}
/// Load working stack from disk.
fn load_working_stack(&mut self) {
if let Ok(data) = std::fs::read_to_string(working_stack_file_path()) {
if let Ok(data) = std::fs::read_to_string(working_stack::file_path()) {
if let Ok(stack) = serde_json::from_str::<Vec<String>>(&data) {
self.context.working_stack = stack;
}