amazon-q-developer-cli icon indicating copy to clipboard operation
amazon-q-developer-cli copied to clipboard

The conversation history character count calculation is inaccurate

Open brandonskiser opened this issue 1 year ago • 1 comments

As noted in #1169 the calculate_char_count method on ConversationState is inaccurate since it is not being performed on the result of as_sendable_conversation_state, which is the actual conversation state being sent to the backend.

To facilitate an accurate character count calculation, we need to decouple our in-app representation of the conversation from the data being sent to the backend.

One approach would be to update as_sendable_conversation_state to be idempotent. Any code that already calls as_sendable_conversation_state would therefore not need to be updated.

brandonskiser avatar Apr 10 '25 18:04 brandonskiser

After reviewing the current source, calculate_char_count in conversation.rs already calls backend_conversation_state (which is the equivalent of as_sendable_conversation_state) rather than computing the count on the raw in-memory state. This appears to have been addressed as part of the context tracking refactor. Can a maintainer confirm whether this can be closed?

sandikodev avatar Apr 07 '26 04:04 sandikodev