Repository navigation
feat(agent-card): add metadata field and expose list filter #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
declan-scale
merged 5 commits into
next
from
declan-scale/agx1-1048-agent-card-metadata
Sep 14, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5c23f4c
feat(agent-card): add metadata field and expose list filter
declan-scale b0e164d
fix(agent-card): add a mapping helper for the metadata filter, fix ruff
declan-scale 5eaccda
feat(worker): let AgentexWorker publish an AgentCard at registration
declan-scale ecd6e32
test(worker): expect the agent_card kwarg in the registration guard test
declan-scale 08c96f7
docs(sdk): document server version requirement and deployment-path ga…
declan-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Helpers for the platform's JSON-encoded metadata filter query parameters. | ||
|
|
||
| The containment filters on ``agents.list(agent_card_metadata=...)`` and | ||
| ``tasks.list(task_metadata=...)`` carry their filter as a JSON-encoded object | ||
| inside a single query string value, so the generated clients type them as | ||
| ``str``. Encoding by hand is easy to get subtly wrong -- Python's ``json`` | ||
| happily emits ``NaN``/``Infinity``, which the server rejects with a 400 -- so | ||
| these helpers do it once, here, in the hand-written layer where they survive | ||
| SDK regeneration. | ||
|
|
||
| from agentex.lib.utils.metadata_filters import encode_metadata_filter | ||
|
|
||
| client.agents.list( | ||
| agent_card_metadata=encode_metadata_filter({"permits_capable": True}), | ||
| ) | ||
|
|
||
| The ``agent_card_metadata`` filter requires an Agentex server that includes | ||
| scaleapi/scale-agentex#411. Older servers ignore the unknown query parameter | ||
| and return the full unfiltered agent list rather than erroring, and the SDK's | ||
| startup backend-contract check does not guard against this. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from typing import Any, Mapping | ||
|
|
||
| __all__ = ["encode_metadata_filter"] | ||
|
|
||
|
|
||
| def encode_metadata_filter(metadata: Mapping[str, Any]) -> str: | ||
| """Encode a metadata filter mapping into the wire form the platform expects. | ||
|
|
||
| Args: | ||
| metadata: The key/value pairs the target's metadata object must contain. | ||
| Values may be any JSON type; matching is exact containment, so | ||
| ``{"permits_capable": True}`` matches a stored JSON ``true`` but not | ||
| the string ``"true"``. An empty mapping matches any target that has | ||
| a metadata object at all. | ||
|
|
||
| Returns: | ||
| A compact JSON object string, with keys sorted so the same filter always | ||
| produces the same query value. | ||
|
|
||
| Raises: | ||
| TypeError: If ``metadata`` is not a mapping, or contains a value that | ||
| isn't JSON-serializable. | ||
| ValueError: If a value is a non-finite float. ``NaN`` and ``Infinity`` | ||
| aren't valid JSON and the server rejects them with a 400, so fail | ||
| here with a clearer message instead. | ||
| """ | ||
| if not isinstance(metadata, Mapping): | ||
| raise TypeError(f"metadata must be a mapping, got {type(metadata).__name__}") | ||
|
|
||
| try: | ||
| return json.dumps(metadata, allow_nan=False, separators=(",", ":"), sort_keys=True) | ||
| except ValueError as exc: | ||
| raise ValueError(f"metadata filter is not encodable as JSON: {exc}") from exc | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.