Skip to content

1.4c: record_usage() accepts **kwargs and handles 204#13

Merged
Shaivpidadi merged 1 commit into
devfrom
feat/1.4c-record-usage-kwargs
May 12, 2026
Merged

1.4c: record_usage() accepts **kwargs and handles 204#13
Shaivpidadi merged 1 commit into
devfrom
feat/1.4c-record-usage-kwargs

Conversation

@Shaivpidadi
Copy link
Copy Markdown
Member

Summary

  • record_usage() / async_record_usage() now accept **kwargs per the 1.4c acceptance criteria
  • Recognised keys (output_tokens, cost, provider, tool_id, correlation_id, metadata) map to the platform API's camelCase fields; unknown keys pass through
  • Sync and async share a single _build_usage_payload helper
  • Error message now tells the caller what to check (org_id/user_id/scope) instead of just echoing HTTP status

GovernsAI Tracker issue

GOV-576

Reviewers

Tagging Nexus (code quality) and Cipher (security/arch) — both approvals required.

Test plan

  • Unit — existing test_record_usage_sends_correct_payload still passes
  • Unit — 204 No Content success path (sync + async) — new
  • Unit — kwargs forwarding: recognised keys map correctly, unknown keys pass through — new
  • Full suite: 39 passed locally (pytest)
  • black --check clean on touched files
  • mypy src/governs_ai/client.py clean

record_usage() / async_record_usage() now match the 1.4c API contract:
- accept arbitrary **kwargs; recognised keys (output_tokens, cost,
  provider, tool_id, correlation_id, metadata) map to camelCase payload
  fields, unknown keys pass through unchanged
- unify sync/async payload construction via _build_usage_payload
- error message now points the caller at actionable next steps

Adds unit coverage:
- 204 No Content success path (sync + async) — SDK must not raise or
  parse body
- kwargs-forwarding test verifies recognised-key mapping and
  pass-through semantics

Refs: GOV-576
@Shaivpidadi Shaivpidadi merged commit bf98dc9 into dev May 12, 2026
3 of 5 checks passed
@Shaivpidadi Shaivpidadi deleted the feat/1.4c-record-usage-kwargs branch May 12, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant