force WAL sync after session create (#5202)

This commit is contained in:
Jack Amadeo
2025-10-16 11:00:36 -04:00
committed by GitHub
parent ceba54d60c
commit 6c25600356
4 changed files with 17 additions and 14 deletions
@@ -218,7 +218,7 @@ where
.update_provider(provider_arc as Arc<dyn goose::providers::base::Provider>) .update_provider(provider_arc as Arc<dyn goose::providers::base::Provider>)
.await?; .await?;
let mut session = CliSession::new(agent, None, false, None, None, None, None); let mut session = CliSession::new(agent, None, false, None, None, None, None).await;
let mut error = None; let mut error = None;
for message in &messages { for message in &messages {
+3 -2
View File
@@ -133,7 +133,7 @@ async fn offer_extension_debugging_help(
} }
// Create the debugging session // Create the debugging session
let mut debug_session = CliSession::new(debug_agent, None, false, None, None, None, None); let mut debug_session = CliSession::new(debug_agent, None, false, None, None, None, None).await;
// Process the debugging request // Process the debugging request
println!("{}", style("Analyzing the extension failure...").yellow()); println!("{}", style("Analyzing the extension failure...").yellow());
@@ -465,7 +465,8 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
session_config.max_turns, session_config.max_turns,
edit_mode, edit_mode,
session_config.retry_config.clone(), session_config.retry_config.clone(),
); )
.await;
// Add stdio extensions if provided // Add stdio extensions if provided
for extension_str in session_config.extensions { for extension_str in session_config.extensions {
+5 -9
View File
@@ -119,7 +119,7 @@ pub async fn classify_planner_response(
} }
impl CliSession { impl CliSession {
pub fn new( pub async fn new(
agent: Agent, agent: Agent,
session_id: Option<String>, session_id: Option<String>,
debug: bool, debug: bool,
@@ -129,14 +129,10 @@ impl CliSession {
retry_config: Option<RetryConfig>, retry_config: Option<RetryConfig>,
) -> Self { ) -> Self {
let messages = if let Some(session_id) = &session_id { let messages = if let Some(session_id) = &session_id {
tokio::task::block_in_place(|| { SessionManager::get_session(session_id, true)
tokio::runtime::Handle::current().block_on(async { .await
SessionManager::get_session(session_id, true) .map(|session| session.conversation.unwrap_or_default())
.await .unwrap()
.map(|session| session.conversation.unwrap_or_default())
.unwrap()
})
})
} else { } else {
Conversation::new_unvalidated(Vec::new()) Conversation::new_unvalidated(Vec::new())
}; };
+8 -2
View File
@@ -645,7 +645,7 @@ impl SessionStorage {
async fn create_session(&self, working_dir: PathBuf, description: String) -> Result<Session> { async fn create_session(&self, working_dir: PathBuf, description: String) -> Result<Session> {
let today = chrono::Utc::now().format("%Y%m%d").to_string(); let today = chrono::Utc::now().format("%Y%m%d").to_string();
Ok(sqlx::query_as( let session_id = sqlx::query_as(
r#" r#"
INSERT INTO sessions (id, description, working_dir, extension_data) INSERT INTO sessions (id, description, working_dir, extension_data)
VALUES ( VALUES (
@@ -666,7 +666,13 @@ impl SessionStorage {
.bind(&description) .bind(&description)
.bind(working_dir.to_string_lossy().as_ref()) .bind(working_dir.to_string_lossy().as_ref())
.fetch_one(&self.pool) .fetch_one(&self.pool)
.await?) .await?;
sqlx::query("PRAGMA wal_checkpoint")
.execute(&self.pool)
.await?;
Ok(session_id)
} }
async fn get_session(&self, id: &str, include_messages: bool) -> Result<Session> { async fn get_session(&self, id: &str, include_messages: bool) -> Result<Session> {