Repository navigation
fix(ai-vault): tolerate unknown session agents - #12999
Conversation
📝 WalkthroughWalkthroughThe session validator now accepts non-empty agent strings and filters them against the supported-agent allowlist during parsing. Malformed sessions and scan issues contribute to invalid counts, while unsupported-agent entries are excluded without increasing those counts. The validator throws an all-invalid error only when every supplied session is malformed. Tests cover unknown-agent filtering, all-unknown responses, malformed-row diagnostics, and session-specific fixture values. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
smwbev
left a comment
There was a problem hiding this comment.
Author of #12958 here — thanks for picking this up, and the sessions path does exactly what the issue asked: unknown-but-well-formed agents no longer count toward the invalid notice, and an all-unknown response now parses to an empty list instead of throwing (which also removes the worst side effect — over SSH that throw fell through to the full 16-root SFTP crawl on every scan). Both semantics being pinned by tests is exactly right.
One gap worth closing while you're in this file: the issues array still validates agent with z.enum(AI_VAULT_AGENTS). A scan issue arriving from a newer host about a newer agent (e.g. a permission error on that agent's sessions root) is dropped by that enum and counted into invalidCount — so the "Skipped N invalid Agent Session History result entries." notice hardcoded to agent: 'codex' still fires for mixed-version pairs through that second path. Mirroring the same tolerance there (accept a non-empty string, silently drop unknown-agent issue rows) would close both halves of #12958.
Minor and optional: the new throw condition (malformedSessionCount > 0 && sessions.length === 0) still throws when a response mixes malformed rows with only-unknown agents — at that point the unknowns prove the payload itself is well-formed, so degrading to the empty list may be preferable there too. Either way is defensible; the sessions-path behavior as implemented is already a clear improvement.
3139b13 to
a1a25de
Compare
|
@smwbev Thanks for the detailed follow-up. Addressed in
Preserved behavior: known-agent sessions and scan issues keep their existing typed behavior, and genuinely all-malformed session payloads still fail closed. Validation after rebasing onto
|
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks @innocarpe — this is the right compatibility boundary.
- Unsupported future-agent sessions and scan issues are fully validated, then omitted before typed UI/resume code.
- Known-agent data remains unchanged; malformed rows are still reported and all-malformed payloads fail closed.
- Added regression coverage proving malformed unknown-agent rows are validated before filtering.
Verified with 27 affected tests, full typecheck/lint, and Electron known/empty/repeat paths.
Resolves the conflict with stablyai#10249's table refactor: per-agent discovery moved from session-scanner-source-discovery.ts into the AI_VAULT_AGENT_SOURCES table, so the Prime Agent source becomes a table entry following the Pi shape (env resolution via primeAgentSessionsDirFromEnv unchanged). Prime Agent stays out of AI_VAULT_DELETABLE_AGENTS. Also picks up stablyai#12999 (unknown-agent tolerance in session-list validation) with no overlap.
* fix: tolerate unknown AI Vault agents * fix: tolerate unknown AI Vault scan issues * test(ai-vault): cover malformed unknown-agent rows --------- Co-authored-by: Jinwoo-H <[email protected]>
Description
Keep remote AI Vault session scans usable when a newer host publishes sessions for an agent this client does not know yet.
Focused fix
Preserves
Evidence
pnpm exec vitest run --config config/vitest.config.ts src/main/ai-vault/session-list-result-validation.test.ts --pool=forks --maxWorkers=1pnpm exec tsc --noEmit -p config/tsconfig.node.json --pretty falseUser-regression-tradeoffs
Fixes #12958