-
Notifications
You must be signed in to change notification settings - Fork 2
β¨ Add tool cache token tracking and attribution (Issue #15) #16
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
rindhuja-johnson
wants to merge
21
commits into
main
Choose a base branch
from
feature/tool-cache-tracking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
This implementation provides anonymous public telemetry for the Zen orchestrator, enabling community-driven analytics that differentiate Zen from Apex's commercial approach. Key features: - Anonymous usage tracking with no authentication required - Community insights visible to all users - Embedded credentials for seamless operation - Public telemetry dashboard capabilities Files added: - TELEMETRY_SETUP_GUIDE.md: Complete setup and capabilities guide - COMMUNITY_ANALYTICS_DEMO.md: Live demo examples - COMMUNITY_ANALYTICS_SUMMARY.md: Summary of analytics features - demo_community_analytics.py: Working demo script - scripts/setup_netra_telemetry_public.sh: Automated setup script π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This implementation provides a bulletproof secret management system for the Zen-Apex integration with enterprise-grade security features. Key components: - Google Secret Manager integration with automatic rotation - Kubernetes secret management with RBAC controls - Multi-environment secret deployment (dev/staging/prod) - Comprehensive monitoring and alerting - Secure credential embedding system Files added: - zen_secrets/: Complete secret management module - core.py: Core secret management classes - gsm.py: Google Secret Manager integration - kubernetes.py: Kubernetes secret management - rotation.py: Automated secret rotation engine - monitoring.py: Monitoring and alerting system - config.py: Configuration management - ZEN_APEX_SECRET_MANAGEMENT_IMPLEMENTATION_GUIDE.md: Implementation guide - zen_secret_management_architecture.md: Architecture documentation - scripts/embed_credentials.py: Secure credential embedding π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit includes production deployment setup, core system updates, and integration improvements for the Zen-Apex ecosystem. Key components: - Production deployment guides and automation scripts - Core system updates including orchestrator enhancements - Telemetry module integration - Build and verification automation - Package configuration updates with updated .gitignore Files added/modified: - PRODUCTION_SETUP_GUIDE.md: Comprehensive production deployment guide - DEMO_SUMMARY.md: Demo summary and usage examples - scripts/build_production.sh: Production build automation - scripts/verify_production.sh: Production verification script - zen/telemetry/: Complete telemetry module implementation - zen_orchestrator.py: Enhanced orchestrator with new capabilities - pyproject.toml, requirements.txt: Updated dependencies and configuration - .gitignore: Updated to exclude sensitive files like embedded credentials - MANIFEST.in: Updated project configuration π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Removed unnecessary MockTracer and MockSpan classes that were causing import errors - Replaced with cleaner NoOpSpan for disabled telemetry cases - Updated type annotations to use Optional["trace.Tracer"] instead of Union types - Simplified error handling by removing mock object assignments - Telemetry now gracefully disables when OpenTelemetry is unavailable This fixes the "name 'MockTracer' is not defined" error during build and makes the codebase cleaner without fake implementations. π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix .gitignore formatting and add .config entry - Update community_auth.py to use embedded_credentials module - Simplify credential loading to use embedded implementation - Add GitHub workflows directory - Include system files for completeness π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements comprehensive cache token tracking for individual tools in the Tool Usage Details table, matching the command-level metrics display. Cache tokens (cache_read and cache_creation) are now properly tracked, attributed, and displayed for each tool. Key changes: - Changed tool_tokens from Dict[str, int] to Dict[str, Dict[str, int]] for structured breakdown - Added cache_read and cache_creation tracking alongside input/output/total tokens - Implemented proportional cache attribution based on tool usage frequency - Added Cache Cr and Cache Rd columns to Tool Usage Details table - Ensured tool cache totals match overall cache metrics - Added comprehensive regression tests in tests/test_tool_cache_tokens.py The cache attribution uses proportional distribution since Claude's API reports cache at the message level rather than per-tool. Tools that are used more frequently receive proportionally more cache attribution. π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Closed
18d24f3 to
26cd0d4
Compare
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.
π Summary
Implements comprehensive cache token tracking for individual tools in the Tool Usage Details table, matching the command-level metrics display. This enhancement provides better visibility into how cache tokens are utilized by different tools during Claude interactions.
π― Key Features
input,output,cache_read,cache_creation, andtotaltokens separatelyπ§ Technical Implementation
Data Structure Changes
Cache Attribution Algorithm
Since Claude's API reports cache at the message level rather than per-tool, we implement proportional distribution based on usage frequency:
Example: When total cache is 100,000 tokens:
π Real Example Output
Before Fix (Cache columns missing):
After Fix (With cache tracking):
Note how cache is distributed:
β Testing
tests/test_tool_cache_tokens.pyπ Files Changed
zen_orchestrator.py: Core implementation of cache tracking and attributiontests/test_tool_cache_tokens.py: Comprehensive test suite for cache trackingπ Fixes
Closes #15 - Tool token tracking missing cache_read and cache_creation tokens
π Documentation
The implementation includes inline documentation explaining the proportional distribution approach and limitations due to API constraints. Cache attribution is an estimate since Claude's API reports cache at message level, not per-tool.
π€ Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com