Skip to content

feat(core): expand interactive card schemas - #908

Open
tejus3131 wants to merge 2 commits into
fetchai:mainfrom
tejus3131:feat/expand-interactive-card-schemas
Open

feat(core): expand interactive card schemas#908
tejus3131 wants to merge 2 commits into
fetchai:mainfrom
tejus3131:feat/expand-interactive-card-schemas

Conversation

@tejus3131

@tejus3131 tejus3131 commented Jun 26, 2026

Copy link
Copy Markdown

Proposed Changes

Expands uagents_core.contrib.protocols.chat.cards payload validation to match predefined card schemas + element-tree primitives (parity w/ Agentverse card spec).

Predefined cards

  • Carousel: style, root_cta, logo; image accepts URL | DisplayImage | list
  • Detail: ExpandedChoice on sub-option choices; hero_image rich media; URL validation
  • Form: cancel_cta; FormField shares InputFieldBase w/ custom-tree input
  • Review: unchanged shape; stricter CtaAction validation

Shared

  • DisplayImage (src, alt, aspect_ratio)
  • CtaAction: non-empty selection required
  • HTTP URL + aspect_ratio (W:H) validation on media fields

Custom element tree (card_kind: "custom")

  • New: VideoNode
  • ButtonNode: optional label (str | LabelWithIcon) or image; ≥1 required
  • ButtonAction: selection | redirect, bypass_required_validation
  • InputNode: full input kinds (date, time, multiselect, phone, etc.) + kind-specific validation
  • ChoiceGridChoice.image: URL | DisplayImage
  • GroupNode.gap: >= 1 when set
  • Depth limit unchanged (MAX_ELEMENT_TREE_DEPTH = 8)

Metadata helpers (create_card_content, extract_card, etc.) unchanged — wire format still v1.

Follow-up to #897; single-file change in cards/__init__.py.


Linked Issues

Closes #907


Types of changes

  • Bug fix (non-breaking change that fixes an issue).
  • New feature added (non-breaking change that adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to stop working as expected).
  • Documentation update.
  • Something else (e.g., tests, scripts, example, deployment, infrastructure).

Checklist

  • I have read the CONTRIBUTING guide
  • Checks and tests pass locally

If applicable

  • I have added tests that prove my fix is effective or that my feature works
  • I have added/updated the documentation (executed the script in python/scripts/generate_api_docs.py)

Further comments

Validation tightened per spec (non-empty CTA selections, HTTP URLs, input kind rules). Valid payloads from #897 should still pass; loose/invalid payloads may now fail — intentional.

Align card payload validation with predefined + element-tree specs:
DisplayImage, VideoNode, LabelWithIcon, extended input kinds, richer
ButtonAction/ButtonNode, carousel detail/form/review field additions.
Copilot AI review requested due to automatic review settings June 26, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Pydantic validation models for interactive chat cards in uagents_core.contrib.protocols.chat.cards to align payload validation with the Agentverse interactive card specification, while keeping the metadata wire format at protocol version "1".

Changes:

  • Added shared schema primitives and validators (e.g., DisplayImage, stricter CtaAction, HTTP URL + aspect_ratio validation).
  • Expanded predefined card payload schemas (carousel/detail/form) and tightened validation rules for media and input field kinds.
  • Extended custom element-tree support (e.g., VideoNode, richer ButtonAction, unified InputNode validation via InputFieldBase).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand interactive card payload schemas in uagents-core

2 participants