Skip to content

feat(cloud-agent-next): add provider failure bucket to outcomes - #6466

Merged
eshurakov merged 3 commits into
mainfrom
eshurakov/platform-failure-attribution
Sep 21, 2026
Merged

eshurakov merged 3 commits into
mainfrom
eshurakov/platform-failure-attribution

Conversation

@eshurakov

@eshurakov eshurakov commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Three commits:

  1. Widen the taxonomy (classifier unchanged). Adds a provider failure responsibility alongside platform/user/unknown, and carries the failure reason into the emitted cloud_agent_outcome_aggregate failureStageCodes entries. Every bucketing, SQL, reporting and admin-web site handles the new value so a future provider responsibility cannot silently land in unknown. Adds providerFailed, distinctProviderAffectedSessions and the unknownSettledShare guardrail.

  2. Apply the attribution policy. The model-serving path is one provider bucket: our gateway and the upstream provider are indistinguishable from the cloud agent's point of view, so provider outages, rate limits, timeouts, model availability and assistant context/output limits no longer inflate the platform-defect share. platform remains for failures whose handling the cloud agent platform itself controls.

  3. Review follow-up. The Observed-health card description now enumerates the buckets it renders, including provider; the emitted limitations list records that the provider bucket also absorbs an unrecognized model selection.

Responsibility changes in classifyAssistantFailure:

Reason Ownership Before After
rate_limited any user provider
model_unavailable, model_missing any platform (managed selection) or user provider
provider_unavailable managed / byok / unknown platform / unknown / unknown provider
timeout managed / byok / unknown platform / unknown / unknown provider
context_limit, output_limit any platform / user / unknown provider
provider_authentication byok / managed / unknown unchanged unchanged
invalid_request byok / managed / unknown unchanged unchanged

Unchanged: content_filter (user), structured_output (platform), assistant_no_reply (platform), assistant_unknown (unknown), insufficient_credits (user), and every sandbox/workspace/git/wrapper/delivery/DO reason (platform).

Model availability no longer depends on who selected the model, which removes the managed-auto-routing branch and the now-unused managedModelSelection fact. managed_model_configuration stays reachable through admission MODEL_VALIDATION_UNAVAILABLE.

Contract version

AGGREGATE_CONTRACT_VERSION stays 1. 950b1010b1 (#6267) made the same change to this record two days earlier — a required field on every failureStageCodes entry plus a new grouping dimension (git show 950b1010b1 -- services/cloud-agent-next/src/telemetry/outcome-aggregate.ts) — and kept the version at 1. This change follows that precedent: the record is a superset (no field removed, renamed or retyped), reason is present on every entry, and no consumer in this repository reads failureStageCodes.

Verification

No manual tests. This is a classifier/SQL/UI surface change with no producer of the new bucket in a live path to exercise end to end; covered by unit tests:

  • packages/worker-utils/src/cloud-agent-failure.test.ts — golden tables and the exhaustive ownership matrix updated to the provider policy.
  • services/cloud-agent-next/src/telemetry/queue-reports.test.ts — emitted report responsibility/reason per code.
  • services/cloud-agent-next/src/telemetry/outcome-aggregate.test.ts, report-store.test.ts, report-consumer.test.ts, queue-reports.test.ts
  • apps/web/src/routers/admin-cloud-agent-next-router.test.ts, CloudAgentNextTelemetry/health-summary.test.ts

Checks run:

  • services/cloud-agent-next unit suite: 6793 passed, 3 skipped.
  • pnpm run typecheck (tsgo + wrapper typecheck) clean; oxlint 0 warnings/0 errors; oxfmt --list-different clean.
  • apps/web lint and format clean on the changed file.

Blocked, not passed: apps/web jest suites and apps/web typecheck cannot run in this worktree. @simplewebauthn/server is declared at apps/web/package.json:103 but absent from node_modules (typecheck fails on src/lib/auth/passkey.ts:14), and jest setup fails in cleanupDbForTest because no local Postgres is running. Both are pre-existing environment gaps unrelated to this change, so the card-copy change is covered by lint/format only.

Visual Changes

N/A

Reviewer Notes

  • Known blind spot, accepted deliberately: a cloud-agent-caused model-path failure (a bad session token yields a gateway 401provider_authentication) keeps its existing ownership split, so a managed-key failure still reads platform. It is not moved into provider.
  • provider with reason provider_ownership_unknown means the model path failed and we do not know whose credential was used.
  • The provider bucket absorbs an unrecognized model selection when the model path reports it as model_missing, which can be user-caused. This is recorded in the emitted record rather than left implicit: limitations now carries provider_includes_user_model_selection_errors.

…come aggregate

Add a `provider` failure responsibility alongside platform/user/unknown and
carry the failure reason into the emitted `cloud_agent_outcome_aggregate`
`failureStageCodes` entries, so external model-provider failures can be
excluded from the platform-defect share.

The classifier output is unchanged: no producer emits `provider` yet. Every
bucketing, SQL, reporting and admin-web site is widened to handle the new
value so a future `provider` responsibility cannot silently land in `unknown`.
Adds `providerFailed`, `distinctProviderAffectedSessions` and the
`unknownSettledShare` guardrail; `AGGREGATE_CONTRACT_VERSION` stays 1
(additive).
Comment thread services/cloud-agent-next/src/telemetry/outcome-aggregate.ts
@kilo-code-bot

kilo-code-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The follow-up commit fixes the Observed-health card copy so it enumerates the provider bucket, and records the provider-bucket model-selection caveat in the emitted limitations; the only remaining finding is the carried-forward contract-version question on the aggregate record.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
services/cloud-agent-next/src/telemetry/outcome-aggregate.ts 261 failureStageCodes adds failureReason to the aggregation key (splitting entries previously merged under (stage, code, responsibility)) and a required reason field, while AGGREGATE_CONTRACT_VERSION stays 1; still unresolved.
Files Reviewed (2 files)
  • apps/web/src/app/admin/components/CloudAgentNextTelemetry/CloudAgentNextOutcomesPage.tsx - previously flagged card copy is now fixed; no new issues
  • services/cloud-agent-next/src/telemetry/outcome-aggregate.ts - 1 carried-forward suggestion; new limitations entry at line 26 verified consistent

Fix these issues in Kilo Cloud

Previous Review Summaries (2 snapshots, latest commit e976b9d)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit e976b9d)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The follow-up commit switches the model-path attribution policy to provider (rate_limited, model_unavailable/model_missing, timeout, provider_unavailable, context_limit, output_limit) and removes the now-dead managedModelSelection input; the classifier, its golden tables, and the queue report tests stay internally consistent and no new changed-code defect was found. The two prior documentation/versioning suggestions remain open on their original lines.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
services/cloud-agent-next/src/telemetry/outcome-aggregate.ts 260 Adding failureReason to the aggregation key splits entries previously merged under (stage, code, responsibility) and adds a required reason field while AGGREGATE_CONTRACT_VERSION stays 1; still unresolved.
apps/web/src/app/admin/components/CloudAgentNextTelemetry/CloudAgentNextOutcomesPage.tsx 123 The new provider outcome card is rendered, but the Observed-health CardDescription still enumerates only user action, platform action, or further investigation; still unresolved.
Files Reviewed (4 files)
  • packages/worker-utils/src/cloud-agent-failure.ts - no new issues
  • packages/worker-utils/src/cloud-agent-failure.test.ts - no new issues
  • services/cloud-agent-next/src/telemetry/queue-reports.ts - no new issues
  • services/cloud-agent-next/src/telemetry/queue-reports.test.ts - no new issues

Fix these issues in Kilo Cloud

Previous review (commit 9e59810)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The provider responsibility is threaded consistently through the classifier contract, queue report schema, persistence, aggregate SQL, and admin UI with no correctness defect found; the only findings are two documentation/versioning gaps on changed lines.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
services/cloud-agent-next/src/telemetry/outcome-aggregate.ts 260 Adding failureReason to the aggregation key splits previously merged failureStageCodes entries and adds a required reason field while AGGREGATE_CONTRACT_VERSION stays 1; this is a semantic change for consumers keyed on the old (stage, code, responsibility) tuple.
apps/web/src/app/admin/components/CloudAgentNextTelemetry/CloudAgentNextOutcomesPage.tsx 123 The new provider outcome card is rendered, but the Observed-health CardDescription still enumerates only user/platform/unknown failure kinds.
Verification Notes
  • CLOUD_AGENT_FAILURE_RESPONSIBILITIES is the only responsibility enum in play; both packages/db/src/schema.ts and @kilocode/worker-utils/cloud-agent-failure were widened, and the DB column is plain text() with no CHECK constraint, so no migration is required.
  • z.enum(['all', ...CLOUD_AGENT_FAILURE_RESPONSIBILITIES]) at admin-cloud-agent-next-router.ts:16 type-checks against zod 4.4.3 and matches existing repo precedent (usage-analytics-schemas.ts:21, control-diagnostics.ts:188).
  • readRunCounts selects 8 expressions and groups by the 7 non-aggregate ordinals; the bucket math (allFailed = platform + provider + user + unknown, settled = completed + allFailed) is mutually exclusive, so provider cannot double count or leak into unknown; unknownResponsibilityCondition correctly excludes provider.
  • Admin summary equality between filtered and unfiltered results, the new expected counts, and the setup-level provider test are arithmetically consistent with the fixtures.
  • No new runtime resource (timers, subscriptions, listeners, caches) is introduced, so no memory leak is added. No markdown files changed, so the image-in-markdown rule does not apply.
  • The provider_retired fixture in the Postgres test is a raw column insert that intentionally represents unrecognized historical text; the aggregate buckets it as unknown.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

The model-serving path is one `provider` responsibility: our gateway and the
upstream provider are indistinguishable from the cloud agent's point of view,
so provider outages, rate limits, timeouts, model availability and assistant
context or output limits no longer inflate the platform-defect share.

`platform` stays for failures whose handling the cloud agent platform itself
controls. Provider authentication keeps its ownership split (managed ->
platform, byok -> user); invalid_request, content_filter, structured_output,
assistant_no_reply and insufficient_credits are unchanged.

Model availability no longer depends on who selected the model, which removes
the managed-auto-routing branch and the now-unused `managedModelSelection`
fact.
…surfaces

The Observed-health card description still enumerated only user action,
platform action and further investigation, although the provider outcome now
has its own card.

The emitted aggregate's limitations did not record that the provider bucket
also absorbs an unrecognized model selection, which is a user-caused failure
the model path reports as `model_missing`.

`AGGREGATE_CONTRACT_VERSION` stays 1. PR #6267 made the same change to
`failureStageCodes`' shape - a required field plus a new grouping dimension -
and kept the version, and this record only gains a field.
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.

2 participants