feat: add news-card-agent (ASI:One interactive cards example)#142
Merged
Conversation
Add a new uAgents example that renders live news as ASI:One interactive cards without using the payment protocol. The example fetches news via Tavily with NewsAPI/Hacker News fallbacks, uses ASI1 to polish card copy, handles card selection round-trips, and documents setup, testing, and backend behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
- Apply ruff format across news-card-agent Python sources (zero behavior change; passes ruff check and ruff format --check). - Register news-card-agent in the root README LLM Integration index table. - Add CHANGELOG entry describing the interactive-cards example, multi-backend news cascade, and ASI1 copy polishing. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new official example,
news-card-agent/, that demonstrates agent-driven interactive cards on ASI:One without any payment protocol.card_kind: "custom"element-tree (section→listof items with image, heading, text, source badge, and a primary Read Full Article button).ChatMessagewhoseTextContentis the button'sselectionpayload. The agent parses it (handling both raw JSON for direct@mentionand natural-language prose from the planner), looks up the cached article inctx.storage, and renders a brand-new article detail card plus a clickable markdown link to the source. A Back to News button on the detail card re-renders the list for the last query.topic: "news"web search, default) → NewsAPI.org (/top-headlinesor/everythingwithNEWS_API_COUNTRY=anysupport) → Hacker News Firebase API (no key required, used as zero-config fallback).asi1-miniviahttps://api.asi1.ai/v1/chat/completions) polishes each article subtitle into a single tight sentence and writes the intro line above the card. All three LLM helpers degrade gracefully when no API key is set.fet-example/:agent.py,chat_proto.py,cards.py(element-tree builders),news_client.py,asi1_client.py,shared.py,requirements.txt,.env.example, and a comprehensiveREADME.md.Type of Change
Checklist
contributors/<agent-name>/(not repo root). (N/A — this is a maintainer/official example added at the repo root alongsidefet-example/andgemini-quickstart/, as permitted byCONTRIBUTING.md.)ruff check .(passes —All checks passed!onnews-card-agent/).ruff format .(applied —6 files already formattedonnews-card-agent/).README.mdfor changed example(s) (newnews-card-agent/README.mdstyled likea2a-uAgents-Integration/.../langgraph/readme.md, and registered in the rootREADME.mdLLM Integration index table)..env.exampleif environment variables are required (documentsASI_ONE_API_KEY,ASI_ONE_MODEL,TAVILY_API_KEY,NEWS_API_KEY,NEWS_API_COUNTRY).contributors/CHANGELOG.mdfor community agent changes, or rootCHANGELOG.mdfor other non-doc changes (rootCHANGELOG.mdupdated — this is a maintainer example, so the root changelog is the correct file).README.md(if new agent). (N/A — official root example. Added to the LLM Integration index table instead.)review-requiredCI).Related Issue
None.
Notes for Reviewers
agent.include(chat_proto, publish_manifest=True). There is nopayment.pyand no FET/Stripe code paths.ChatMessagecarries aTextContentpreamble + oneMetadataContentblock withcard_protocol_version: "1",requires_card_interaction: "true",card_kind: "custom", andcard_payloadJSON-stringified — matches the agent-driven interactive cards spec.shared.parse_card_selection()handles both inbound formats (raw JSON for direct@mention, regex over prose for the planner path) and is unit-checked forarticle_id,back_to_news, and "not a selection" cases.TAVILY_API_KEY(orNEWS_API_KEY) upgrades it automatically.NEWS_API_COUNTRY=any(or blank,all,global,world) skips the country filter and routes the request through NewsAPI/everythingso the call never fails the "country/category/sources required" validation.query="latest tech news"— returned 3 articles with real image URLs and source domains (cnbc.com, cnet.com), confirming the request shape and response parsing.python agent.py→ on ASI:One sendlatest tech news→ tap any Read Full Article → tap Back to News. The detail card also includes a markdown link[Open original article](<url>)in the chat bubble.Made with Cursor