Skip to content

feat: add request metadata to the conversation history and emitted telemetry #2313

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

brandonskiser
Copy link
Contributor

@brandonskiser brandonskiser commented Jul 16, 2025

Description of changes:
Adding metadata about our send message requests, storing it as part of the conversation history, and sending it as part of ChatAddedMessage telemetry.

Details

Couple things to call out:

  1. ChatAddedMessage telemetry is now correctly being sent in all error cases, and sent after tool use execution. We may need to add more timing information after tool use execution completes, but this is omitted for now.
  2. A new type RequestMetadata is created for including information about how the response stream is handled (contains timing info between chunks, total size, etc.). This is stored in the conversation history.
  3. To prevent even more code changes, a crazy hack for getting RequestMetadata on sigint is seemingly required by the use of an Arc<Mutex<Option<RequestMetadata>>> value. This is essentially shared state between the response handler and the sigint handler, and is required because the sigint handler has no notion of what the stream output would be otherwise. This isn't ideal, but seems to be required with the current code setup without a larger refactor around ctrl+c handling.
  4. Adding a new telemetry type codewhispererterminal_recordUserTurnCompletion to the definitions, but is currently unimplemented in the code. This will be done in a followup PR.

Important Callouts

This will break the conversation serialization format with the current version since the history is being updated from (UserMessage, AssistantMessage) to a struct HistoryEntry { user, assistant, request_metadata }.

If we want to preserve backwards compatibility, then a separate PR could be made adding versioning to the conversation state instead, but doing that as part of this PR would be too much work.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@brandonskiser brandonskiser marked this pull request as ready for review July 16, 2025 16:29
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