fix: Research Agentのトークンカウントが0/0/0で表示される問題を修正#1481
Open
takke1986 wants to merge 1 commit intoaws-samples:mainfrom
Open
fix: Research Agentのトークンカウントが0/0/0で表示される問題を修正#1481takke1986 wants to merge 1 commit intoaws-samples:mainfrom
takke1986 wants to merge 1 commit intoaws-samples:mainfrom
Conversation
- converters.py: ResultMessageからusage dictを抽出しトークン使用量を累計 - total_input_tokens/total_output_tokensフィールドを追加 - ResultMessageをスキップせずusage.input_tokens/output_tokensを蓄積 - agent.py: ハードコードされた0/0/0をconverterの累計値に置き換え
Contributor
|
This PR is stale because it has been open for 30 days with no activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
修正内容
converters.py:
ContentBlockConverter に total_input_tokens/total_output_tokens フィールドを追加
ResultMessage を単純にスキップせず、usage dict から input_tokens/output_tokens を抽出して累計
複数ターンの会話でもトークン使用量が正しく蓄積される
agent.py:
ハードコードされた {"inputTokens": 0, "outputTokens": 0, "totalTokens": 0} を converter.total_input_tokens/converter.total_output_tokens の累計値に置き換え
既存ユーザーへの影響
破壊的変更なし
UIのトークン表示が 0/0/0 から実際の使用量に変わるため、表示上の変化あり
Research Agent 以外のユースケースには影響なし
Checklist
npm run cdk:testand if there are snapshot differences, executenpm run cdk:test:update-snapshotto update snapshotsRelated Issues
Please list related issues as much as possible.