Skip to content

feat: add news-summarizer-agent using NewsAPI and ASI:One LLM#141

Merged
gautammanak1 merged 19 commits into
fetchai:mainfrom
vibeetroot:feat/news-summarizer-agent
Jun 18, 2026
Merged

feat: add news-summarizer-agent using NewsAPI and ASI:One LLM#141
gautammanak1 merged 19 commits into
fetchai:mainfrom
vibeetroot:feat/news-summarizer-agent

Conversation

@vibeetroot

@vibeetroot vibeetroot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Closes #126

Summary

Adds a new beginner-friendly news-summarizer-agent example that fetches the
top 5 news headlines for any topic using the free NewsAPI (no credit card
required) and summarizes them using ASI:One LLM. This fills the gap for a
beginner example combining real-time data fetching with LLM summarization.

Type of Change

  • New agent example

Checklist

  • I have starred this repository.
  • I ran ruff check ..
  • I ran ruff format ..
  • I added/updated README.md for changed example(s).
  • I added .env.example if environment variables are required.
  • I added demo image/GIF (if applicable).

Related Issue

Closes #126

Notes for Reviewers

  • Uses NewsAPI free tier (no credit card needed), making this accessible to
    all GSSoC contributors
  • Uses ASI:One asi1-mini model via the standard chat completions endpoint
  • Tested locally on Windows with Python 3.11 for topics: AI, sports, Finance
  • No API keys committed — .env is gitignored, only .env.example included
  • Code passes ruff check and ruff format with no issues

@vibeetroot

Copy link
Copy Markdown
Contributor Author

@gautammanak1 this has been open for 16 days. Happy to make any requested changes.

@gautammanak1

Copy link
Copy Markdown
Collaborator

Please fix the CI issues and also add ChatProtocol support. At the moment, the workflow doesn't seem to be working correctly, which is likely why the PR has remained open. Once those changes are addressed, I can review it again.

@github-actions github-actions Bot added enhancement New feature or request gssoc26 GirlScript Summer of Code 2026 contribution level2 GSSoC level 2 - intermediate (medium points) labels Jun 16, 2026
@vibeetroot

Copy link
Copy Markdown
Contributor Author

Hi @gautammanak1, I've updated the PR to address the CI issues and added Chat Protocol support using uAgents. The agent has been moved to contributors/news-summarizer-agent/ as required by the repository structure. Please let me know if anything else needs to be changed.

@vibeetroot

Copy link
Copy Markdown
Contributor Author

Hi @gautammanak1, I've resolved the merge conflict in contributors/CHANGELOG.md. The PR should be ready for review now.

@gautammanak1 gautammanak1 self-assigned this Jun 17, 2026
@gautammanak1

gautammanak1 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds a clean, beginner-friendly news-summarizer-agent that fetches news headlines via NewsAPI and summarizes them using ASI:One's asi1-mini model. The agent implements the Chat Protocol for Agentverse integration and includes proper error handling, timeout configuration, and environment variable management. Low risk — well-structured and follows the repo's conventions.

What I liked

  • The early validation in build_news_summary() (lines 78–85) is excellent — checking for missing API keys and empty topics before making any network requests keeps the UX clear and avoids unnecessary failures.
  • The timeout values (15s for NewsAPI, 30s for ASI:One) are sensible defaults that prevent hanging on slow upstream services.
  • The Chat Protocol implementation is clean: acknowledging the message first, then processing, then replying — this is the right pattern for protocol compliance.
  • The docstrings are thorough and beginner-friendly, which matches the stated goal of this example.

Security

  • ✅ No hardcoded credentials — both API keys are read from environment variables with safe defaults (empty strings). The .env file is properly gitignored per the PR description.
  • ✅ The ASI1_API_KEY is only used in the Authorization header on line 56; the value is never logged or exposed in error messages.
  • ✅ User input (topic) is passed directly to NewsAPI via query params, which is safe — NewsAPI handles the sanitization on their end. No SQL/command injection vectors here.

Correctness / logic

  • contributors/news-summarizer-agent/agent.py:45 — The list comprehension [a["title"] for a in articles if a.get("title")] correctly guards against missing or null titles. Good defensive coding.
  • contributors/news-summarizer-agent/agent.py:62data["choices"][0]["message"]["content"] assumes the ASI:One response always has at least one choice. Given the raise_for_status() on line 61, this is reasonable, but a future enhancement could add a fallback if choices is empty.
  • contributors/news-summarizer-agent/agent.py:127 — The exception handling catches requests.RequestException, which covers all requests-related errors (timeouts, connection errors, HTTP errors). This is the right granularity for this use case.
  • contributors/news-summarizer-agent/agent.py:99run_cli() is defined but never called in the module. This is fine for a helper function intended for manual testing, but it's worth noting it's not wired into the agent's main execution path.

Performance

  • ✅ The pageSize: 5 limit on NewsAPI requests keeps responses small and fast.
  • ✅ No N+1 patterns or unbounded loops — the code makes exactly two sequential HTTP requests per topic (fetch headlines, then summarize).
  • ✅ The max_tokens: 300 cap on the LLM response prevents unexpectedly long outputs.

Code quality

  • contributors/news-summarizer-agent/agent.py:102–103 — The run_cli() function uses print() for output. For a beginner example, this is acceptable since it's explicitly for local testing. If you want to be consistent with the rest of the codebase (which uses ctx.logger), you could optionally switch to logging, but I wouldn't block on this.
  • The module structure is clear: utilities first (fetch_headlines, summarize_with_asi1, build_news_summary), then protocol handlers, then agent setup. This makes the code easy to follow for beginners.
  • The unused run_cli() function could either be removed (if not needed) or documented with a comment showing how to invoke it from the command line. As-is, it's harmless.

Tests

  • This PR adds only the agent code with no accompanying tests. For a beginner example in the contributors/ directory, this is consistent with the repo's pattern — these are runnable demos rather than production code. If you want to make this more robust for contributors, consider adding a simple unit test for build_news_summary() that mocks the HTTP responses.

Suggested fixes

None blocking. If you want to polish further, here are optional enhancements:

  1. Add a fallback for empty LLM responses (optional, low priority):

    # In summarize_with_asi1(), after line 62:
    choices = data.get("choices", [])
    if not choices:
        return "Unable to generate a summary. Please try again later."
    return str(choices[0]["message"]["content"])
  2. Document run_cli() usage (optional):

    def run_cli(topic: str) -> None:
        """Run the agent's summary flow once and print the result (for local testing).
        
        Usage:
            python -c "from agent import run_cli; run_cli('AI')"
        """

Questions for the author

  • Is run_cli() intended to be invoked manually, or should it be removed to keep the module focused on the agent runtime?

LGTM! ✅ This is a well-structured, beginner-friendly example that fills a clear gap in the repo. The code is safe, readable, and follows Fetch.ai agent patterns. Ship it!

@vibeetroot

Copy link
Copy Markdown
Contributor Author

Hi @gautammanak1, I've pushed a fix removing a stray top-level demo.png file that was tripping the changelog-check (the diff had a leftover file outside contributors/, which made the workflow look for a root CHANGELOG.md update instead of contributors/CHANGELOG.md). Could you approve the pending workflow run so the checks execute on the latest commit? Also, if you're able to formally approve via Files changed → Review changes → Approve, that should satisfy the review-required check too. Thanks for your patience on this!

@gautammanak1 gautammanak1 added the level:beginner GSSoC difficulty: beginner-friendly task label Jun 18, 2026
@gautammanak1 gautammanak1 added the gssoc:approved GSSoC validation: approved by Project Admin label Jun 18, 2026
@vibeetroot

Copy link
Copy Markdown
Contributor Author

Hi @gautammanak1, thank you for reviewing and approving my PR! 🎉

I noticed that all the checks have passed and the PR is now ready to be merged. When you have a chance, could you please merge it so it can be counted for GSSoC?
Also, it seems like the GSSoC leaderboard or server hasn't updated points for the last few days. Just wanted to confirm that once this PR is merged, my points will be reflected whenever the leaderboard syncs again. Thanks a lot for your time and support!

@gautammanak1 gautammanak1 merged commit 5290694 into fetchai:main Jun 18, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gssoc:approved GSSoC validation: approved by Project Admin gssoc26 GirlScript Summer of Code 2026 contribution level:beginner GSSoC difficulty: beginner-friendly task level2 GSSoC level 2 - intermediate (medium points)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add beginner example news-summarizer-agent using free NewsAPI + ASI:One LLM

2 participants