Skip to content

feat(T22): replace Anthropic SDK with OpenAI-compatible provider - #8

Merged
DamengRandom merged 2 commits into
masterfrom
feat/T22-openrouter-migration
Jul 28, 2026
Merged

feat(T22): replace Anthropic SDK with OpenAI-compatible provider#8
DamengRandom merged 2 commits into
masterfrom
feat/T22-openrouter-migration

Conversation

@DamengRandom

Copy link
Copy Markdown
Owner

Summary

Moves every agent off the Anthropic SDK onto any OpenAI-compatible endpoint, defaulting to OpenRouter with nvidia/nemotron-3-ultra-550b-a55b:free. Follows the pattern already used in the damo project's KpiSummaryAgent.

@langchain/anthropic is removed entirely — no references remain in src/, the workflows, .env.example, or the README.

Changes

Provider swap

  • New src/agent/llm.ts — a single createLlm(temperature) factory. Provider is chosen by LLM_BASE_URL; OpenRouter and the nemotron free model are the built-in defaults, so only the API key is required. NVIDIA NIM works by overriding LLM_BASE_URL / LLM_MODEL.
  • Removed the six duplicated new ChatAnthropic(...) instances across the agents.
  • Throws a clear error when LLM_API_KEY is unset rather than failing deep inside an agent call.
  • @langchain/core bumped to satisfy @langchain/openai's peer dependency.

Mock users — seeding cron disabled, workflow_dispatch retained. Code untouched.

Trending digest prompt

  • The repo count now says 5–8 in all three places. The tool schema's .describe() said 5–8 while the prompt said 1–3; the schema was silently winning.
  • Summaries bounded to 140 chars in the tool. The model overshot on 3 of 8 during testing, so the prompt alone was not sufficient.
  • Tags restricted to a closed vocabulary — they render as hashtags, so drift across days made them unsearchable.
  • url and tags are now escaped before going into the HTML message.

Bug fix — star counts were always 0

The digest had been sending ⭐ 0 for every repo. GitHub places a star <svg> between the stargazers anchor and the number, and the regex expected digits immediately after the opening tag. Against the live page: 0 matches before, 18 after.

Testing

Ran pnpm news end to end against the free model. Verified from the database:

Check Result
Repos curated 8
Rendered summaries over 140 chars 0
Tags outside the allowed list none
Repos with stars = 0 0 / 8 (was 8 / 8)
Message size 2,647 / 4,096 chars
pnpm run tsc clean

Telegram delivery confirmed on each run.

Deploy notes

One secret change under Settings → Secrets and variables → Actions:

  • delete ANTHROPIC_API_KEY
  • add LLM_API_KEY (OpenRouter key)

All other secrets are unchanged.

Known issue, not addressed here

The free model occasionally skips the tool call. curateRepos cannot distinguish that from "the model curated nothing" — toolOutput returns '', parseJson falls back to {}, and the job exits quietly. On Actions that is a green check with no digest sent. Hit once during testing; an immediate re-run with identical input succeeded. Worth a retry-on-missing-tool-call in a follow-up.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CFr2cPw9xvDvStaya9sDW8

DamengRandom and others added 2 commits July 26, 2026 15:51
Swap every agent off @langchain/anthropic onto any OpenAI-compatible
endpoint, defaulting to OpenRouter with the free nemotron model.

- add src/agent/llm.ts — single createLlm(temperature) factory, provider
  selected by LLM_BASE_URL (OpenRouter default, NVIDIA NIM supported)
- drop the six duplicated ChatAnthropic instances across the agents
- remove @langchain/anthropic; bump @langchain/core for the openai peer
- swap ANTHROPIC_API_KEY for LLM_API_KEY in the three workflows
- disable the mock user seeding cron (workflow_dispatch retained)

Trending digest improvements:

- align repo count at 5-8 across prompt, tool schema and user message;
  the schema description was silently overriding the prompt's "1-3"
- bound summaries to 140 chars in code, not just in the prompt
- restrict tags to a closed vocabulary so hashtags stay searchable
- escape url and tags before rendering into the HTML message

Fix total star counts always rendering as 0: GitHub puts an svg icon
between the stargazers anchor and the number, so the regex never
matched. Verified against the live page (0 matches before, 18 after).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFr2cPw9xvDvStaya9sDW8
The v2 action verifies `fallow-lsp` and `fallow-mcp` binaries, but from
fallow 3.x the platform packages ship a single multicall `fallow` binary.
Since the action installs the latest CLI by default, every run failed with
`binary-missing`. v3's verifier expects only `fallow`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFr2cPw9xvDvStaya9sDW8
@DamengRandom
DamengRandom merged commit b4139e1 into master Jul 28, 2026
3 checks passed
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.

1 participant