feat: align typed session failures with AIR protocol - #393
Open
nikita-ashihmin wants to merge 4 commits into
Open
feat: align typed session failures with AIR protocol#393nikita-ashihmin wants to merge 4 commits into
nikita-ashihmin wants to merge 4 commits into
Conversation
Codex reports non-fatal advisories as dedicated app-server notifications, but codex-acp flattened them into assistant text: `warning` became `Warning: <message>` and `configWarning` became `Config warning: <summary>`, both as an untagged `agent_message_chunk`. The client could not tell them from the model's own words, so a compaction hint rendered as if the agent had said it. Extend the typed session-failure extension from agentclientprotocol#383 rather than adding a parallel notice concept: a record now carries an optional `severity` of `error` or `warning`, plus an `advisory` category whose wording comes from the app-server. Clients that negotiated the `sessionFailure` capability receive the structured record; everyone else keeps the existing text, unchanged. Advisories live in their own `sessionNotice` slot under a `:notice` id, so they never disturb the revision bookkeeping of an in-flight terminal failure — the two records coexist and the client decides which to show. `severity` is optional on the wire and absent means `error`, so an AIR build that predates this change keeps treating every record it receives as a failure. Scoped out deliberately: `thread/compacted` keeps its italic transcript line (informational, not a warning), and `guardianWarning` / `deprecationNotice` remain dropped as before.
deprecationNotice carries the same {summary, details} shape as configWarning,
so treating the two differently was inertia, not design: it was simply already
being dropped.
Unlike warning and configWarning it has no legacy text rendering to preserve,
so it is emitted only to clients that negotiated typed records. A client that
did not must keep seeing exactly what it sees today, which is nothing.
Extracts joinSummaryAndDetails so the two notifications share one formatting
rule rather than repeating it.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
AIR renders agent failures as persistent inline transcript entries. The existing extension exposed a larger provider-specific shape and sent retry diagnostics through a separate
_meta.codex.errorpath, while warning notifications were flattened into assistant text.That made presentation inconsistent and gave the client no stable way to update one reconnect incident without appending repeated messages.
Change
Aligns
_meta.jetbrains.air.sessionFailurewith the AIR v1 contract:id,revision,category,severity,title, andactionsdetailsonly when the explanation is too large fortitleconnection,access,limit,request,service,unknownretry,login,new_sessionphase,source,safeMessage,retryable,turnId, and provider error codes from the wire recordFor app-server errors,
titleis the exact user-facingTurnError.messageproduced by Codex. The adapter does not replace it with category-specific canned wording. This preserves native messages such asReconnecting... 1/5, including retry progress already encoded by Codex.TurnError.additionalDetailsremains private diagnostic data and is not forwarded. Adapter-authored fallback text exists only for failures outside a Codex turn error, such as process exit before Codex can report one.Retrying errors arrive as
severity: "warning"records, reusing the incident id and incrementingrevision. A terminal failure updates that incident toseverity: "error". Historical entries are not deleted.Warnings, config warnings, and deprecation notices use the same typed record when the capability is negotiated. Consecutive duplicate warnings reuse one id and advance its revision; a later independent occurrence receives a new id. Short notice details are folded into
title, while genuinely long explanations usedetails.Legacy behavior remains unchanged when AIR does not advertise
sessionFailuresupport.Scoped out deliberately
thread/compactedkeeps its existing informational transcript line.guardianWarningremains represented by its existing guardian tool flow.windows/worldWritableWarningremains unchanged because its structured path list needs dedicated presentation.Validation
npm run typechecknpx vitest run src/__tests__/CodexACPAgent/typed-session-failure-wire.test.ts src/__tests__/CodexACPAgent/auth-error-events.test.ts src/__tests__/CodexACPAgent/plan-review-events.test.ts— 62 passednpm test— 409 passed, 28 skippednpm run buildClient side: IJAI-993.