feat(ai): make agent turn limit configurable

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-07-23 13:57:06 +08:00
1 parent 21e9578f78
commit 9253203d99
21 files changed
+307 -5

No files matched your search

+5
View File
@@ -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");
+10
View File
@@ -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() {