Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/goose-cli/src/scenario_tests/scenario_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ where
.update_provider(provider_arc as Arc<dyn goose::providers::base::Provider>)
.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;
for message in &messages {
Expand Down
5 changes: 3 additions & 2 deletions crates/goose-cli/src/session/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async fn offer_extension_debugging_help(
}

// 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
println!("{}", style("Analyzing the extension failure...").yellow());
Expand Down Expand Up @@ -465,7 +465,8 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
session_config.max_turns,
edit_mode,
session_config.retry_config.clone(),
);
)
.await;

// Add stdio extensions if provided
for extension_str in session_config.extensions {
Expand Down
14 changes: 5 additions & 9 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub async fn classify_planner_response(
}

impl CliSession {
pub fn new(
pub async fn new(
agent: Agent,
session_id: Option<String>,
debug: bool,
Expand All @@ -129,14 +129,10 @@ impl CliSession {
retry_config: Option<RetryConfig>,
) -> Self {
let messages = if let Some(session_id) = &session_id {
tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
SessionManager::get_session(session_id, true)
.await
.map(|session| session.conversation.unwrap_or_default())
.unwrap()
})
})
SessionManager::get_session(session_id, true)
.await
.map(|session| session.conversation.unwrap_or_default())
.unwrap()
} else {
Conversation::new_unvalidated(Vec::new())
};
Expand Down
10 changes: 8 additions & 2 deletions crates/goose/src/session/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl SessionStorage {

async fn create_session(&self, working_dir: PathBuf, description: String) -> Result<Session> {
let today = chrono::Utc::now().format("%Y%m%d").to_string();
Ok(sqlx::query_as(
let session_id = sqlx::query_as(
r#"
INSERT INTO sessions (id, description, working_dir, extension_data)
VALUES (
Expand All @@ -651,7 +651,13 @@ impl SessionStorage {
.bind(&description)
.bind(working_dir.to_string_lossy().as_ref())
.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> {
Expand Down
Loading