Add source-linked briefing example#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf8afa16b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| validate_response(response) | ||
| articles = [normalize_article(article) for article in response["news"]] | ||
| articles.sort(key=lambda article: article["title"].casefold()) | ||
| articles.sort(key=lambda article: article["published"], reverse=True) |
There was a problem hiding this comment.
Parse publication timestamps before sorting
When responses contain valid timestamps with different UTC offsets, lexicographic ordering is not chronological; for example, 2026-01-01T00:30:00+01:00 sorts ahead of the newer 2025-12-31T23:45:00Z. Parse and normalize nonempty timestamps before sorting so the documented newest-first order remains correct.
Useful? React with 👍 / 👎.
| if article["published"]: | ||
| lines.append(" - Published: {}".format(article["published"])) | ||
| if article["description"]: | ||
| lines.append(" - {}".format(article["description"])) |
There was a problem hiding this comment.
Escape article text before rendering Markdown
When a live article description contains Markdown or a newline such as summary\n- Fabricated headline - <https://example.invalid>, this interpolation creates an additional rendered briefing item that appears independently source-linked. Because descriptions originate outside the application, escape Markdown control characters and indent or replace embedded line breaks before writing the human-readable briefing.
Useful? React with 👍 / 👎.
What changed
examples/source_linked_briefing/Why
The live source-linked briefing article contains inline Python but did not provide a cloneable, testable GitHub example. This change gives readers an example they can run without credentials before trying a live search.
Developer impact
Developers can run the checked-in fictional fixture without network access or an API key. Live mode uses the existing
CurrentsAPI.search()interface and keeps model processing outside the SDK example.Validation
python3 -m pytest tests/test_source_linked_briefing_example.py -q— 8 passedpython3 -m pytest tests/ -q— 22 passedpython3 -m compileall -q currentsapi examples/source_linked_briefing testsgit diff --check