Fix inbound call phone numbers not shown in usage logs (#241)

For outbound calls, the caller phone is stored as "phone_number" in
initial_context. For inbound calls, it is stored as "caller_number".
The usage log extraction only checked "phone_number", so inbound
caller numbers were never surfaced.

Add a fallback to also check "caller_number" when "phone_number" is absent.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Zakir Jiwani 2026-04-17 02:12:57 -04:00 committed by GitHub
parent 79bc91b1e0
commit 1d0a7cd2d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -316,9 +316,10 @@ class OrganizationUsageClient(BaseDBClient):
total_duration_seconds += int(round(call_duration))
# Extract phone number from initial_context
# Outbound calls store it as "phone_number"; inbound calls store it as "caller_number"
phone_number = None
if run.initial_context:
phone_number = run.initial_context.get("phone_number")
phone_number = run.initial_context.get("phone_number") or run.initial_context.get("caller_number")
# Extract disposition from gathered_context
disposition = None