feat: Introduce userContext for agent operations#71
Merged
Conversation
…ement during agent operations
Deploying voltagent with
|
| Latest commit: |
38b3051
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fe690475.voltagent.pages.dev |
| Branch Preview URL: | https://feat-user-context.voltagent.pages.dev |
…and improve type safety
…e EventStatus type definition
…mprove memory manager checks
… VoltagentError structure
codegen-sh Bot
referenced
this pull request
in Zeeeepa/voltagent
May 28, 2025
🎯 CONSOLIDATION OBJECTIVES ACHIEVED: ✅ Merged monitoring and performance systems into unified platform ✅ Consolidated alerting and analytics for consistency ✅ Unified observability components across all services ✅ Eliminated duplicate metrics collection ✅ Standardized monitoring interfaces 📊 CONSOLIDATED COMPONENTS: - Performance monitoring system (PR #51) - Analytics and metrics collection (PR #67) - Real-time monitoring & performance analytics (PR #71) - Comprehensive end-to-end workflow testing (PR #72) - Consolidated monitoring & testing systems (PR VoltAgent#94) 🚀 NEW UNIFIED SYSTEM FEATURES: - Single comprehensive monitoring system - Unified performance analytics with real-time tracking - Consolidated alerting system with rule-based alerts - Integrated observability platform with OpenTelemetry - Standardized monitoring interfaces across all components - Zero duplication in monitoring logic - Consistent metrics collection patterns - Dashboard system for visualization - Enhanced CLI analytics integration 🔧 TECHNICAL IMPLEMENTATION: - Core monitoring orchestrator (CoreMonitor) - Unified metrics collection (MetricsCollector) - Consolidated analytics tracking (AnalyticsTracker) - Performance monitoring (PerformanceMonitor) - Rule-based alerting system (AlertingSystem) - Dashboard and visualization (DashboardSystem) - Agent integration helpers (AgentMonitoringIntegration) - Enhanced OpenTelemetry integration - CLI analytics consolidation - Comprehensive configuration management - Backward compatibility with existing systems 📈 BENEFITS: - Single source of truth for all monitoring data - Reduced complexity and maintenance overhead - Improved performance through unified collection - Better observability with correlated data - Standardized monitoring patterns - Enhanced debugging and troubleshooting capabilities - Comprehensive testing and validation 🧪 TESTING & VALIDATION: - Comprehensive test suite for all components - Migration guide for existing implementations - Backward compatibility validation - Performance benchmarking - Error handling and resilience testing This consolidation eliminates redundancy across PRs #51,67,71,72,94 and provides a single, cohesive monitoring platform for VoltAgent.
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.
This PR introduces the
userContextfeature to VoltAgent, providing a mechanism to pass custom, operation-specific data through the lifecycle of an agent execution (e.g., a singlegenerateTextcall).PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Previously, there was no clean, isolated way to share request-specific information (like tracing IDs, user configurations, temporary state) between agent lifecycle hooks (
onStart,onEnd) and tool executions within the same operation without resorting to potentially unsafe or complex workarounds.What is the new behavior?
This PR implements
OperationContext, which includes:operationId.userContext: Map<string | symbol, unknown>property.This
OperationContextis now accessible within:Agent hooks (
onStart,onEnd).Tool
executefunctions via theoptionsparameter (options.operationContext).@voltagent/core:OperationContexttype and integrated it into agent generation methods (generateText,streamText, etc.).OperationContextto hooks and tool execution contexts.serializeValueForDebugutility (moved tosrc/utils/serialization.ts) to safely representuserContext(including complex types like functions, Symbols, classes) in history events.createStandardTimelineEvent,addToolEvent) to include the serializeduserContext.serializeValueForDebug.console:ExecutionDrawer.tsxin the debug UI to display theuserContextassociated with the selected timeline event, using theJsonViewer.website:docs/agents/context.mdexplaining theuserContextfeature with usage examples.Utils:
packages/core/src/utils/serialization.tsfor the serialization logic.closes
Notes for reviewers