Skip to content

Gateway sessions have NULL model in DB #987

@heyalchang

Description

@heyalchang

Sessions created via the gateway (telegram, whatsapp, etc) end up with `model = NULL` in the sessions table. The model isn't known when `get_or_create_session()` runs because the AIAgent hasn't been constructed yet. After the agent finishes, `update_session()` writes token counts but never backfills the model.

This means `/insights` and any dashboard queries show "unknown" for most gateway sessions, even though the model is available on the agent after the first API call.

Probably a one-liner in `_handle_message()` — pass the model to `update_session()` after the agent runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions