feat: add usage columns to steps table (#9270)
* feat: add usage columns to steps table Adds denormalized usage fields to the steps table for easier querying: - model_handle: The model handle (e.g., "openai/gpt-4o-mini") - cached_input_tokens: Tokens served from cache - cache_write_tokens: Tokens written to cache (Anthropic) - reasoning_tokens: Reasoning/thinking tokens These fields mirror LettaUsageStatistics and are extracted from the existing prompt_tokens_details and completion_tokens_details JSON columns. 🤖 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * chore: regenerate OpenAPI specs and SDK for usage columns 🤖 Generated with [Letta Code](https://letta.com) Co-authored-by: Sarah Wooders <sarahwooders@users.noreply.github.com> --------- Co-authored-by: Letta <noreply@letta.com> Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com> Co-authored-by: Sarah Wooders <sarahwooders@users.noreply.github.com>
This commit is contained in:
committed by
Caren Thomas
parent
f957beaa37
commit
e0a23f7039
33
alembic/versions/3e54e2fa2f7e_add_usage_columns_to_steps.py
Normal file
33
alembic/versions/3e54e2fa2f7e_add_usage_columns_to_steps.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""add_usage_columns_to_steps
|
||||
|
||||
Revision ID: 3e54e2fa2f7e
|
||||
Revises: a1b2c3d4e5f8
|
||||
Create Date: 2026-02-03 16:35:51.327031
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "3e54e2fa2f7e"
|
||||
down_revision: Union[str, None] = "a1b2c3d4e5f8"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column("steps", sa.Column("model_handle", sa.String(), nullable=True))
|
||||
op.add_column("steps", sa.Column("cached_input_tokens", sa.Integer(), nullable=True))
|
||||
op.add_column("steps", sa.Column("cache_write_tokens", sa.Integer(), nullable=True))
|
||||
op.add_column("steps", sa.Column("reasoning_tokens", sa.Integer(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("steps", "reasoning_tokens")
|
||||
op.drop_column("steps", "cache_write_tokens")
|
||||
op.drop_column("steps", "cached_input_tokens")
|
||||
op.drop_column("steps", "model_handle")
|
||||
Reference in New Issue
Block a user