Skip to content

[feat] Standardize media handling and unify AgentOS routers#7310

Open
nklowns wants to merge 1 commit intoagno-agi:mainfrom
nklowns:feat/media-os-updates
Open

[feat] Standardize media handling and unify AgentOS routers#7310
nklowns wants to merge 1 commit intoagno-agi:mainfrom
nklowns:feat/media-os-updates

Conversation

@nklowns
Copy link
Copy Markdown

@nklowns nklowns commented Apr 2, 2026

Summary

fixes #7311 This PR standardizes media validation across the Agent platform by moving MIME type and extension checks into the core Media classes and simplifying the corresponding AgentOS routers.

Changes

Core Media Layer (libs/agno/agno/media.py):

  • Added valid_mime_types() and valid_extensions() class methods to Image, Video, and FileMedia.
  • Centralized validation logic to avoid hardcoded lists in routers.

AgentOS Routers (libs/agno/agno/os/routers/):

  • agents/router.py & teams/router.py: Refactored file upload handling to use centralized media validation.
  • Removed duplicated processing logic for images, videos, and documents.

Utilities & Normalization (libs/agno/agno/utils/common.py & libs/agno/agno/os/utils.py):

  • Implemented case-insensitive MIME type normalization (e.g., IMAGE/PNG -> image/png).
  • Added robust handling for special characters and emojis in filenames.

Tests:

  • Added libs/agno/tests/unit/test_media_structure.py for core validation.
  • Added libs/agno/tests/unit/os/test_utils_media.py for filename and normalization.
  • Added E2E-style router tests in libs/agno/tests/unit/os/test_router_uploads.py.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh upward)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Duplicate and AI-Generated PR Check

  • I have searched existing open pull requests and confirmed that no other PR already addresses this issue
  • If a similar PR exists, I have explained below why this PR is a better approach
  • Check if this PR was entirely AI-generated (by Copilot, Claude Code, Cursor, etc.)

Additional Notes

  • Verified with 12 new unit tests covering SVG support, case-insensitivity, and filename encoding.
  • Simplifies router maintenance by decoupling API logic from media validation rules.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

PR Triage

Missing issue link: Please link the issue this PR addresses using fixes #<issue_number>, closes #<issue_number>, or resolves #<issue_number> in the PR description. If there is no existing issue, please create one first.

@nklowns nklowns force-pushed the feat/media-os-updates branch from 394fa4b to 994a781 Compare April 2, 2026 21:18
@nklowns nklowns changed the title [feat] Update media structure and OS routers for Agent platform [feat] Standardize media handling and unify AgentOS routers Apr 2, 2026
@nklowns nklowns force-pushed the feat/media-os-updates branch from 994a781 to 5ce7318 Compare April 6, 2026 13:15
@nklowns nklowns force-pushed the feat/media-os-updates branch from 5ce7318 to c668b41 Compare April 6, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Technical] Standardize Media Validation and Unify AgentOS Routers

1 participant