feat(genai): add local/Data URI pre-upload support and configurable hooks#119
Merged
Cirilla-zmh merged 19 commits intoalibaba:mainfrom Feb 27, 2026
Merged
feat(genai): add local/Data URI pre-upload support and configurable hooks#119Cirilla-zmh merged 19 commits intoalibaba:mainfrom
Cirilla-zmh merged 19 commits intoalibaba:mainfrom
Conversation
…ring Support Uri objects with data: scheme (base64 encoded only) in MultimodalPreUploader. - Refactor _process_message_parts to reduce redundancy: - Add _normalize_audio_data to unify audio format detection and conversion. - Add _check_size and _estimate_base64_size to unify size limit checks. - Add _resolve_mime_type to unify MIME type resolution logic. Optimize Data URI processing by estimating size before decoding. - Merge and expand unit tests in util/opentelemetry-util-genai/tests/_multimodal_upload/test_pre_uploader.py, covering: - Data URI processing (base64, explicit mime, invalid formats). - Local file URI processing. - Size limit enforcement for Blob, Base64Blob, and Data URI.
…singMixin - Added type checks for invocation objects in async methods to ensure correct processing. - Updated logging to use a casted logger for better type safety. - Refactored metric recording calls to remove type ignores and enhance clarity. - Adjusted the _record_extended_metrics method signature to accept specific invocation types. - Cleaned up test setup by removing unnecessary reset logic for MetricsSingletonMeta.
…tion support - Added entry points for multimodal uploader and pre-uploader in `pyproject.toml`. - Enhanced `README-loongsuite.rst` with detailed instructions on enabling multimodal upload features. - Implemented `GenAIShutdownProcessor` for graceful shutdown of GenAI components. - Refactored `MultimodalProcessingMixin` to support dynamic loading of uploader and pre-uploader hooks based on environment variables. - Updated `MultimodalPreUploader` to handle new upload modes and improved metadata extraction. - Added tests for shutdown processor and default hooks to ensure functionality and error handling.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the GenAI multimodal upload pipeline with support for Data URI and local file path inputs, adds AgentInvocation multimodal data handling, implements a configurable hook-based system for uploader/pre-uploader loading, and introduces graceful shutdown coordination for GenAI components.
Changes:
- Add Data URI and local file path support to
MultimodalPreUploaderwith security controls - Implement entry-point-based hook system for dynamic uploader/pre-uploader discovery and loading
- Add multimodal data processing support for
InvokeAgentInvocationwith async handling - Introduce
GenAIShutdownProcessorfor coordinated graceful shutdown of GenAI components - Refactor metrics recording with
_record_extended_metricshelper method
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test_shutdown_processor.py | New test file validating shutdown processor behavior with mock handlers and uploaders |
| test_extended_handler.py | Agent multimodal async processing tests, Chinese comments for shutdown tests |
| test_pre_uploader_audio.py | Add default upload mode fixture for audio tests |
| test_pre_uploader.py | Comprehensive tests for Data URI, local file, and size limit handling |
| test_multimodal_upload_hook.py | New tests for entry-point-based hook loading and validation |
| test_fs_uploader.py | Corrected OSS environment variable names |
| test_default_hooks.py | New tests for default fs uploader and pre-uploader hook factories |
| shutdown_processor.py | New SpanProcessor for coordinated graceful shutdown with configurable timeouts |
| extended_types.py | Added monotonic_end_s field to InvokeAgentInvocation |
| extended_handler.py | Agent multimodal support, refactored metrics recording, renamed shutdown method |
| extended_environment_variables.py | New env vars for upload mode, hook selection, local file access, changed defaults |
| pre_uploader.py | Data URI parsing, local file reading with path validation, audio normalization refactor |
| multimodal_upload_hook.py | New hook loading system with entry point discovery and singleton caching |
| fs_uploader.py | Added fs_uploader_hook factory function for entry point integration |
| _base.py | Added default shutdown method to PreUploader protocol |
| init.py | Updated exports for new hook-based loading system |
| _multimodal_processing.py | Agent multimodal async methods, refactored fallback/dispatch logic |
| pyproject.toml | Entry point configuration for uploader/pre-uploader hooks |
| README-loongsuite.rst | Documentation for multimodal upload, hook system, shutdown processor usage |
| CHANGELOG-loongsuite.md | Changelog entry for this PR |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/shutdown_processor.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-genai/tests/_multimodal_upload/test_pre_uploader.py
Show resolved
Hide resolved
...lemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/multimodal_upload_hook.py
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py
Outdated
Show resolved
Hide resolved
Cirilla-zmh
requested changes
Feb 13, 2026
Collaborator
Cirilla-zmh
left a comment
There was a problem hiding this comment.
Great job! I have some concerns about the implementations which may help.
util/opentelemetry-util-genai/src/opentelemetry/util/genai/extended_environment_variables.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/extended_handler.py
Outdated
Show resolved
Hide resolved
...lemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/multimodal_upload_hook.py
Show resolved
Hide resolved
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_multimodal_upload/pre_uploader.py
Outdated
Show resolved
Hide resolved
- Split multimodal upload dependencies into separate groups in `pyproject.toml`. - Introduced new environment variables for audio conversion and local file handling. - Updated `README-loongsuite.rst` with detailed descriptions of new features and configuration options. - Refactored `MultimodalProcessingMixin` and `MultimodalPreUploader` to improve shutdown handling and configuration management. - Added utility functions for environment variable parsing related to multimodal features. - Removed the `GenAIShutdownProcessor` class as it is no longer needed. - Enhanced tests for multimodal upload hooks and audio conversion functionality.
123liuziming
approved these changes
Feb 27, 2026
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
This PR refactors and enhances the GenAI Multimodal Upload Pipeline. The primary focus is shifting to a Lazy Loading architecture, which not only avoids unnecessary resource overhead but also establishes the necessary invocation points for multimodal processing that were previously missing. Additionally, it enhances security for local file handling and provides seamless integration for AgentInvocation in Agentscope.
Key changes
MultimodalPreUploaderto support Data URI and local file path inputs.pyproject.toml.GenAIShutdownProcessorfor graceful shutdown of GenAI components.README-loongsuite.rstwith multimodal upload configuration and usage guidance.Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.