Skip to content

Wait for OpenCode Go Zen balance in CLI usage reads - #2583

Open
Yuxin-Qiao wants to merge 4 commits into
steipete:mainfrom
Yuxin-Qiao:codex/fix-opencodego-zen-balance-2581
Open

Wait for OpenCode Go Zen balance in CLI usage reads#2583
Yuxin-Qiao wants to merge 4 commits into
steipete:mainfrom
Yuxin-Qiao:codex/fix-opencodego-zen-balance-2581

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Closes #2581

Summary

codexbar usage --provider opencodego can silently drop the OpenCode Zen balance when the balance page responds more than 250 ms after the subscription page: the optional Zen join grace (optionalZenBalanceJoinGrace, 250 ms) resolves as nil and cancels the in-flight balance request.

This PR keeps the app's intentional fast refresh and changes the join contract for one-shot CLI reads:

  • OpenCodeGoUsageFetcher.fetchUsage gains waitForZenBalance (default false). When enabled, the optional Zen balance is joined without the 250 ms grace, so a slower but successful balance response is included in the snapshot.
  • OpenCodeGoUsageFetchStrategy enables the wait policy when context.runtime == .cli (codexbar usage, codexbar serve); the menu-bar app keeps the 250 ms bounded join.
  • On the wait path only, the balance request is capped at the existing 5 s optional-balance timeout (optionalZenBalanceTimeout), so a hung balance endpoint stalls a CLI read by at most ~5 s.
  • If the balance request fails while waiting, the subscription result is still returned with a nil balance; the CLI read does not fail.

This is the "Zen balance completeness is required for each CLI snapshot" contract from the issue review decision table. The alternative (retaining and asynchronously refreshing the last successful balance) remains open for the app/menu surface.

Tests

  • optional zen balance does not stall subscription usage (unchanged: app path still completes under 700 ms with a 1 s balance response)
  • cli wait policy includes slow but successful zen balance (new: 1 s delayed valid balance is included)
  • cli wait policy keeps subscription result when balance fetch fails (new)
  • web strategy waits for zen balance only in cli runtime (new)

Validation

Summary

codexbar usage --provider opencodego can silently drop the OpenCode Zen balance when the balance page responds more than 250 ms after the subscription page: the optional Zen join grace (optionalZenBalanceJoinGrace, 250 ms) resolves as nil and cancels the in-flight balance request.

This PR keeps the app's intentional fast refresh and changes the join contract for one-shot usage reads:

  • OpenCodeGoUsageFetcher.fetchUsage gains waitForZenBalance (default false). When enabled, the optional Zen balance is joined with the optional-balance timeout (5 s) instead of the 250 ms grace, so a slower but successful balance response is included in the snapshot.
  • ProviderFetchContext gains requiresOptionalUsageCompleteness (default false). Only usage-snapshot reads (codexbar usage, codexbar serve) set it, so codexbar guard and diagnostic commands keep the 250 ms bounded join and a slow balance cannot consume the guard deadline.
  • When subscription parsing finds no usage fields (Zen-only account), the balance request keeps the caller-configured --web-timeout; the required fallback is no longer capped at five seconds.
  • If the optional balance request fails while waiting, the subscription result is still returned with a nil balance; the CLI read does not fail.

Maintainer follow-up in 8fd66a4a6c bounds workspace discovery and the balance request at five seconds in the local-overlay helper and adds OpenCodeGoOptionalZenBalanceTimeoutTests.

Tests

  • optional zen balance does not stall subscription usage (unchanged: app path still completes under 700 ms with a 1 s balance response)
  • cli wait policy includes slow but successful zen balance (1 s delayed valid balance is included)
  • cli wait policy keeps subscription result when balance fetch fails
  • cli wait policy keeps configured timeout when zen balance becomes required (Zen-only fallback keeps --web-timeout)
  • web strategy waits for zen balance only on usage completeness reads (guard-style CLI contexts do not wait)

Validation

  • swift test --filter 'OpenCodeGo...' - 34/34 passed
  • make check - SwiftFormat clean, SwiftLint 0 violations
  • make test - 760 selections / 64 groups, all passed

Note: the latest swift-test-macos (1, 2) CI failure on this branch is an unrelated timing flake in KimiProviderTests (subscription grace is a total budget for existing usage windows, 0.25444 s vs a 250 ms budget); the PR does not touch Kimi code and the test passes locally.

Real-behavior proof (redacted live codexbar usage --provider opencodego transcript) still needs an OpenCode Go account and is pending.
Closes #2581

Summary

codexbar usage --provider opencodego can silently drop the OpenCode Zen balance when the balance page responds more than 250 ms after the subscription page: the optional Zen join grace (optionalZenBalanceJoinGrace, 250 ms) resolves as nil and cancels the in-flight balance request.

This PR keeps the app's intentional fast refresh and changes the join contract for one-shot usage reads:

  • OpenCodeGoUsageFetcher.fetchUsage gains waitForZenBalance (default false). When enabled, the optional Zen balance is joined with the optional-balance timeout (5 s) instead of the 250 ms grace, so a slower but successful balance response is included in the snapshot.
  • ProviderFetchContext gains requiresOptionalUsageCompleteness (default false). Only usage-snapshot reads (codexbar usage, codexbar serve) set it, so codexbar guard and diagnostic commands keep the 250 ms bounded join and a slow balance cannot consume the guard deadline.
  • When subscription parsing finds no usage fields (Zen-only account), the balance request keeps the caller-configured --web-timeout; the required fallback is no longer capped at five seconds.
  • If the optional balance request fails while waiting, the subscription result is still returned with a nil balance; the CLI read does not fail.

Maintainer follow-up in 8fd66a4a6c bounds workspace discovery and the balance request at five seconds in the local-overlay helper and adds OpenCodeGoOptionalZenBalanceTimeoutTests.

Real behavior proof

Live runs against a real OpenCode Go account, same command (codexbar usage --provider opencodego --format json), same network, three runs each:

Branch Run 1 Run 2 Run 3
main (e59539db, 0.47.0) providerCost missing providerCost missing providerCost missing
this PR (5564c2cf) providerCost present providerCost present providerCost present

On this network the Zen balance endpoint consistently finishes more than 250 ms after the subscription page, so main drops it on every run; the PR branch includes it on every run.

Redacted PR-branch transcript (the output contains no cookies, account identifiers, or workspace IDs, so nothing further needed redacting):

[
  {
    "provider" : "opencodego",
    "source" : "web",
    "usage" : {
      "primary" : {
        "resetsAt" : "2026-08-03T21:10:06Z",
        "usedPercent" : 2,
        "windowMinutes" : 300
      },
      "providerCost" : {
        "currencyCode" : "USD",
        "limit" : 0,
        "period" : "Zen balance",
        "updatedAt" : "2026-08-03T16:43:53Z",
        "used" : 0
      },
      "secondary" : {
        "resetsAt" : "2026-08-09T23:59:57Z",
        "usedPercent" : 9,
        "windowMinutes" : 10080
      },
      "tertiary" : {
        "resetsAt" : "2026-09-01T16:44:42Z",
        "usedPercent" : 51,
        "windowMinutes" : 43200
      },
      "updatedAt" : "2026-08-03T16:43:53Z"
    }
  }
]

The same command on main returns the identical shape without providerCost:

{
  "provider" : "opencodego",
  "source" : "web",
  "usage" : {
    "primary" : { "usedPercent" : 2, "windowMinutes" : 300 },
    "secondary" : { "usedPercent" : 9, "windowMinutes" : 10080 },
    "tertiary" : { "usedPercent" : 51, "windowMinutes" : 43200 },
    "updatedAt" : "2026-08-03T16:43:57Z"
  }
}

Tests

  • optional zen balance does not stall subscription usage (unchanged: app path still completes under 700 ms with a 1 s balance response)
  • cli wait policy includes slow but successful zen balance (1 s delayed valid balance is included)
  • cli wait policy keeps subscription result when balance fetch fails
  • cli wait policy keeps configured timeout when zen balance becomes required (Zen-only fallback keeps --web-timeout)
  • web strategy waits for zen balance only on usage completeness reads (guard-style CLI contexts do not wait)

Validation

  • swift test --filter 'OpenCodeGo...' - 34/34 passed
  • make check - SwiftFormat clean, SwiftLint 0 violations
  • make test - 760 selections / 64 groups, all passed

Note: the earlier swift-test-macos (1, 2) CI failure on this branch was an unrelated timing flake in KimiProviderTests (subscription grace is a total budget for existing usage windows, 0.25444 s vs a 250 ms budget); the PR does not touch Kimi code and the test passes locally.

@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Aug 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7f5e59748

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// than the subscription page is worth waiting for (bounded by the balance request timeout).
/// The menu-bar app keeps the short optional join grace so refreshes never stall behind it.
static func shouldWaitForZenBalance(context: ProviderFetchContext) -> Bool {
context.runtime == .cli

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude guard fetches from the Zen-balance wait

Using runtime == .cli also enables this policy for codexbar guard, whose CLIGuardCommand.guardFetchOutcome only consumes the subscription rate windows and wraps the whole operation in the user-specified guard deadline. If the subscription page succeeds but the optional Zen request is slow—especially when its workspace and billing requests run sequentially—a short --timeout can now produce an unavailable/timeout decision (or fail open) instead of evaluating the already-fetched quota; previously the 250 ms join returned that quota promptly. Restrict the wait to usage reads, or disable optional usage in the guard context.

Useful? React with 👍 / 👎.

workspaceID: workspaceID,
cookieHeader: requestCookieHeader,
timeout: timeout,
timeout: waitForZenBalance ? min(timeout, self.optionalZenBalanceTimeout) : timeout,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the configured timeout for required Zen fallback

For a Zen-only account whose /go page has no subscription fields, requiredZenBalanceFallback reuses this task as the required source of the snapshot. With CLI waiting enabled, this line shortens that task from the caller's configured timeout (commonly 60 seconds) to 5 seconds, so a balance response arriving after 5 seconds now fails the entire CLI read even though it is within --web-timeout; the cap should apply only while the balance remains optional, or the fallback should retry with the original timeout.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 4, 2026, 7:10 AM ET / 11:10 UTC.

ClawSweeper review

What this changes

The PR makes OpenCode Go CLI usage snapshots wait for Zen balance data within a five-second optional-request budget while preserving the short wait for app, guard, and diagnostic reads.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep open: the PR has strong real-account proof, but the latest timeout calculation can still discard a Zen balance that completed before the five-second deadline when subscription parsing finishes later.

Priority: P2
Reviewed head: ff4df124ac66b4e551d9a4279f36e990818202fb

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong real-account evidence and focused tests support the goal, but the latest timeout-race fix has one remaining correctness defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR includes a redacted real OpenCode Go before/after CLI transcript across three runs per revision, directly showing the balance appear after the change.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR includes a redacted real OpenCode Go before/after CLI transcript across three runs per revision, directly showing the balance appear after the change.
Evidence reviewed 5 items Current main still has the reported behavior: Current main joins the optional Zen task with the 250 ms default grace, so the central CLI completeness problem is not already implemented.
New deadline race can lose an already-completed result: The new helper reduces the wait to zero after a slow subscription. It then creates both an observer and a zero-duration timeout; the timeout may resolve nil first even if the Zen task completed within the intended budget.
Call site exposes the race after subscription parsing: The CLI completeness path applies the computed remaining duration only after awaiting and parsing the subscription task, rather than retaining the balance outcome from task creation.
Findings 1 actionable finding [P2] Retain balances completed before the deadline
Security None None.

How this fits together

CodexBar fetches OpenCode Go subscription usage and a Zen prepaid balance concurrently, then returns a provider usage snapshot to the CLI and menu app. The changed policy determines how long each caller waits for the optional balance before producing that snapshot.

flowchart LR
A[OpenCode Go pages] --> B[Concurrent subscription and Zen requests]
B --> C[Read policy]
C --> D[CLI completeness budget]
C --> E[App and guard short grace]
D --> F[Usage snapshot]
E --> F
Loading

Before merge

  • Retain balances completed before the deadline (P2) - When subscription processing takes over five seconds, the computed remaining duration is zero even if the Zen task already succeeded. The new race then schedules a zero-duration timeout alongside its observer, so it can return nil and cancel/discard that completed balance. Record or race the result from task creation and add the slow-subscription/timely-balance regression.
  • Resolve merge risk (P1) - A slow subscription response can still cause a CLI snapshot to omit providerCost even when the Zen request completed within the promised five-second budget.
  • Resolve merge risk (P1) - The intended CLI wait can add up to five seconds to existing scripts; the fix should preserve the documented app, guard, and diagnostic short-grace paths.
  • Complete next step (P2) - The remaining defect is a narrow, mechanical concurrency repair with a clear regression scenario on the current PR head.

Findings

  • [P2] Retain balances completed before the deadline — Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoZenBalanceFetcher.swift:140-141
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +55, tests +391, changelog +1 The provider-policy change has substantial focused regression coverage, but the added race remains a merge-blocking correctness concern.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2581
Summary: This PR is the open candidate fix for the reported OpenCode Go CLI Zen-balance omission.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve completed Zen results (recommended)
    Start or retain the optional-result race when the Zen task starts so a completed result wins even if subscription processing reaches the join after the deadline.
  2. Accept incomplete edge-case snapshots
    Merge with the known risk that unusually slow subscription parsing can still omit an otherwise completed Zen balance.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve Zen task completion recorded before the five-second optional deadline, keep the required Zen-only fallback on the caller timeout, and add a regression for a slow subscription with a timely completed balance.

Technical review

Best possible solution:

Retain the task result or arm its optional deadline when the Zen task is created, then add a regression where Zen completes before five seconds but subscription parsing completes afterward.

Do we have a high-confidence way to reproduce the issue?

Yes—source establishes a controlled path: let the balance finish before five seconds, delay subscription parsing beyond five seconds, and the zero-duration join can race away the completed result. The PR body also provides real-account evidence for the underlying current-main omission.

Is this the best way to solve the issue?

No—the elapsed-duration subtraction bounds the wait but does not retain a result that completed before the deadline. A race or completion record established at task creation is the narrower safe solution.

Full review comments:

  • [P2] Retain balances completed before the deadline — Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoZenBalanceFetcher.swift:140-141
    When subscription processing takes over five seconds, the computed remaining duration is zero even if the Zen task already succeeded. The new race then schedules a zero-duration timeout alongside its observer, so it can return nil and cancel/discard that completed balance. Record or race the result from task creation and add the slow-subscription/timely-balance regression.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a82f509ea8e7.

Labels

Label justifications:

  • P2: This is a bounded provider CLI correctness issue that can omit usage data without disabling the application.
  • merge-risk: 🚨 compatibility: The PR intentionally changes the latency contract of existing OpenCode Go CLI usage reads.
  • merge-risk: 🚨 availability: The new deadline race can still return an incomplete snapshot despite a completed balance request.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR includes a redacted real OpenCode Go before/after CLI transcript across three runs per revision, directly showing the balance appear after the change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes a redacted real OpenCode Go before/after CLI transcript across three runs per revision, directly showing the balance appear after the change.

Evidence

Acceptance criteria:

  • [P1] swift test --filter OpenCodeGoUsageFetcherCLIWaitTests.
  • [P1] swift test --filter OpenCodeGoProviderStrategyTests.
  • [P1] make check.

What I checked:

Likely related people:

  • Peter Steinberger: Available current-main blame and path history point to this revision of the OpenCode Go usage-fetch path. (role: recent area contributor; confidence: medium; commits: 6a16c23313a7; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoUsageFetcher.swift, Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoZenBalanceFetcher.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Retain the Zen completion outcome from task creation and add the slow-subscription/timely-balance regression.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-02T21:00:08.328Z sha 8fd66a4 :: needs real behavior proof before merge. :: [P1] Exclude guard fetches from the Zen-balance wait | [P1] Preserve the timeout for required Zen fallback
  • reviewed 2026-08-03T03:36:25.864Z sha 5564c2c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T11:46:44.280Z sha 5564c2c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T15:56:36.151Z sha 5564c2c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T16:48:43.346Z sha 5564c2c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T19:00:49.880Z sha 5564c2c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T04:41:20.435Z sha d97edf5 :: needs changes before merge. :: [P1] Remove the unresolved changelog conflict block
  • reviewed 2026-08-04T06:11:00.568Z sha 8f4efaf :: needs changes before merge. :: [P1] Start the optional Zen deadline with its task

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Completed the maintainer follow-up in 8fd66a4a6c.

  • Reuses one min(timeout, 5s) value for both workspace discovery and the Zen balance request.
  • Adds a no-workspace-override regression proving both outgoing request timeouts are capped at five seconds.
  • Keeps the menu-bar app's optional balance join grace at 250 ms.
  • Adds the 0.46.1 changelog entry with thanks to @Yuxin-Qiao.

Proof:

  • swift test --filter OpenCodeGo — 94 tests passed.
  • make check — clean (SwiftFormat and SwiftLint: 0 violations).
  • make test — 759 selections across 64 groups; all 64 passed first attempt, with no retries or timeouts.
  • /Users/steipete/Projects/agent-skills/skills/autoreview/scripts/autoreview --mode local — clean, no accepted/actionable findings.

No merge performed.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 Urgent regression or broken agent/channel workflow affecting real users now. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 3, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/fix-opencodego-zen-balance-2581 branch from 5564c2c to d97edf5 Compare August 4, 2026 03:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d97edf5fb1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md Outdated
- About: link the Website entry to codex.bar.

### Fixed
<<<<<<< HEAD

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve the changelog conflict markers

The commit leaves an unresolved merge block in the 0.47.0 release notes; any rendered or published changelog will expose <<<<<<</=======/>>>>>>>, and the OpenCode Go fix is duplicated under the wrong historical release. Resolve the block by retaining the Alibaba entry and removing the duplicate OpenCode Go entry and markers (git diff --check also reports all three markers).

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 4, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/fix-opencodego-zen-balance-2581 branch from d97edf5 to 8f4efaf Compare August 4, 2026 05:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f4efafc20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +200 to +202
timeout: waitForZenBalance
? .seconds(self.optionalZenBalanceTimeout)
: Self.optionalZenBalanceJoinGrace)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Start the optional Zen timeout when its task starts

When the subscription page is slow and the Zen request hangs, this five-second timer is not armed until after the subscription task has completed and been parsed, even though the Zen task started concurrently and still receives the caller's potentially 60-second timeout at line 157. In the current revision, a four-second subscription fetch can therefore be followed by another five-second join, making the CLI wait roughly nine seconds for a supposedly five-second-bounded optional request. Start the optional deadline with the Zen task, while restarting it with the configured timeout if it becomes the required Zen-only fallback, or subtract the task's elapsed time here.

Useful? React with 👍 / 👎.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the changelog conflict block from the last review: removed the conflict markers, retained the Alibaba 0.47.0 entry, removed the duplicate historical OpenCode Go line, and verified git diff --check is clean. Head is 8f4efaf.

@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the P1 from the last review: the optional Zen-balance deadline now starts when the balance task is created, so a slow subscription cannot stack a second full five-second wait on top of it. Added a regression covering a slow subscription plus a hung balance (cli wait policy bounds optional balance wait from task start), and kept the caller-configured timeout for the required Zen-only fallback. Head is ff4df12.

@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff4df124ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +140 to +141
let remaining = .seconds(Self.optionalZenBalanceTimeout) - (ContinuousClock.now - startedAt)
return max(Duration.zero, remaining)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve balances completed before the deadline

When the subscription request or parsing takes more than five seconds but the Zen task has already completed successfully, this returns a zero timeout and then races an observer of the completed source task against Task.sleep(for: .zero). The timeout task can win and cancel/discard that already-available balance, so the new completeness path can still omit providerCost nondeterministically on slow subscription responses. Start and retain the timeout race when the Zen task is created, so completion before the deadline is recorded independently of when subscription parsing finishes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode Go provider silently drops Zen balance if balance fetch is >250ms slower than subscription fetch

2 participants