[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent card

オープン
#1,468 コメント 0 件 リアクション 0 件 担当者 2 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@rohityan がすでに取り組んでいます。

2026年11月13日 から。

  • #1469 @miinimal による — オープン

評価

この issue はまだ評価されていません。

説明

Is your feature request related to a problem? Please describe.

With validate_input_modes=True, a card that declares a media range such as image/* rejects every concrete image type, because validate_input_modes compares type/subtype literally. The question was left open in #1425 ("a card that declares image/* still only matches that literal string ... Would you rather have them handled here?"); this issue is a place to settle it.

It matters across SDKs: Microsoft Agent Framework (agent-framework-hosting-a2a) documents wildcard modes such as image/* for the cards it builds and accepts image/png against them in its own conversion, and it returns a native a2a.types.AgentCard meant to be served with this SDK's request handlers. The same card then rejects the same message here:

import asyncio
from a2a.types import AgentInterface, Message as A2AMessage, Part, Role
from a2a.utils.input_mode_validator import validate_input_modes
from agent_framework import Agent
from agent_framework_hosting_a2a import AgentA2AAdapter

agent = Agent(client=None, name="vision", description="Describes images")
adapter = AgentA2AAdapter(
    agent,
    version="1.0.0",
    supported_interfaces=[AgentInterface(url="http://localhost/a2a", protocol_binding="JSONRPC")],
    default_input_modes=["text/plain", "image/*"],
)
card = asyncio.run(adapter.get_card())
msg = A2AMessage(message_id="m1", role=Role.ROLE_USER, parts=[Part(raw=b"\x89PNG", media_type="image/png")])

adapter.a2a_to_run(msg)              # accepted by Agent Framework
validate_input_modes(msg, card)      # rejected by a2a-sdk
card default_input_modes: ['text/plain', 'image/*']
Agent Framework conversion: accepted
a2a-sdk validate_input_modes: REJECTED: ContentTypeNotSupportedError Media type image/png is not supported. Supported input modes: image/*, text/plain

The same result on this repo's main (09c9347) with a plain AgentCard(name="v", default_input_modes=["text/plain", "image/*"]): image/png and video/mp4 are rejected, text/plain is accepted.

Describe the solution you'd like

Treat a declared mode of the form type/* as a media range (the RFC 9110 section 12.5.1 meaning): it matches any part whose essence has that type. */* matches everything. Matching keeps the current rules from #1425: case-insensitive, parameters ignored, and parts without media_type are not checked. Exact declarations behave as today, so text/html still fails against text/plain.

Concretely, in src/a2a/utils/input_mode_validator.py, a declared essence ending in /* would match by type prefix, with unit tests for image/* vs image/png, IMAGE/* vs image/png; q=1, image/* vs video/mp4 (rejected), and */*.

Describe alternatives you've considered
  • Keep literal matching and document that cards must list concrete types. Cards built by other SDKs that already use ranges then have to be rewritten before validation can be turned on.
  • Expand ranges when building the card. That needs a closed list of subtypes, which a range exists to avoid.
Additional context

The specification defines input modes as media types and does not mention ranges, so this is a policy choice for the SDK, as noted in #1425. If maintainers prefer literal matching, a sentence in the validate_input_modes docstring saying ranges are not supported would also close this. I would be glad to send the PR for whichever direction you choose.

AI assistance: the analysis, the reproduction and this report were prepared with an AI coding assistant; I ran both reproductions and checked the output above.

主要言語
Python
スター
2.2k
フォーク
540
平均マージ
2日 9時間
マージ済み PR(30日)
56

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

a2aproject/a2a-python のほかの issue

a2aproject/a2a-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。