Make external session detection limits configurable (#34449)

## What changed

- Add `maxSessionAgeDays` and `maxSessions` to the external-agent config detection request.
- Apply the requested limits when discovering sessions from supported migration sources.
- Preserve the existing defaults of a 30-day maximum age and 50 sessions when either option is omitted.

GitOrigin-RevId: 46376e94b64f1f61d8776e34d82cdd2cdeb36ca0
This commit is contained in:
charlesgong-openai authored and copyberry committed 2026-07-21 02:55:11 +00:00
1 parent 9078e32371
commit 3bc49e1721
18 files changed
+195 -25

No files matched your search

@@ -13,6 +13,7 @@ pub use crate::model::ExternalAgentConfigImportRawError;
pub use crate::model::ExternalAgentConfigImportSuccess;
pub use crate::model::ExternalAgentConfigMigrationItem;
pub use crate::model::ExternalAgentConfigMigrationItemType;
pub use crate::model::ExternalAgentSessionImportLimits;
pub use crate::model::MigrationDetails;
pub use crate::model::NamedMigration;
pub use crate::model::PendingPluginImport;
@@ -64,6 +65,7 @@ pub struct ExternalAgentConfigService {
pub(crate) external_agent_home: PathBuf,
pub(crate) analytics_events_client: Option<AnalyticsEventsClient>,
pub(crate) source: ExternalAgentSource,
pub(crate) session_import_limits: ExternalAgentSessionImportLimits,
state_db: Option<StateDbHandle>,
}
@@ -82,6 +84,7 @@ impl ExternalAgentConfigService {
external_agent_home,
analytics_events_client: Some(analytics_events_client),
source,
session_import_limits: ExternalAgentSessionImportLimits::default(),
state_db,
}
}
@@ -96,10 +99,17 @@ impl ExternalAgentConfigService {
external_agent_home,
analytics_events_client: self.analytics_events_client.clone(),
source,
session_import_limits: self.session_import_limits,
state_db: self.state_db.clone(),
}
}
pub fn with_session_import_limits(&self, limits: ExternalAgentSessionImportLimits) -> Self {
let mut service = self.clone();
service.session_import_limits = limits;
service
}
pub fn session_metadata_mode(&self) -> SessionMetadataMode {
self.source.session_metadata_mode()
}
@@ -122,6 +132,7 @@ impl ExternalAgentConfigService {
external_agent_home,
analytics_events_client: None,
source,
session_import_limits: ExternalAgentSessionImportLimits::default(),
state_db: None,
}
}