You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
shelley: record fork provenance to de-duplicate usage data
Prompt: When we fork messages, do we write down where they came from?
I'd like to be able to compute usage data based on usage data and these
new llm columns.
Forking copies a conversation's messages into a new conversation with
fresh message_ids and identical usage_data/llm_api_url/model_name. Until
now nothing recorded that a message was a copy, so summing usage across
all messages (e.g. grouped by the new llm_api_url/model_name columns)
double-counts LLM work already incurred in the source conversation.
Add a nullable forked_from_message_id column on messages, populated by
CopyMessagesForFork with the source message's id (NULL for
originally-incurred messages). To compute usage that counts each LLM
call exactly once, filter WHERE forked_from_message_id IS NULL; join on
it to attribute a fork's copies back to their origin. No FK constraint:
the source may be deleted later and the fork should survive independently.
Also surface llm_api_url, model_name, and forked_from_message_id through
the API message struct and generated TS types so the front-end can do
the same attribution/de-duplication.
Co-authored-by: Shelley <shelley@exe.dev>
0 commit comments