Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conversation metadata with cost and token metrics #7745

Closed
wants to merge 2 commits into from

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Apr 7, 2025

This PR updates the conversation metadata to include cost/token metrics from events.

Changes

  1. Added new fields to ConversationMetadata class:

    • accumulated_cost: Tracks the total cost of the conversation
    • prompt_tokens: Tracks the number of prompt tokens used
    • completion_tokens: Tracks the number of completion tokens used
    • total_tokens: Tracks the total number of tokens used
  2. Renamed _update_timestamp_for_conversation to _update_conversation_for_event to better reflect its expanded purpose

  3. Modified _create_conversation_update_callback to pass the event to the callback function

  4. Updated the function to extract and store metrics from the event when available

  5. Added a migration script (scripts/migrate_conversation_metadata.py) to update existing conversation metadata files with the new fields


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:e4afdfd-nikolaik   --name openhands-app-e4afdfd   docker.all-hands.dev/all-hands-ai/openhands:e4afdfd

@rbren rbren closed this Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants