Skip to content

fix(gateway): return real usage for OpenAI-compatible chat completions#62986

Merged
obviyus merged 7 commits into
openclaw:mainfrom
Lellansin:feat/chat-completions-usage
Apr 10, 2026
Merged

fix(gateway): return real usage for OpenAI-compatible chat completions#62986
obviyus merged 7 commits into
openclaw:mainfrom
Lellansin:feat/chat-completions-usage

Conversation

@Lellansin

@Lellansin Lellansin commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: /v1/chat/completions returned hardcoded zero usage in non-stream responses, and stream responses did not expose usage in an OpenAI-compatible way.
  • Why it matters: OpenAI-compatible clients may depend on real usage values for telemetry, metering, assertions, or downstream compatibility behavior.
  • What changed: the gateway now derives usage from result.meta.agentMeta.usage, returns it for non-stream responses, and emits a final usage chunk for stream responses when stream_options.include_usage=true.
  • What changed (stream finalization semantics): streaming teardown now uses the same finalize + usage gate pattern as openresponses-http.ts (wait for the ingress command to settle when usage output is requested) instead of closing the SSE immediately from the prior lifecycle / finally paths. This is adapter-level close ordering so the optional usage chunk can precede [DONE]; it is not an HTTP-layer setTimeout removal relative to main.
  • What changed (usage mapping): chat-completions usage clamps non-negative components before deriving total_tokens, and preserves upstream aggregate totals via max(componentTotal, aggregateTotal) when an aggregate total is present.
  • What did NOT change (scope boundary): no auth/model-routing/request-validation/tool-behavior changes; OpenAI-compatible usage mapping keeps prompt_tokens = input + cacheRead (cache-write excluded intentionally).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: the OpenAI-compatible /v1/chat/completions adapter hardcoded zero usage for non-stream responses and did not implement a compatible usage-return path for streaming responses.
  • Missing detection / guardrail: there was no targeted gateway coverage asserting that non-stream responses propagate real usage or that streaming usage finalization behaves correctly under lifecycle timing races.
  • Contributing context (if known): prior attempts addressed parts of the behavior but did not land, so the compatibility gap remained in the adapter layer.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/openai-http.test.ts (endpoint contract) and src/agents/usage.test.ts (toOpenAiChatCompletionsUsage / normalization edge cases).
  • Scenario the test should lock in: non-stream responses return real usage from agentMeta.usage; stream responses emit a final usage chunk only when stream_options.include_usage=true; normal streaming finalization is not blocked when usage output is not requested.
  • Why this is the smallest reliable guardrail: the bug is in the gateway compatibility adapter and response-shaping/finalization logic, so targeted endpoint tests cover the exact contract with minimal surface area.
  • Existing test that already covers this (if any): existing streaming/non-stream endpoint tests covered basic response flow, but not usage propagation or finalize race handling.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Non-stream /v1/chat/completions responses now return real usage values instead of hardcoded zeros when upstream usage metadata exists.
  • Stream /v1/chat/completions responses now emit a final usage chunk when stream_options.include_usage=true.
  • Default stream behavior remains compatible for clients that do not request usage.

Diagram (if applicable)

Before:

flowchart LR
    A["User request"] --> B["/v1/chat/completions adapter"]
    B --> C["Hardcoded usage = 0 / no streaming usage path"]
Loading

After:

flowchart LR
    A["User request"] --> B["/v1/chat/completions adapter"]
    B --> C["Derive usage from meta.agentMeta.usage<br/>(normalizeUsage → toOpenAiChatCompletionsUsage)"]
    C --> D["Non-stream: usage in JSON body"]
    C --> E["Stream: finalize gate + optional usage chunk<br/>when stream_options.include_usage = true"]
Loading

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node.js / gateway build
  • Model/provider: OpenClaw gateway OpenAI-compatible adapter, validated against agent runs that populate result.meta.agentMeta.usage
  • Integration/channel (if any): Gateway HTTP /v1/chat/completions
  • Relevant config (redacted): optional OPENCLAW_DEBUG_OPENAI_USAGE=1, gateway OpenAI-compatible endpoint enabled

Steps

  1. Start the gateway with the OpenAI-compatible endpoint enabled.
  2. Send a non-stream POST to /v1/chat/completions and inspect the usage field.
  3. Send a stream POST to /v1/chat/completions with stream_options.include_usage=true and inspect the final SSE usage chunk.

Expected

  • Non-stream responses return real usage values when available.
  • Streaming responses emit usage only when explicitly requested.
  • Normal streaming finalization still closes promptly when usage output is not requested.

Actual

  • Non-stream responses map real usage from agentMeta.usage.
  • Streaming responses emit a final usage chunk when requested.
  • Finalization race handling is covered so early lifecycle end does not hang usage-enabled streams.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: local endpoint tests for non-stream usage mapping, stream usage chunk emission, lifecycle-end-before-usage race handling, and default stream finalization without usage gating.
  • Edge cases checked: cache-read/cache-write usage mapping, explicit total override, stream finalize ordering, and default stream behavior when include_usage is absent.
  • What you did not verify: full provider matrix across every upstream transport and external SDK client behavior outside the gateway test surface.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: upstream usage payloads may vary by provider shape or omit some fields.
    • Mitigation: usage is derived from normalized agentMeta.usage fields with existing fallback behavior.
  • Risk: streaming finalization can regress if lifecycle timing changes.
    • Mitigation: added targeted tests for lifecycle-end-before-usage and for non-usage stream finalization behavior.

Trade-offs / Deferred follow-up

  • Current decision in this PR: keep /v1/chat/completions stream finalization semantics aligned with openresponses-http.ts (finalize request + final usage gate), instead of introducing a chat-completions-only fallback.
  • Known trade-off: when stream_options.include_usage=true, completion latency can still depend on when the ingress command settles on very slow tail/cleanup paths.
  • Why this scope boundary: this PR is focused on usage correctness and OpenAI-compatible usage payload behavior, and we want to avoid cross-endpoint semantic divergence in finalize behavior.
  • Follow-up direction (shared adapter decision): evaluate a bounded-finalize strategy for both openai-http and openresponses-http together.

Evidence links

  • src/gateway/openai-http.ts — OpenAI-compatible /v1/chat/completions adapter: usage mapping, streaming finalize gate, optional usage chunk when stream_options.include_usage=true.
  • src/gateway/openai-http.test.ts — Contract tests for non-stream usage, streaming usage chunk, finalize/lifecycle behavior, and default stream path without usage.
  • src/agents/usage.tsnormalizeUsage + toOpenAiChatCompletionsUsage (OpenAI-style prompt_tokens / completion_tokens / total_tokens, including aggregate vs component totals).
  • src/agents/usage.test.ts — Unit tests for chat-completions usage mapping edge cases.

Reference (not modified in this PR): src/gateway/openresponses-http.ts — finalize / usage-gating pattern this endpoint mirrors in comments and behavior.

Related unresolved threads

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Apr 8, 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: 02bd1f8d0c

ℹ️ 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 src/gateway/openai-http.ts

@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: b36d155812

ℹ️ 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 src/gateway/openai-http.ts Outdated

@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: bb901fbf09

ℹ️ 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 src/gateway/openai-http.ts Outdated
@Lellansin Lellansin marked this pull request as draft April 8, 2026 08:04
@Lellansin Lellansin force-pushed the feat/chat-completions-usage branch from bb901fb to 1d5e54a Compare April 8, 2026 08:38
@Lellansin Lellansin marked this pull request as ready for review April 8, 2026 08:39
@Lellansin

Copy link
Copy Markdown
Contributor Author

@codex review

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two gaps in the OpenAI-compatible /v1/chat/completions adapter: non-stream responses previously returned hardcoded zero usage, and stream responses had no usage-chunk path. The fix introduces toOpenAiChatCompletionsUsage in src/agents/usage.ts and wires it into both response paths in src/gateway/openai-http.ts, using a maybeFinalize/requestFinalize gate pattern (matching openresponses-http.ts) to ensure the final usage chunk is emitted before [DONE] when stream_options.include_usage=true. Prior review thread concerns — total_tokens divergence and cacheWrite inflation — are resolved: total_tokens is now max(componentTotal, aggregateTotal) and prompt_tokens excludes cacheWrite.

Confidence Score: 5/5

Safe to merge — no critical regressions, prior concerns resolved, and comprehensive test coverage added.

All remaining findings are P2 or lower. The finalization gate is sound and mirrors the existing openresponses-http.ts pattern; the total_tokens and cacheWrite issues flagged in prior review threads have been explicitly addressed. Tests cover non-stream usage mapping, stream usage chunk emission, the lifecycle-end-before-usage race, and default stream behavior without usage gating.

No files require special attention.

Reviews (4): Last reviewed commit: "Gateway: preserve aggregate usage totals" | Re-trigger Greptile

Comment thread src/gateway/openai-http.ts Outdated
Comment thread src/gateway/openai-http.ts Outdated

@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: 2ac3692fcf

ℹ️ 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 src/gateway/openai-http.ts Outdated
@Lellansin Lellansin marked this pull request as draft April 8, 2026 08:49
@Lellansin Lellansin marked this pull request as ready for review April 8, 2026 09:08
@Lellansin

Copy link
Copy Markdown
Contributor Author

@codex review

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Tip:

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

@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: 678903e0ca

ℹ️ 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 src/gateway/openai-http.ts Outdated
Comment thread src/gateway/openai-http.ts Outdated
@Lellansin Lellansin marked this pull request as draft April 8, 2026 09:34
@Lellansin Lellansin force-pushed the feat/chat-completions-usage branch from f61e98a to 66122d4 Compare April 10, 2026 01:45
@Lellansin Lellansin marked this pull request as ready for review April 10, 2026 01:47
@Lellansin

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 66122d4aab

ℹ️ 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 src/gateway/openai-http.ts Outdated
Comment thread src/gateway/openai-http.ts

@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: d5c97325bb

ℹ️ 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 src/gateway/openai-http.ts
@Lellansin Lellansin force-pushed the feat/chat-completions-usage branch from 265ffef to f1a102c Compare April 10, 2026 04:34

@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: 6b6fa1fe64

ℹ️ 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 src/gateway/openai-http.ts
@Lellansin Lellansin force-pushed the feat/chat-completions-usage branch from 6b6fa1f to ba6a87b Compare April 10, 2026 04:46

@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: ba6a87b747

ℹ️ 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 src/gateway/openai-http.ts Outdated

@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: 1901b68345

ℹ️ 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 src/gateway/openai-http.ts
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Apr 10, 2026
@Lellansin Lellansin marked this pull request as ready for review April 10, 2026 08:42

@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: 095c072ddc

ℹ️ 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 src/agents/usage.ts Outdated

@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: 15897be529

ℹ️ 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 src/agents/usage.ts

@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: 1debbc4071

ℹ️ 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 src/gateway/openai-http.ts Outdated
Comment on lines +675 to +679
if (!abortController.signal.aborted) {
abortController.abort();
}
maybeFinalize();
}, STREAM_USAGE_FINALIZE_GRACE_MS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove fixed 2s abort from include_usage finalization

This timer turns a normal slow-tail run into an early successful close: once lifecycle:end requests finalize, it sets zero usage and aborts after 2s even if the command is still legitimately finishing. In src/agents/pi-embedded-subscribe.handlers.lifecycle.ts:92-149, phase: "end" is emitted before async flush of pending media/channel output, so runs that need more than 2 seconds for that flush will be cut off here and the SSE closes with [DONE] before trailing assistant output (or fallback payload text) can be sent, producing truncated completions and fake zero usage.

Useful? React with 👍 / 👎.

@obviyus obviyus self-assigned this Apr 10, 2026
@obviyus obviyus force-pushed the feat/chat-completions-usage branch from 1debbc4 to 591a39a Compare April 10, 2026 16:10

@obviyus obviyus 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.

Verified the OpenAI-compatible chat completions usage fix path on the latest head. This keeps real usage in non-stream responses, emits the final usage chunk when include_usage is requested, and moves the terminal lifecycle signal behind the final flush so the compat stream no longer needs the truncating HTTP fallback.

During landing I rebased onto latest main, kept the changelog entry in the active Unreleased fixes block, and replaced the 2s HTTP abort patch with the root-cause lifecycle fix in pi-embedded subscribe. That addressed the current-head P1 about truncating slow-tail output after lifecycle end.

Local gate: oxfmt passed on the touched files. I also ran the targeted lifecycle/openai-http test lane, but the Vitest wrapper in this worktree did not return a clean exit, so I am not claiming a fully green local test run.

@obviyus obviyus merged commit 2ccd183 into openclaw:main Apr 10, 2026
8 checks passed
@obviyus

obviyus commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Landed.

Maintainer commits during landing:

Merged as 2ccd1839f212d84dfb78f78e3699c384a12ee091.

Thanks @Lellansin.

@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: 40138ef572

ℹ️ 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 +151 to +153
return flushBlockReplyBufferResult
.then(() => flushPendingMediaAndChannel())
.then(() => emitLifecycleTerminal());

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 Emit lifecycle terminal even when flush callbacks fail

If either flushBlockReplyBufferResult or onBlockReplyFlush rejects, this promise chain short-circuits before emitLifecycleTerminal() runs, so the run never emits a terminal lifecycle event from handleAgentEnd. Because createEmbeddedPiSessionEventHandler catches and logs handler rejections, this failure is silent and downstream listeners can miss phase: "end"/"error" (or receive a later generic fallback), which breaks lifecycle ordering guarantees under channel flush failures.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…aw#62986) (thanks @Lellansin)

* Gateway: fix chat completions usage compatibility

* Gateway: clarify usage-gated stream wait

* Gateway: preserve aggregate usage totals

* Agents: clamp usage components before total

* fix(gateway): bound usage stream finalization

* fix: add OpenAI compat usage changelog (openclaw#62986) (thanks @Lellansin)

* fix(agents): emit lifecycle terminal events after flush

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…aw#62986) (thanks @Lellansin)

* Gateway: fix chat completions usage compatibility

* Gateway: clarify usage-gated stream wait

* Gateway: preserve aggregate usage totals

* Agents: clamp usage components before total

* fix(gateway): bound usage stream finalization

* fix: add OpenAI compat usage changelog (openclaw#62986) (thanks @Lellansin)

* fix(agents): emit lifecycle terminal events after flush

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…aw#62986) (thanks @Lellansin)

* Gateway: fix chat completions usage compatibility

* Gateway: clarify usage-gated stream wait

* Gateway: preserve aggregate usage totals

* Agents: clamp usage components before total

* fix(gateway): bound usage stream finalization

* fix: add OpenAI compat usage changelog (openclaw#62986) (thanks @Lellansin)

* fix(agents): emit lifecycle terminal events after flush

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…aw#62986) (thanks @Lellansin)

* Gateway: fix chat completions usage compatibility

* Gateway: clarify usage-gated stream wait

* Gateway: preserve aggregate usage totals

* Agents: clamp usage components before total

* fix(gateway): bound usage stream finalization

* fix: add OpenAI compat usage changelog (openclaw#62986) (thanks @Lellansin)

* fix(agents): emit lifecycle terminal events after flush

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…aw#62986) (thanks @Lellansin)

* Gateway: fix chat completions usage compatibility

* Gateway: clarify usage-gated stream wait

* Gateway: preserve aggregate usage totals

* Agents: clamp usage components before total

* fix(gateway): bound usage stream finalization

* fix: add OpenAI compat usage changelog (openclaw#62986) (thanks @Lellansin)

* fix(agents): emit lifecycle terminal events after flush

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime size: L

Projects

None yet

2 participants