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

@@ -2,8 +2,9 @@ use crate::ClaSource;
use crate::CurSource;
use crate::RewriteProfile;
use crate::detect::plugins;
use crate::detect::sessions::detect_recent_cla_sessions;
use crate::detect::sessions::detect_recent_cur_sessions;
use crate::detect::sessions::detect_recent_cla_sessions_with_limits;
use crate::detect::sessions::detect_recent_cur_sessions_with_limits;
use crate::model::ExternalAgentSessionImportLimits;
use crate::sessions::ExternalAgentSessionMigration;
use crate::sessions::SessionMetadataMode;
use serde_json::Value as JsonValue;
@@ -122,10 +123,15 @@ impl ExternalAgentSource {
self,
external_agent_home: &Path,
codex_home: &Path,
limits: ExternalAgentSessionImportLimits,
) -> io::Result<Vec<ExternalAgentSessionMigration>> {
match self {
Self::Cla => detect_recent_cla_sessions(external_agent_home, codex_home),
Self::Cur => detect_recent_cur_sessions(external_agent_home, codex_home),
Self::Cla => {
detect_recent_cla_sessions_with_limits(external_agent_home, codex_home, limits)
}
Self::Cur => {
detect_recent_cur_sessions_with_limits(external_agent_home, codex_home, limits)
}
}
}