feat(ai): make agent turn limit configurable
This commit is contained in:
@@ -106,6 +106,10 @@ pub async fn ai_agent_stream(
|
||||
.await
|
||||
.get(&connection_id)
|
||||
.is_some_and(|config| dbx_core::production_safety::is_production_database(config, &database));
|
||||
let max_agent_turns = state.storage.load_max_agent_turns().await.unwrap_or_else(|err| {
|
||||
log::warn!("Failed to load max_agent_turns setting, using default: {err}");
|
||||
dbx_core::agent_loop::DEFAULT_MAX_AGENT_TURNS
|
||||
});
|
||||
let agent_ctx = AgentLoopContext {
|
||||
state: state.inner().clone(),
|
||||
connection_id,
|
||||
@@ -117,6 +121,7 @@ pub async fn ai_agent_stream(
|
||||
allow_writes: !production_database && allow_write_sql.unwrap_or(false),
|
||||
allow_dangerous: !production_database && allow_write_sql.unwrap_or(false),
|
||||
},
|
||||
max_agent_turns,
|
||||
};
|
||||
let is_agent_mode = mode.as_deref() == Some("agent");
|
||||
|
||||
|
||||
@@ -42,6 +42,16 @@ pub async fn save_desktop_settings(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn load_max_agent_turns(state: State<'_, Arc<AppState>>) -> Result<u32, String> {
|
||||
state.storage.load_max_agent_turns().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn save_max_agent_turns(state: State<'_, Arc<AppState>>, max_agent_turns: u32) -> Result<(), String> {
|
||||
state.storage.save_max_agent_turns(max_agent_turns).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn complete_app_close(app: AppHandle, window: Window, action: String) -> Result<(), String> {
|
||||
match action.as_str() {
|
||||
|
||||
@@ -1080,6 +1080,8 @@ pub fn run() {
|
||||
commands::prompt_template::set_ai_global_custom_instructions,
|
||||
commands::app_settings::load_desktop_settings,
|
||||
commands::app_settings::save_desktop_settings,
|
||||
commands::app_settings::load_max_agent_turns,
|
||||
commands::app_settings::save_max_agent_turns,
|
||||
commands::app_settings::complete_app_close,
|
||||
commands::app_settings::mark_frontend_ready,
|
||||
commands::app_settings::request_app_close_from_window_controls,
|
||||
|
||||
Reference in New Issue
Block a user