You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds lightweight personal and organization model-validation API contracts so Cloud Agent can check selected Kilo model availability against the effective catalog before dispatch.
Architecturally, cloud-agent-next now performs prompt-only model preflight at prepare, start, and send admission boundaries, failing unavailable selections synchronously and treating unavailable validation infrastructure as retryable failure.
Aligns dispatched model normalization and extends the fake gateway/E2E harness to prove rejected models create no sandbox work or chat-completion dispatch.
Verification
Confirmed accepted models complete a cold turn plus hot follow-up turns through both the unified and legacy API surfaces using the deterministic local fake gateway.
Confirmed an unavailable initial model is rejected before sandbox creation or chat-completion dispatch through both API surfaces using the fake validation gateway.
Confirmed an unavailable initial model is rejected before sandbox creation through both API surfaces when validation routes through the local Next.js gateway.
Confirmed unavailable follow-up sends reject without an added chat-completion dispatch for both API surfaces; the gated legacy turn completes after release with no remaining fake-gateway waiters.
Reviewer Notes
Focus on catalog-source resolution in services/cloud-agent-next/src/model-validation.ts, including official versus override/token-routed validation and scoped 401 fallback behavior.
Prompt-only enforcement is intentional; command-valued prepared sessions remain outside this change.
The preflight adds an availability request before accepted prompt work and fails closed when availability cannot be established.
Incremental commit feab35479 simplifies the 404 rollout strategy: instead of falling back to the catalog endpoint when the official /validate route returns 404, validation is now silently skipped (fail-open) with a warning log. The change is clean, tests are updated to match, and no new issues are introduced.
Resolved Issues
File
Issue
Status
services/cloud-agent-next/src/model-validation.ts
organizationId interpolated without encodeURIComponent in buildKiloOverrideValidationUrl
Could preflight run only for a new admission? A retry would needlessly re-validate
✅ Fixed in 01a08128b — prompt retries with an already-admitted message skip model preflight
services/cloud-agent-next/src/model-validation.ts
404 fallback to catalog creates mutual recursion risk
✅ Simplified in feab35479 — 404 from official route now returns skipped (fail-open with warning log), validateFromExistingOfficialCatalog and officialCatalogResponseSchema removed entirely
Simplified 404 handling: The previous strategy fell back to the catalog endpoint (/api/openrouter/models or /api/organizations/:id/models) when the /validate route returned 404 during rollout. This created mutual recursion between validateFromOfficialSource and validateFromExistingOfficialCatalog. The new strategy simply returns { type: 'skipped' } which passes validation with a warning log — appropriate for the rollout window.
Asymmetric 404 behavior is intentional: The official source is fail-open on 404 (route not deployed), while override/BYOK sources remain fail-closed on 404 (line 176: validation-unavailable). This correctly reflects that a 404 from an override endpoint is unexpected and not a rollout concern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cloud-agent-nextnow performs prompt-only model preflight at prepare, start, and send admission boundaries, failing unavailable selections synchronously and treating unavailable validation infrastructure as retryable failure.Verification
Reviewer Notes
services/cloud-agent-next/src/model-validation.ts, including official versus override/token-routed validation and scoped401fallback behavior.