[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent card
メンテナーはふだん 2 日以内に返信
評価
この 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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
a2aproject/a2a-python のほかの issue
-
[Bug]: `A2A-Version` validation ignores minor versions and the query parameter対応中かも @rohityan が 82 日前に担当しました。 オープンcomponent: server status:awaiting response status:stale
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
a2aproject/a2a-python#1204 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: REST task/request id sanitization再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンmaintainers-only
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
a2aproject/a2a-python#805 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: JSON-RPC client ignores the JSON-RPC error body when the HTTP status is not 2xx対応中かも @rohityan が今日担当しました。 オープン
a2aproject/a2a-python#1475 · 担当者 2 名 ·
メンテナーはふだん 2 日以内に返信
-
Required extensions aren't enforced, so ExtensionSupportRequiredError is never raised対応中かも @rohityan が 2 日前に担当しました。 オープンcomponent: server status:awaiting response
a2aproject/a2a-python#1467 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: ListTasks prints unset fields on every task (history: [] with historyLength=0, empty mediaType/filename on parts)対応中かも @rohityan が 3 日前に担当しました。 オープン
a2aproject/a2a-python#1461 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
a2aproject/a2a-python の issue をすべて見る
似ている issue
-
area:security effort:S priority:P3 status:needs-triage type:chore
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
randomparity/kdive#3657 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/mcp-proxy-for-aws#476 ·
メンテナーはふだん 1 日以内に返信
-
fix(cli): a --root that does not exist exits 0 with 'Scanned 0 file(s)', so a wrong path in CI passes silently対応中かも @arpanjot-coding が今日担当しました。 オープンarea: runtime automation bug cli code-scanning consistency developer-experience difficulty: easy github-actions good first issue help wanted json-output priority: P3 python sarif silent-failure static-analysis tests
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
ContainsOnly raises TypeError for unhashable input with set-based choices対応中かも @prathamchoksi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
marshmallow-code/marshmallow#3115 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信