Skip to content

fix(ai-vault): tolerate unknown session agents - #12999

Merged
Jinwoo-H merged 3 commits into
stablyai:mainfrom
innocarpe:fix/ai-vault-unknown-agent
Aug 7, 2026
Merged

Jinwoo-H merged 3 commits into
stablyai:mainfrom
innocarpe:fix/ai-vault-unknown-agent

Conversation

@innocarpe

@innocarpe innocarpe commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

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

  • In scope: accept non-empty agent strings at the wire boundary, fully validate session and issue rows, and omit well-formed rows for agents this client does not support.
  • Out of scope: inventing an agent label or resume command for an unsupported agent, changing host merge semantics, or relaxing malformed-payload validation.

Preserves

  • Known-agent sessions and issues retain their typed behavior; malformed rows are still reported, and all-malformed session payloads still fail closed.

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/main/ai-vault/session-list-result-validation.test.ts --pool=forks --maxWorkers=1
  • Typecheck: pnpm exec tsc --noEmit -p config/tsconfig.node.json --pretty false
  • Changed-file Oxlint and React Doctor checks pass with no warnings.
  • Regression coverage covers mixed known/unknown rows, all-unknown rows, unknown scan issues, malformed unknown-agent rows, and all-malformed payloads.

User-regression-tradeoffs

  • A client that predates a new agent no longer misattributes the unsupported row to Codex or falls into the SSH crawl; it simply omits that row until the client supports the agent.

Fixes #12958

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and testing, but it omits the required AI Review Report, Security Audit, Notes, and explicit Screenshots sections. Add the missing template sections, state whether there is visual change, document AI review and cross-platform checks, and summarize the security audit and follow-up risks.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #12958 by accepting unknown agents, filtering unsupported rows, preserving malformed-row failures, and retaining known-agent behavior.
Out of Scope Changes check ✅ Passed The changes and tests remain focused on session-list validation and unknown-agent compatibility described in issue #12958.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main change: tolerating session rows from unknown agents.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@smwbev smwbev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@innocarpe
innocarpe force-pushed the fix/ai-vault-unknown-agent branch from 3139b13 to a1a25de Compare August 7, 2026 12:58
@innocarpe

innocarpe commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@smwbev Thanks for the detailed follow-up. Addressed in a1a25deb02.

  • The issues path now accepts non-empty agent strings, filters unknown agents, and counts only malformed rows. Newer-host issue rows no longer produce a synthetic Codex warning.
  • The all-invalid session guard now distinguishes malformed rows from well-formed unknown agents. Mixed malformed/unknown responses return the supported empty list while retaining the malformed-row notice.
  • Added regression coverage for mixed known/unknown scan issues and malformed-plus-unknown session responses.

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 upstream/main at 02a1251c2d:

  • AI Vault validator/results tests: 12 passed
  • Node typecheck on Node 24.18.0: passed
  • Changed-code quality: 0 new findings

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Jinwoo-H
Jinwoo-H merged commit 2e199cb into stablyai:main Aug 7, 2026
43 checks passed
smwbev added a commit to smwbev/orca that referenced this pull request Aug 7, 2026
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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Vault: session-list validation should tolerate agents unknown to the client

5 participants