这是indexloc提供的服务,不要输入任何密码
Skip to content

fix issues with token counting #33

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

Merged
merged 1 commit into from
Jul 23, 2025
Merged

fix issues with token counting #33

merged 1 commit into from
Jul 23, 2025

Conversation

homanp
Copy link
Contributor

@homanp homanp commented Jul 23, 2025

What does this PR do?

This pull request introduces enhancements to token counting functionality, updates the user interface for better token count display, and includes a version bump for the package. Key changes focus on improving token management in the agent, refining the UI, and adding a utility function for formatting token counts.

Token management improvements:

  • src/agent/grok-agent.ts: Updated real-time token counting to include tool calls and added a final token count update after processing all tool calls. This ensures more accurate token tracking during streaming and tool interactions. [1] [2]
  • src/agent/grok-agent.ts: Changed const to let for inputTokens to allow updates after processing tool calls.

UI enhancements:

Utility function addition:

  • src/utils/token-counter.ts: Added formatTokenCount function to format token counts for display, supporting compact representations like "k" for thousands and "m" for millions.

Version update:

  • package.json: Bumped the package version from 0.0.5 to 0.0.6.

Fixes #2

Checklist

  • I tested my changes
  • I reviewed my own code

@homanp homanp self-assigned this Jul 23, 2025
@homanp homanp merged commit 00f8d11 into main Jul 23, 2025
2 checks passed
jasonkneen pushed a commit to jasonkneen/grok-cli that referenced this pull request Jul 24, 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.

Update token counting to also include tool results
1 participant