Skip to content

feat(omp): preserve native service tiers and durable chat throughput - #41577

Open
magicJie wants to merge 3 commits into
stablyai:mainfrom
magicJie:feat/omp-native-metrics-and-tiers
Open

magicJie wants to merge 3 commits into
stablyai:mainfrom
magicJie:feat/omp-native-metrics-and-tiers

Conversation

@magicJie

@magicJie magicJie commented Nov 12, 2026 •

Copy link
Copy Markdown

ELI5

OMP chats gain a speed picker that keeps the choices OMP actually offers, plus a reliable tokens-per-second number after a turn finishes. Turning off inline visuals or reopening a chat keeps these capabilities working.

What Changed

  • Add a bundled OMP telemetry extension and load it for fresh/resumed ACP sessions and model discovery, independently of visuals and scratch setup.
  • Preserve native provider-family tier choices, descriptions and reported current values. The OMP 18.19 regression fixture covers seven choices (None, Auto, Default, Flex, Scale, Priority, Ultrafast); the implementation discovers them rather than installing a provider-tier table.
  • Default to None when no override is configured. None clears the override; literal Default remains selectable. Reasoning effort stays independent, and saved/live choices use the existing ACP option path. Provider adapters decide whether a selected value reaches a request.
  • Carry actual assistant usage.output and measured provider-request durations through ACP translation and the durable journal to desktop/mobile settled-turn status. Cumulative snapshots replace prior snapshots instead of double-counting.
  • Prefer native request duration; otherwise use the actual provider-request/message-end interval. The rate includes first-token wait and excludes tool gaps. Synthetic zero-token notices preserve valid prior measurements. Running turns, unmeasured history, incomplete timing/counters and intervals below 100 ms show no rate. Text length never estimates tokens.
  • Update the existing development documentation and regression tests. No package-version change, fork-maintenance configuration or private environment data is included.

Why

A boolean Fast control discards valid native OMP choices, and conflating None with Default changes the request's meaning. Provider-native usage and request timing provide a meaningful, reload-safe rate without counting time spent running tools.

Linked Issue

Fixes #41574

Visual Proof

After screenshots from the prior isolated Linux packaged validation of the accepted feature tree, using real OMP 18.19 and a deterministic loopback provider in a synthetic profile. These demonstrate the native picker and rendered settled/reloaded request metrics; the displayed rates are regression measurements, not hosted-provider performance claims. This was not a new package build of the PR head. The feature UI is preserved through the subsequent upstream integration and test-only correction.

Native seven-choice picker

OMP native seven-choice speed picker

Settled rates after restoring and resuming the existing conversation

OMP restored conversation with settled native request throughput

A before screenshot was not retained. The PNG-only orphan evidence ref in the contributor fork contains no application/source files or private chat/profile data. This provides Linux after-state evidence; macOS/Windows/SSH rendered validation remains unverified.

Testing

  • Owner-reported home acceptance test passed for the accepted feature snapshot.
  • Seven focused native/shared test files: 43 passed.
  • Mobile picker regression file: 2 passed.
  • Linux source Node 24.22.1, pnpm 12.14.0 and Bun 1.4.4 used for the final focused regression batch.
  • Node/web/mobile typechecks passed; mobile generated prerequisites were produced by the repository's actual postinstall scripts.
  • Complete pnpm check:changed --base=upstream/main --maxWorkers=2 --timeout=1 gate: 38/39 checks passed; broad related-unit selection timed out after 60 seconds.
  • Full lint/test/build suite and macOS/Windows/remote rendered validation.
  • Every added test's fail-on-revert property individually demonstrated. Existing focused assertions pass; no revert experiment was run.

Focused native/shared files: omp-native-extension-launch, omp-service-tier, omp-generation-usage, omp-native-chat-extension, structured-agent-session-native-tier, native-chat-session-option-snapshot, native-chat-turn-status; mobile: MobileNativeChatSessionOptionPickers.

Risk

Level: Medium

The main boundary is ACP extension events entering durable session journals and shared option state. Regressions could hide a settled rate, misreport a tier, or affect restored chats/paired mobile clients. Missing measurements intentionally leave the existing turn status intact. The extension is OMP-specific; the shared usage fields are optional. A plain revert restores prior behavior; historical measured entries remain optional journal data.

AI Disclosure

Implemented and integrated with AI coding assistance, including OpenAI GPT-6.1-sol for this contribution preparation.

Review

Agent summary: OMP-only extension discovery reuses the existing launch/ACP flow and applies on restore as well as initial launch. Shared optional usage metadata serves desktop and mobile. Paths remain in the existing host launch/resource machinery; no new local-only provider installation or process spawning convention is introduced. Throughput uses provider counters and request intervals rather than tokenizer estimates or wall-clock turn duration. Linux source regressions/types and prior isolated packaged after screenshots are provided; macOS/Windows/SSH rendered validation and a retained before image are outside the current evidence. No secrets, production state or fork deployment workflow are included.

Agent skill upstream boundary

  • Not applicable: this change copies no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments or documentation.

Notes

Submitted for upstream CI and review with the local broad-unit gate explicitly incomplete. The final mandatory changed gate ran against the frozen upstream/main base after the last source edit: 51 feature files selected; formatting, oxlint, changed-code quality, node/web/CLI types and all selected non-unit checks passed (38/39 checks). Its broad related-unit lane exceeded the explicit 60-second limit. An earlier attempt also reported an Electron auto-download fetch failure. The previously observed /bin/zsh-dependent lane remains unavailable locally; no dedicated retry was run. Focused feature tests above are the completed unit evidence. No new heavy packaging build or activation was performed.

The PR is ready for review. One ready-state gh pr checks --watch reported no surfaced checks; the triggered PR Checks, Mobile Checks, and Headless Node server runs report action_required. PR Checks has zero jobs, so this is an upstream workflow-admission gate rather than a completed test failure. Maintainer action is needed before those checks execute; merge remains subject to required CI and review. No workflow approval, CLA or contributor agreement was signed on the owner's behalf.

Checklist

  • One cohesive OMP native-chat metrics and service-tier feature
  • User-facing before/after, mechanism and rationale explained
  • Risk and revert behavior described
  • Linux after screenshots attached with provenance and coverage limits; before screenshot not retained
  • Cross-platform, SSH/remote and mobile boundaries considered
  • Full required gates green; pending external CI/review

@magicJie
magicJie marked this pull request as ready for review November 12, 2026 15:06
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add an OMP ACP extension that reports native service-tier choices and generation measurements. ACP sessions handle service-tier commands and carry generation usage through the timeline and journal. Shared option logic distinguishes none from literal default. Settled desktop and mobile turn-status displays show a formatted token rate when valid usage data is available.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to a7c4b

The new tier picker and tok/s display may not work at all on the minimum supported OMP version. An opening-message tier can also be silently ignored, and the tok/s display can be lost in some cases. Resolve the version-support gap and the opening-turn tier race before merging; the other issues are small follow-ups.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: preserving OMP native service tiers and adding durable throughput (tokens per second) for chats. The changeset covers both: the service-tier picker and option han…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #41574), Visual Proof with before/after context, Testing, Risk with level Medium, AI Disclo…
Linked Issues check Passed Issue #41574 is the only active direct link, so its coding requirements apply. The PR addresses each requirement group:

1. Service tiers: serviceTierOption and effectiveServiceTier keep tiers as …
Out of Scope Changes check Passed Every changed area maps to issue #41574's objectives. These areas are: OMP extension and launch wiring; ACP option read, write, and report paths for service tiers; durable journal and timeline fields …
Full details: Title check

Explanation

The title names the two main changes: preserving OMP native service tiers and adding durable throughput (tokens per second) for chats. The changeset covers both: the service-tier picker and option handling, and the generation-usage timing carried through ACP, the journal, and the settled-turn status. The title is specific and follows the conventional-commit style. It does not cover the telemetry extension or the docs, which is acceptable.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #41574), Visual Proof with before/after context, Testing, Risk with level Medium, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It explains the mechanism and the revert path. Gaps: the Visual Proof section has no before screenshot, which the template requires for UI changes. Testing leaves several boxes unchecked, including the full gate and the fail-on-revert check, and the Testing section does not list macOS, Windows, or SSH validation. The Notes section reports a 38/39 changed-gate result and a timed-out broad lane. The 'Every added test fails without this change' item is explicitly unverified. These are disclosed, not hidden, but the PR is not merge-ready on the template's own terms.

Resolution

Consider adding a before screenshot or an explicit justification for its absence in Visual Proof. State which platforms were actually tested in Testing. Clarify the status of the unchecked gates in the checklist before review.

Full details: Linked Issues check

Explanation

Issue #41574 is the only active direct link, so its coding requirements apply. The PR addresses each requirement group:

  1. Service tiers: serviceTierOption and effectiveServiceTier keep tiers as reported. none is the clear choice when listed. Literal default stays selectable (structured-agent-session-native-tier tests, native-chat-session-option-snapshot tests). omp-native-chat-options.ts validates and attaches reported tiers. Reasoning effort is handled by its existing option path.
  2. Telemetry loading: acp-structured-launch-resolution.ts (read at head) passes --extension for omp using visuals?.skill ?? await resolveNativeChatVisualsSkillLocation(). The fallback resolves the bundled extension path without requiring inline visuals to be enabled, which matches the requirement for independence from visuals/scratch setup. Model discovery is covered by acp-model-catalog-probe.ts changes.
  3. Throughput: omp-native-chat.mjs and omp-native-chat-extension.test.ts cover native duration preference, fallback to the before_provider_request interval (including first-token wait), skipping zero-token synthetic notices, and suppressing invalid measurements. agentSessionTokensPerSecond hides rates when output is 0 or duration is under 100 ms.
  4. Durable journal: generationUsage is added to the journal schema and turn lifecycle, and reviseTurnBody replaces (does not add) the prior snapshot. omp-generation-usage.test.ts covers settlement and reload.
  5. Desktop and mobile display: NativeChatWorkingStatus, MobileNativeChatTurnStatus, and formatNativeChatTurnRate display the settled rate. Hiding for running turns and unmeasured history is covered by native-chat-turn-status.test.ts.

Unverified in this review: the reported test pass counts and the screenshots were not re-executed. The broad changed-code gate is incomplete, as the PR description states. These gaps affect verification evidence, not the code-level requirement mapping.

Full details: Out of Scope Changes check

Explanation

Every changed area maps to issue #41574's objectives. These areas are: OMP extension and launch wiring; ACP option read, write, and report paths for service tiers; durable journal and timeline fields for generation usage; shared speed-tier and option-label logic; desktop and mobile turn-status display; the renderer fixture used to verify the speed menu; and the development documentation section describing the rate calculation. The tests cover these same changes. The PR makes no package-version change. The PR description reports no fork-maintenance or private-data files in the change set. Nothing in the summary falls outside the linked issue's scope.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7e6c6e8-522f-4c8e-873a-172610467165
Commits

Reviewing files that changed from the base of the PR and between 0b6497c and a7c4bba.

Files selected for processing: 51

  • docs/development.md
  • mobile/src/session/native-chat/input/MobileNativeChatSessionOptionPickers.test.ts
  • mobile/src/session/native-chat/transcript/MobileNativeChatMessage.tsx
  • mobile/src/session/native-chat/transcript/MobileNativeChatTurnStatus.tsx
  • resources/native-chat-visuals/omp-native-chat.mjs
  • src/main/acp/acp-dialects/acp-dialect.ts
  • src/main/acp/acp-dialects/omp-dialect.ts
  • src/main/acp/discovery/acp-at-rest-commands.ts
  • src/main/acp/discovery/acp-model-catalog-probe.ts
  • src/main/acp/launch/acp-launch-contract.ts
  • src/main/acp/launch/acp-launch-registry.ts
  • src/main/acp/launch/acp-structured-launch-resolution.ts
  • src/main/acp/launch/omp-native-extension-launch.test.ts
  • src/main/acp/options/acp-live-options.ts
  • src/main/acp/options/acp-session-option-write.ts
  • src/main/acp/options/acp-structured-options.ts
  • src/main/acp/options/omp-service-tier.test.ts
  • src/main/acp/session/acp-structured-acquire.ts
  • src/main/acp/session/acp-structured-agent-definitions.ts
  • src/main/acp/session/acp-structured-session-adapter.ts
  • src/main/acp/session/children/acp-structured-child.ts
  • src/main/acp/timeline/acp-timeline-translator.ts
  • src/main/acp/timeline/omp-generation-usage.test.ts
  • src/main/acp/turns/acp-message-execution-options.ts
  • src/main/acp/turns/acp-model-command.ts
  • src/main/native-chat/agent-session-timeline/agent-journal-turn-row-revision.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-assembler.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-decision.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-event.ts
  • src/main/native-chat/agent-session-timeline/provider-timeline-turn-decisions.ts
  • src/main/native-chat/agent-session-wire/options/structured-agent-session-execution-options.ts
  • src/main/omp/omp-native-chat-extension.test.ts
  • src/main/omp/omp-native-chat-options.ts
  • src/renderer/src/components/native-chat/conversation/turns/NativeChatWorkingStatus.fixture.tsx
  • src/renderer/src/components/native-chat/conversation/turns/NativeChatWorkingStatus.tsx
  • src/renderer/src/components/native-chat/messages/rows/NativeChatTranscriptRow.tsx
  • src/shared/agent-session/agent-session-generation-usage.ts
  • src/shared/agent-session/journal/agent-session-journal-schemas.ts
  • src/shared/agent-session/journal/agent-session-journal-status.ts
  • src/shared/agent-session/journal/agent-session-journal-types.ts
  • src/shared/agent-session/options/structured-agent-session-discovered-model.ts
  • src/shared/agent-session/options/structured-agent-session-effective-tier.ts
  • src/shared/agent-session/options/structured-agent-session-native-tier.test.ts
  • src/shared/agent-session/options/structured-agent-session-option-snapshot.ts
  • src/shared/agent-session/view/structured-agent-session-turn-timing.ts
  • src/shared/native-chat/input/native-chat-session-option-labels.ts
  • src/shared/native-chat/input/native-chat-session-option-snapshot.test.ts
  • src/shared/native-chat/input/native-chat-session-options.ts
  • src/shared/native-chat/input/native-chat-session-speed-tiers.ts
  • src/shared/native-chat/transcript/native-chat-turn-status.test.ts
  • src/shared/native-chat/transcript/native-chat-turn-status.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

return
}

const root = (ctx) => ctx.agent?.kind === 'main'

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.

Major · Functional Correctness · Heavy lift

Support OMP 17.0.5 or raise the declared minimum.

The launch registry accepts OMP 17.0.5 as a minimum. On that release, extension contexts have no agent field, so root(ctx) returns false. reportOptions then returns early, and the extension sends no service-tier options. Generation metrics are also skipped because they use the same guard.

Either raise minimumVersions in src/main/acp/launch/acp-launch-registry.ts to a release whose extension context provides agent, or add a main-agent check that works on 17.0.5.

const elapsed =
requestStartedAt === undefined ? undefined : performance.now() - requestStartedAt
requestStartedAt = undefined
const duration = message.duration ?? elapsed

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.

Minor · Functional Correctness · Quick win

Use the measured interval when the native duration is not positive.

message.duration ?? elapsed keeps a native 0, because ?? falls back only for null or undefined. The later duration > 0 check then fails. measured becomes false for the rest of the turn, and later assistant messages return before any generation report. A valid elapsed value is discarded in this case.

The OMP AssistantMessage type declares duration?: number with no lower bound. A native duration of 0 can therefore reach this handler on a message with output tokens.

Treat a nonpositive native duration as unavailable and use the measured interval instead:

Proposed change

--- "a/resources/native-chat-visuals/omp-native-chat.mjs"
+++ "b/resources/native-chat-visuals/omp-native-chat.mjs"
@@ -83,7 +83,8 @@
     const elapsed =
       requestStartedAt === undefined ? undefined : performance.now() - requestStartedAt
     requestStartedAt = undefined
-    const duration = message.duration ?? elapsed
+    const duration =
+      Number.isFinite(message.duration) && message.duration > 0 ? message.duration : elapsed
     // Synthetic assistant notices have no provider request or output to measure.
     if (tokens === 0 && duration === undefined) {
       return
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
const duration = message.duration ?? elapsed
const duration =
Number.isFinite(message.duration) && message.duration > 0 ? message.duration : elapsed

return true
}
for (const key of ['model', 'effort'] as const) {
for (const key of ['model', 'effort', 'serviceTier'] as const) {

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.

Minor · Functional Correctness · Quick win

Clear the cached service tier when the model changes.

invalidateInput('model') clears the cached model and effort entries, but not serviceTier. After a model switch that uses setModel, a stale serviceTier entry can make the loop skip a tier write that the new model needs. The message can then run with the new model's default tier instead of the selected one.

The tier is re-applied on the next send after a model change. For providers that set tiers through a prompt, this sends one additional hidden command.

Suggested fix

   invalidateInput(key: string): void {
     this.appliedInput.delete(key)
     if (key === 'model') {
       this.appliedInput.delete('effort')
+      this.appliedInput.delete('serviceTier')
     }

(key === 'model' && session.options.matchesNativeRestoredModel(value)) ||
(key === 'effort' && !session.options.offersEffort(value))
(key === 'effort' && !session.options.offersEffort(value)) ||
(key === 'serviceTier' && !session.options.write(key, value))

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.

Major · Functional Correctness · Heavy lift

Gate the opening turn on the initial tier report.

Dispatch does not wait for OMP's tier report. The report reaches adoptServiceTiers only through a notification (acp-structured-acquire.ts:135). Startup awaits initialization, session start, the child-stop probe, and the permission-mode write, but not this notification. The first dispatch runs applyAcpMessageOptions (acp-structured-session-adapter.ts:124). If the report has not arrived, write('serviceTier') returns null (acp-structured-options.ts:225-232, omp-native-chat-options.ts:53-54). The guard at acp-message-execution-options.ts:37 then skips the requested tier silently, and the turn continues at the provider's existing tier.

Keep the skip for a tier that the reported model does not offer. Do not apply it before the report exists. Wait for the initial tier report before the opening turn dispatches, or fail that turn when a requested tier cannot be applied.

return {
...base,
...(contextUsage ? { contextUsage: { ...current?.contextUsage, ...contextUsage } } : {}),
...(generationUsage ? { generationUsage } : {})

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.

Minor · Data Integrity & Integration · Quick win

Reserve bytes for generationUsage in the turn-row reservation.

agentJournalTurnRowReservedBytes does not include generationUsage. reviseTurnBody writes that field into the body, and resolveAgentJournalTurnRowWrite checks the body against the reservation. When retained context is close to its size bound, the body can exceed the reservation. The write then falls back to lifecycle alone, which drops the retained usage, or a usage-only write returns null. The settled rate is lost for that turn.

Add a bound for the field to the reservation:

Suggested fix

 /** Reserve lifecycle space even for rows created by other writers. */
 const TURN_ROW_BYTES_WITHOUT_CONTEXT = 8 * 1024
+
+/** Worst-case JSON size of the two-number generation usage object. */
+const GENERATION_USAGE_BYTES_BOUND = jsonBytes({
+  generationUsage: { outputTokens: Number.MAX_VALUE, durationMs: Number.MAX_VALUE }
+})
   return (
     (known && write.lifecycle
       ? estimateStructuredAgentSessionItemBytes(known, write.lifecycle)
       : TURN_ROW_BYTES_WITHOUT_CONTEXT) + contextBytesBound(write.contextUsage)
+      + GENERATION_USAGE_BYTES_BOUND
   )

This branch has not been deployed

No deployments
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.

OMP native chat: preserve provider service tiers and report durable measured throughput

1 participant