Skip to content

fix(openai-api): report turn token usage - #181

Open
fancyboi999 wants to merge 1 commit into
MemTensor:mainfrom
fancyboi999:fix/openai-api-usage-replacement
Open

fix(openai-api): report turn token usage#181
fancyboi999 wants to merge 1 commit into
MemTensor:mainfrom
fancyboi999:fix/openai-api-usage-replacement

Conversation

@fancyboi999

Copy link
Copy Markdown
Contributor

Summary

  • Supersedes fix(openai-api): report real token usage in chat completions #8 with a clean, one-commit branch from current main; the old PR remains open.
  • Carries each AgentRunner turn's accumulated usage through AgentLoop outbound metadata to non-streaming /v1/chat/completions responses.
  • Normalizes the three OpenAI usage counters and accumulates them if an empty first completion is retried.

Root cause

The API response constructed its usage object as three hard-coded zeroes even though the agent runtime had already accumulated provider usage for the completed turn.

Compatibility and scope

  • Missing usage still produces the existing all-zero usage object.
  • Streaming behavior is intentionally unchanged; this PR fixes the three hard-coded fields in normal chat-completion responses only.
  • The branch changes four files and does not include the unrelated upstream/rebase history present in fix(openai-api): report real token usage in chat completions #8.

Validation

  • Targeted OpenAI API and AgentLoop integration tests: 36 passed.
  • Full agent suite: 4,628 passed, 3 skipped.
  • Root lint, typecheck, build, and test suites passed.
  • Built API HTTP check: /health returned OK and /v1/chat/completions returned usage 42 / 17 / 59 from a local provider stub.

Supersedes #8.

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