Skip to content

Carry usage metadata on completion_ended - #61

Merged
x2d7 merged 1 commit into
mainfrom
feat/usage-event
Nov 10, 2026
Merged

x2d7 merged 1 commit into
mainfrom
feat/usage-event

Conversation

@x2d7

@x2d7 x2d7 commented Nov 10, 2026

Copy link
Copy Markdown
Owner

completion_ended now carries provider metadata for the generation it closes:
prompt_tokens, completion_tokens, total_tokens, cost_usd,
list_cost_usd, billing_source, finish_reason, model and vendor extras in
metadata. All fields are optional.

  • Streamed OpenAI requests ask for usage by default
    (stream_options.include_usage); set DisableUsageReporting to turn it off.
  • The connector emits one completion_ended with tool calls and metadata.
  • openai_connect.CompletionMetaFromCompletion extracts the same metadata from
    a non-streaming completion.
  • NewEventCompletionEnded is unchanged;
    NewEventCompletionEndedWithUsage adds metadata.

Expose provider metadata for one generation on the existing terminal event.

- add CompletionMeta and NewEventCompletionEndedWithUsage
- keep NewEventCompletionEnded(toolCalls) unchanged
- serialize tokens, cost, billing source, finish reason and model as part
  of completion_ended
- request stream usage by default (stream_options.include_usage) with
  DisableUsageReporting to turn it off
- emit one completion_ended at the end of an OpenAI stream with tool calls
  and metadata
- add CompletionMetaFromCompletion for non-streaming completions
- stabilize the auto-approve tool execution test

No separate usage event.
@x2d7
x2d7 merged commit 144fdfb into main Nov 10, 2026
1 check passed
@x2d7
x2d7 deleted the feat/usage-event branch November 10, 2026 08:00
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.

1 participant