Don't set agent props twice (#4872)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -10,7 +10,6 @@ use bytes::Bytes;
|
||||
use futures::{stream::StreamExt, Stream};
|
||||
use goose::conversation::message::{Message, MessageContent};
|
||||
use goose::conversation::Conversation;
|
||||
use goose::execution::SessionExecutionMode;
|
||||
use goose::mcp_utils::ToolResult;
|
||||
use goose::permission::{Permission, PermissionConfirmation};
|
||||
use goose::session::SessionManager;
|
||||
@@ -207,10 +206,7 @@ async fn reply_handler(
|
||||
let task_tx = tx.clone();
|
||||
|
||||
drop(tokio::spawn(async move {
|
||||
let agent = match state
|
||||
.get_agent(session_id.clone(), SessionExecutionMode::Interactive)
|
||||
.await
|
||||
{
|
||||
let agent = match state.get_agent(session_id.clone()).await {
|
||||
Ok(agent) => agent,
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to get session agent: {}", e);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use axum::http::StatusCode;
|
||||
use goose::execution::manager::AgentManager;
|
||||
use goose::execution::SessionExecutionMode;
|
||||
use goose::scheduler_trait::SchedulerTrait;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::PathBuf;
|
||||
@@ -46,14 +45,8 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_agent(
|
||||
&self,
|
||||
session_id: String,
|
||||
mode: SessionExecutionMode,
|
||||
) -> anyhow::Result<Arc<goose::agents::Agent>> {
|
||||
self.agent_manager
|
||||
.get_or_create_agent(session_id, mode)
|
||||
.await
|
||||
pub async fn get_agent(&self, session_id: String) -> anyhow::Result<Arc<goose::agents::Agent>> {
|
||||
self.agent_manager.get_or_create_agent(session_id).await
|
||||
}
|
||||
|
||||
/// Get agent for route handlers - always uses Interactive mode and converts any error to 500
|
||||
@@ -61,11 +54,9 @@ impl AppState {
|
||||
&self,
|
||||
session_id: String,
|
||||
) -> Result<Arc<goose::agents::Agent>, StatusCode> {
|
||||
self.get_agent(session_id, SessionExecutionMode::Interactive)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to get agent: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
self.get_agent(session_id).await.map_err(|e| {
|
||||
tracing::error!("Failed to get agent: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user