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/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn get_session_id(identifier: Identifier) -> Result<String> {

sessions
.into_iter()
.find(|s| s.id == name || s.description.contains(&name))
.find(|s| s.name == name || s.id == name)
.map(|s| s.id)
.ok_or_else(|| anyhow::anyhow!("No session found with name '{}'", name))
} else if let Some(path) = identifier.path {
Expand Down
2 changes: 1 addition & 1 deletion crates/goose-cli/src/commands/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub async fn handle_schedule_sessions(id: String, limit: Option<usize>) -> Resul
" - Session ID: {}, Working Dir: {}, Description: \"{}\", Schedule ID: {:?}",
session_name, // Display the session_name as Session ID
metadata.working_dir.display(),
metadata.description,
metadata.name,
metadata.schedule_id.as_deref().unwrap_or("N/A")
);
}
Expand Down
21 changes: 9 additions & 12 deletions crates/goose-cli/src/commands/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TRUNCATED_DESC_LENGTH: usize = 60;
pub async fn remove_sessions(sessions: Vec<Session>) -> Result<()> {
println!("The following sessions will be removed:");
for session in &sessions {
println!("- {} {}", session.id, session.description);
println!("- {} {}", session.id, session.name);
}

let should_delete = confirm("Are you sure you want to delete these sessions?")
Expand Down Expand Up @@ -46,10 +46,10 @@ fn prompt_interactive_session_removal(sessions: &[Session]) -> Result<Vec<Sessio
let display_map: std::collections::HashMap<String, Session> = sessions
.iter()
.map(|s| {
let desc = if s.description.is_empty() {
"(no description)"
let desc = if s.name.is_empty() {
"(no name)"
} else {
&s.description
&s.name
};
let truncated_desc = safe_truncate(desc, TRUNCATED_DESC_LENGTH);
let display_text = format!("{} - {} ({})", s.updated_at, truncated_desc, s.id);
Expand Down Expand Up @@ -155,10 +155,7 @@ pub async fn handle_session_list(

println!("Available sessions:");
for session in sessions {
let output = format!(
"{} - {} - {}",
session.id, session.description, session.updated_at
);
let output = format!("{} - {} - {}", session.id, session.name, session.updated_at);
println!("{}", output);
}
}
Expand Down Expand Up @@ -189,7 +186,7 @@ pub async fn handle_session_export(
let conversation = session
.conversation
.ok_or_else(|| anyhow::anyhow!("Session has no messages"))?;
export_session_to_markdown(conversation.messages().to_vec(), &session.description)
export_session_to_markdown(conversation.messages().to_vec(), &session.name)
}
_ => return Err(anyhow::anyhow!("Unsupported format: {}", format)),
};
Expand Down Expand Up @@ -323,10 +320,10 @@ pub async fn prompt_interactive_session_selection() -> Result<String> {
let display_map: std::collections::HashMap<String, Session> = sessions
.iter()
.map(|s| {
let desc = if s.description.is_empty() {
"(no description)"
let desc = if s.name.is_empty() {
"(no name)"
} else {
&s.description
&s.name
};
let truncated_desc = safe_truncate(desc, TRUNCATED_DESC_LENGTH);

Expand Down
2 changes: 1 addition & 1 deletion crates/goose-cli/src/commands/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ async fn list_sessions() -> Json<serde_json::Value> {
session_info.push(serde_json::json!({
"name": session.id,
"path": session.id,
"description": session.description,
"description": session.name,
"message_count": session.message_count,
"working_dir": session.working_dir
}));
Expand Down
4 changes: 2 additions & 2 deletions crates/goose-server/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ derive_utoipa!(Icon as IconSchema);
super::routes::session::list_sessions,
super::routes::session::get_session,
super::routes::session::get_session_insights,
super::routes::session::update_session_description,
super::routes::session::update_session_name,
super::routes::session::delete_session,
super::routes::session::export_session,
super::routes::session::import_session,
Expand Down Expand Up @@ -395,7 +395,7 @@ derive_utoipa!(Icon as IconSchema);
super::routes::reply::ChatRequest,
super::routes::session::ImportSessionRequest,
super::routes::session::SessionListResponse,
super::routes::session::UpdateSessionDescriptionRequest,
super::routes::session::UpdateSessionNameRequest,
super::routes::session::UpdateSessionUserRecipeValuesRequest,
super::routes::session::UpdateSessionUserRecipeValuesResponse,
Message,
Expand Down
4 changes: 2 additions & 2 deletions crates/goose-server/src/routes/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ async fn start_agent(
}

let counter = state.session_counter.fetch_add(1, Ordering::SeqCst) + 1;
let description = format!("New session {}", counter);
let name = format!("New session {}", counter);

let mut session = SessionManager::create_session(PathBuf::from(&working_dir), description)
let mut session = SessionManager::create_session(PathBuf::from(&working_dir), name)
.await
.map_err(|err| {
error!("Failed to create session: {}", err);
Expand Down
10 changes: 5 additions & 5 deletions crates/goose-server/src/routes/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ fn default_limit() -> u32 {
#[derive(Serialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct SessionDisplayInfo {
id: String, // Derived from session_name (filename)
name: String, // From metadata.description
created_at: String, // Derived from session_name, in ISO 8601 format
working_dir: String, // from metadata.working_dir (as String)
id: String,
name: String,
created_at: String,
working_dir: String,
schedule_id: Option<String>,
message_count: usize,
total_tokens: Option<i32>,
Expand Down Expand Up @@ -325,7 +325,7 @@ async fn sessions_handler(
for (session_name, session) in session_tuples {
display_infos.push(SessionDisplayInfo {
id: session_name.clone(),
name: session.description,
name: session.name,
created_at: parse_session_name_to_iso(&session_name),
working_dir: session.working_dir.to_string_lossy().into_owned(),
schedule_id: session.schedule_id,
Expand Down
33 changes: 17 additions & 16 deletions crates/goose-server/src/routes/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub struct SessionListResponse {

#[derive(Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSessionDescriptionRequest {
/// Updated description (name) for the session (max 200 characters)
description: String,
pub struct UpdateSessionNameRequest {
/// Updated name for the session (max 200 characters)
name: String,
}

#[derive(Deserialize, ToSchema)]
Expand All @@ -49,7 +49,7 @@ pub struct ImportSessionRequest {
json: String,
}

const MAX_DESCRIPTION_LENGTH: usize = 200;
const MAX_NAME_LENGTH: usize = 200;

#[utoipa::path(
get,
Expand Down Expand Up @@ -118,14 +118,14 @@ async fn get_session_insights() -> Result<Json<SessionInsights>, StatusCode> {

#[utoipa::path(
put,
path = "/sessions/{session_id}/description",
request_body = UpdateSessionDescriptionRequest,
path = "/sessions/{session_id}/name",
request_body = UpdateSessionNameRequest,
params(
("session_id" = String, Path, description = "Unique identifier for the session")
),
responses(
(status = 200, description = "Session description updated successfully"),
(status = 400, description = "Bad request - Description too long (max 200 characters)"),
(status = 200, description = "Session name updated successfully"),
(status = 400, description = "Bad request - Name too long (max 200 characters)"),
(status = 401, description = "Unauthorized - Invalid or missing API key"),
(status = 404, description = "Session not found"),
(status = 500, description = "Internal server error")
Expand All @@ -135,16 +135,20 @@ async fn get_session_insights() -> Result<Json<SessionInsights>, StatusCode> {
),
tag = "Session Management"
)]
async fn update_session_description(
async fn update_session_name(
Path(session_id): Path<String>,
Json(request): Json<UpdateSessionDescriptionRequest>,
Json(request): Json<UpdateSessionNameRequest>,
) -> Result<StatusCode, StatusCode> {
if request.description.len() > MAX_DESCRIPTION_LENGTH {
let name = request.name.trim();
if name.is_empty() {
return Err(StatusCode::BAD_REQUEST);
}
if name.len() > MAX_NAME_LENGTH {
return Err(StatusCode::BAD_REQUEST);
}

SessionManager::update_session(&session_id)
.description(request.description)
.user_provided_name(name.to_string())
.apply()
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
Expand Down Expand Up @@ -311,10 +315,7 @@ pub fn routes(state: Arc<AppState>) -> Router {
.route("/sessions/{session_id}/export", get(export_session))
.route("/sessions/import", post(import_session))
.route("/sessions/insights", get(get_session_insights))
.route(
"/sessions/{session_id}/description",
put(update_session_description),
)
.route("/sessions/{session_id}/name", put(update_session_name))
.route(
"/sessions/{session_id}/user_recipe_values",
put(update_session_user_recipe_values),
Expand Down
4 changes: 1 addition & 3 deletions crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,7 @@ impl Agent {
let provider = self.provider().await?;
let session_id = session_config.id.clone();
tokio::spawn(async move {
if let Err(e) =
SessionManager::maybe_update_description(&session_id, provider).await
{
if let Err(e) = SessionManager::maybe_update_name(&session_id, provider).await {
warn!("Failed to generate session description: {}", e);
}
});
Expand Down
Loading
Loading