Repository navigation
Conversation
Greptile SummaryThis PR introduces a
Confidence Score: 4/5Not safe to merge as-is — the undefined sessionKey argument is a compile-time type error that will break pnpm tsgo and pnpm build. One P1 finding: passing undefined where string is required in createInternalHookEvent is a TypeScript type error that will fail the build gate. All other changes (quota classification, backoff policy, failover policy, hook types) are logically sound and consistent. Score is 4 pending that one fix. src/agents/auth-profiles/state-observation.ts (undefined sessionKey); src/hooks/internal-hooks.ts (missing isAgentProviderTrippedEvent guard) Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/auth-profiles/state-observation.ts
Line: 64
Comment:
**`undefined` passed for `sessionKey: string` — type error**
`createInternalHookEvent` expects its third argument as `string`, not `string | undefined`. Passing `undefined` here is a TypeScript type error that will fail `pnpm tsgo` / `pnpm build`. Provider-level events have no natural session key, but the contract must still be satisfied — use an empty string or a sentinel like `""` to stay within the type.
```suggestion
createInternalHookEvent("agent", "provider_tripped", "", {
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/hooks/internal-hooks.ts
Line: 40-44
Comment:
**Missing `isAgentProviderTrippedEvent` type guard**
Every other exported hook event type (`AgentBootstrapHookEvent`, `GatewayStartupHookEvent`, `MessageReceivedHookEvent`, etc.) has a corresponding `isXxxEvent` narrowing function. `AgentProviderTrippedHookEvent` is the only one without one, which breaks the established plugin API pattern and makes it harder for plugin authors to safely consume this event.
Consider adding:
```ts
export function isAgentProviderTrippedEvent(
event: InternalHookEvent,
): event is AgentProviderTrippedHookEvent {
if (!isHookEventTypeAndAction(event, "agent", "provider_tripped")) {
return false;
}
const context = getHookContext<AgentProviderTrippedHookContext>(event);
if (!context) return false;
return hasStringContextField(context, "provider") && hasStringContextField(context, "reason");
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat: Provider circuit breaker for quota..." | Re-trigger Greptile |
| if (windowType === "disabled" && !windowReused) { | ||
| // Fire internal hook async so ContextClaw can observe provider death | ||
| triggerInternalHook( | ||
| createInternalHookEvent("agent", "provider_tripped", undefined, { |
There was a problem hiding this comment.
undefined passed for sessionKey: string — type error
createInternalHookEvent expects its third argument as string, not string | undefined. Passing undefined here is a TypeScript type error that will fail pnpm tsgo / pnpm build. Provider-level events have no natural session key, but the contract must still be satisfied — use an empty string or a sentinel like "" to stay within the type.
| createInternalHookEvent("agent", "provider_tripped", undefined, { | |
| createInternalHookEvent("agent", "provider_tripped", "", { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/auth-profiles/state-observation.ts
Line: 64
Comment:
**`undefined` passed for `sessionKey: string` — type error**
`createInternalHookEvent` expects its third argument as `string`, not `string | undefined`. Passing `undefined` here is a TypeScript type error that will fail `pnpm tsgo` / `pnpm build`. Provider-level events have no natural session key, but the contract must still be satisfied — use an empty string or a sentinel like `""` to stay within the type.
```suggestion
createInternalHookEvent("agent", "provider_tripped", "", {
```
How can I resolve this? If you propose a fix, please make it concise.| export type AgentProviderTrippedHookEvent = InternalHookEvent & { | ||
| type: "agent"; | ||
| action: "provider_tripped"; | ||
| context: AgentProviderTrippedHookContext; | ||
| }; |
There was a problem hiding this comment.
Missing
isAgentProviderTrippedEvent type guard
Every other exported hook event type (AgentBootstrapHookEvent, GatewayStartupHookEvent, MessageReceivedHookEvent, etc.) has a corresponding isXxxEvent narrowing function. AgentProviderTrippedHookEvent is the only one without one, which breaks the established plugin API pattern and makes it harder for plugin authors to safely consume this event.
Consider adding:
export function isAgentProviderTrippedEvent(
event: InternalHookEvent,
): event is AgentProviderTrippedHookEvent {
if (!isHookEventTypeAndAction(event, "agent", "provider_tripped")) {
return false;
}
const context = getHookContext<AgentProviderTrippedHookContext>(event);
if (!context) return false;
return hasStringContextField(context, "provider") && hasStringContextField(context, "reason");
}Prompt To Fix With AI
This is a comment left during a code review.
Path: src/hooks/internal-hooks.ts
Line: 40-44
Comment:
**Missing `isAgentProviderTrippedEvent` type guard**
Every other exported hook event type (`AgentBootstrapHookEvent`, `GatewayStartupHookEvent`, `MessageReceivedHookEvent`, etc.) has a corresponding `isXxxEvent` narrowing function. `AgentProviderTrippedHookEvent` is the only one without one, which breaks the established plugin API pattern and makes it harder for plugin authors to safely consume this event.
Consider adding:
```ts
export function isAgentProviderTrippedEvent(
event: InternalHookEvent,
): event is AgentProviderTrippedHookEvent {
if (!isHookEventTypeAndAction(event, "agent", "provider_tripped")) {
return false;
}
const context = getHookContext<AgentProviderTrippedHookContext>(event);
if (!context) return false;
return hasStringContextField(context, "provider") && hasStringContextField(context, "reason");
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 026705940a
ℹ️ 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".
| const disabledFailureReason = | ||
| params.reason === "billing" || params.reason === "auth_permanent" ? params.reason : null; | ||
| params.reason === "billing" || params.reason === "auth_permanent" || params.reason === "quota_exhausted" ? params.reason : null; | ||
|
|
There was a problem hiding this comment.
Add quota_exhausted to failure-reason scoring allowlist
This branch stores quota_exhausted as a disabled reason, but resolveProfilesUnavailableReason only scores reasons present in FAILURE_REASON_SET (derived from FAILURE_REASON_PRIORITY), which still omits quota_exhausted. In practice, profiles disabled for quota exhaustion are inferred as unknown, so cooldown handling can take the transient path (including probing behavior and same-provider fallback decisions) instead of the intended persistent-disabled behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6510554dce
ℹ️ 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".
| if (isPeriodicUsageLimitErrorMessage(raw)) { | ||
| return toReasonClassification(isBillingErrorMessage(raw) ? "billing" : "rate_limit"); | ||
| return toReasonClassification("quota_exhausted"); | ||
| } |
There was a problem hiding this comment.
Honor quota_exhausted when classifying HTTP 429 failures
This new quota_exhausted classification is computed from message text, but in classifyFailoverSignal any inferred HTTP status takes precedence, and status 429 is still forced to rate_limit. In practice, payloads like 429 ... daily/weekly limit reached never stay in the new lane, so they continue to take transient cooldown handling instead of the intended disabled/backoff path.
Useful? React with 👍 / 👎.
| if (inferredReason === "billing" || inferredReason === "quota_exhausted") { | ||
| const shouldProbeSingleProviderBilling = | ||
| params.isPrimary && |
There was a problem hiding this comment.
Stop probing single-provider quota outages every 30 seconds
Including quota_exhausted in this billing branch reuses shouldProbeSingleProviderBilling, which allows attempts whenever the probe throttle opens (every MIN_PROBE_INTERVAL_MS, 30s) for single-provider setups with no fallbacks. That means quota-disabled providers are retried repeatedly throughout multi-hour disabled windows, reintroducing the 429 retry loop this circuit-breaker is intended to prevent.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 4:57 PM ET / 20:57 UTC. Summary PR surface: Source +77, Tests +80. Total +157 across 14 files. Reproducibility: yes. from source inspection: the PR adds a new failover reason while adjacent allowlists and schemas enumerate old reasons and would not preserve the new one. A live after-fix exhausted-provider reproduction is still missing. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the quota-exhausted lane only if the new reason is propagated through all failover, protocol, result, docs, and error surfaces, then refresh the branch and require maintainer acceptance plus real after-fix runtime proof. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: the PR adds a new failover reason while adjacent allowlists and schemas enumerate old reasons and would not preserve the new one. A live after-fix exhausted-provider reproduction is still missing. Is this the best way to solve the issue? No, not yet; the PR is a plausible owner-boundary fix, but it is incomplete until the new reason is propagated and maintainers accept the long-disable provider semantics. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 010b61746379. Label changesLabel justifications:
Evidence reviewedPR surface: Source +77, Tests +80. Total +157 across 14 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
Thanks to @greptile-apps and @clawsweeper for the careful reviews — both points landed well, and the "split before review" recommendation is correct. Wanted to acknowledge here before I quietly force-push. P1 fixes from greptile: the Plan for the split (per @clawsweeper's "best path" guidance):
On the bot's open behavior questions — I agree changing the periodic-quota classification from Will push the split tonight or tomorrow. Cheers. |
|
Thanks for the detailed update — the split plan is well-scoped and the rationale is clear. A few notes: On the P1 fixes in 6510554dce — good to hear the On the split plan itself — the three-way split is exactly the right call:
On Looking forward to reviewing the narrowed PR when it's ready. Tip: You can customize Greptile's behavior for this repo with |
|
Split done in 3c0730c — this PR is now scoped strictly to the circuit-breaker (11 files, +65/-13):
The Re-running CI now. |
Per @clawsweeper review on PR openclaw#64127 and @greptile-apps feedback: this PR is now scoped strictly to the quota-exhaustion circuit breaker — quota_exhausted failure reason classification, the 5–24h disabled lane routing, and the agent:provider_tripped internal hook event with its isAgentProviderTrippedEvent guard. The PluginStatusProvider / registerStatusProvider plugin API and TUI status/cost render-path changes have moved to a separate PR (forthcoming) that resolves openclaw#64086 and coordinates with openclaw#53774. Pre-existing tsgo errors in extensions/msteams/src/attachments.test.ts and src/process/supervisor/adapters/child.test.ts are unrelated to this PR and present on main; --no-verify used (matches precedent set by b8db4c4 on PR openclaw#64436).
3c0730c to
cdfd5cb
Compare
800b709 to
bcaeb4b
Compare
|
@dodge1218 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
Closing per ClawSweeper review verdict |
Resolves #64085
This PR introduces proper handling for daily/weekly/monthly quota exhaustion errors:
"quota_exhausted"(rather than transientrate_limit).quota_exhaustedthrough the same persistent backoff lane as billing failures (bypassing the provider for 5-24 hours).agent:provider_trippedinternal hook event whenever a provider enters the disabled lane, allowing plugins (like ContextClaw) to observe and react to provider death.Real behavior proof
Behavior or issue addressed: OpenClaw previously treated periodic quota-exhaustion messages as ordinary transient rate limits, so a provider that had exhausted a daily/weekly/monthly usage window could keep being retried through the short rate-limit lane. This patch classifies those cases as
quota_exhausted, routes them through the long disabled-lane backoff, and emitsagent:provider_trippedwhen a provider enters that disabled lane.Real environment tested:
feat/provider-circuit-breakerat6f2493db9043f43a30a0b59def58a9d37206a222, then lint-only follow-up applied locally before push.RESOURCE_EXHAUSTEDcascades across 26 runIds and about 390 exhausted-provider events.Exact steps or command run after the patch:
npm run format:check -- src/agents/auth-profiles/state-observation.ts.pnpm lint --threads=8.pnpm test src/agents/failover-error.test.ts src/agents/auth-profiles/usage.test.ts src/agents/model-fallback.probe.test.ts src/agents/embedded-agent-helpers.isbillingerrormessage.test.ts.Evidence after fix: Copied local command output from the after-patch run:
Observed result after fix: The quota-exhaustion classifier lets quota text win over generic HTTP 429 rate-limit handling, active quota-disabled providers resolve as
quota_exhausted, the 30-second billing recovery probe is not reused for quota exhaustion, and quota-disabled providers only probe near disabled-window expiry. Theagent:provider_trippedhook dispatch path now satisfies the internal hook contract and narrows async dispatch errors safely.What was not tested: I did not retest against a live already-exhausted Gemini billing account after this patch. The real-world production incident is included as before-patch validation of the cascade shape; the after-patch evidence is local OpenClaw runtime-path evidence.