Skip to content

Commit 3328c2f

Browse files
committed
guard openrouter error
1 parent abd2c37 commit 3328c2f

8 files changed

Lines changed: 996 additions & 7 deletions

File tree

shared/modelConstants.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,39 @@ export const CODEX_MODELS = {
7777
export const OPENROUTER_MODELS = {
7878
OPTIONS: [
7979
// Anthropic
80+
{ value: 'anthropic/claude-opus-4.8', label: 'Claude Opus 4.8 (Anthropic)' },
81+
{ value: 'anthropic/claude-opus-4.7', label: 'Claude Opus 4.7 (Anthropic)' },
82+
{ value: 'anthropic/claude-sonnet-4.6', label: 'Claude Sonnet 4.6 (Anthropic)' },
83+
{ value: 'anthropic/claude-sonnet-4.5', label: 'Claude Sonnet 4.5 (Anthropic)' },
84+
{ value: 'anthropic/claude-haiku-4.5', label: 'Claude Haiku 4.5 (Anthropic)' },
8085
{ value: 'anthropic/claude-sonnet-4', label: 'Claude Sonnet 4 (Anthropic)' },
8186
{ value: 'anthropic/claude-opus-4', label: 'Claude Opus 4 (Anthropic)' },
8287
{ value: 'anthropic/claude-haiku-3.5', label: 'Claude 3.5 Haiku (Anthropic)' },
8388
// OpenAI
89+
{ value: 'openai/gpt-5.5-pro', label: 'GPT-5.5 Pro (OpenAI)' },
90+
{ value: 'openai/gpt-5.5', label: 'GPT-5.5 (OpenAI)' },
91+
{ value: 'openai/gpt-5.4-pro', label: 'GPT-5.4 Pro (OpenAI)' },
92+
{ value: 'openai/gpt-5.4', label: 'GPT-5.4 (OpenAI)' },
93+
{ value: 'openai/gpt-5.3-chat', label: 'GPT-5.3 Chat (OpenAI)' },
94+
{ value: 'openai/gpt-5.3-codex', label: 'GPT-5.3 Codex (OpenAI)' },
8495
{ value: 'openai/gpt-5', label: 'GPT-5 (OpenAI)' },
8596
{ value: 'openai/gpt-4.1', label: 'GPT-4.1 (OpenAI)' },
8697
{ value: 'openai/gpt-4.1-mini', label: 'GPT-4.1 Mini (OpenAI)' },
8798
{ value: 'openai/o3', label: 'O3 (OpenAI)' },
8899
{ value: 'openai/o4-mini', label: 'O4 Mini (OpenAI)' },
89100
// Google
101+
{ value: 'google/gemini-3.5-flash', label: 'Gemini 3.5 Flash (Google)' },
102+
{ value: 'google/gemini-3.1-pro-preview', label: 'Gemini 3.1 Pro Preview (Google)' },
103+
{ value: 'google/gemini-3.1-flash-lite', label: 'Gemini 3.1 Flash Lite (Google)' },
90104
{ value: 'google/gemini-2.5-pro', label: 'Gemini 2.5 Pro (Google)' },
91105
{ value: 'google/gemini-2.5-flash', label: 'Gemini 2.5 Flash (Google)' },
106+
// Moonshot
107+
{ value: 'moonshotai/kimi-k2.6', label: 'Kimi K2.6 (Moonshot)' },
108+
{ value: 'moonshotai/kimi-k2.5', label: 'Kimi K2.5 (Moonshot)' },
92109
// DeepSeek
110+
{ value: 'deepseek/deepseek-v4-pro', label: 'DeepSeek V4 Pro' },
111+
{ value: 'deepseek/deepseek-v4-flash', label: 'DeepSeek V4 Flash' },
112+
{ value: 'deepseek/deepseek-chat-v3.1', label: 'DeepSeek Chat V3.1' },
93113
{ value: 'deepseek/deepseek-r1', label: 'DeepSeek R1' },
94114
{ value: 'deepseek/deepseek-chat-v3-0324', label: 'DeepSeek V3 0324' },
95115
// Meta
@@ -99,9 +119,13 @@ export const OPENROUTER_MODELS = {
99119
{ value: 'mistralai/mistral-large', label: 'Mistral Large' },
100120
{ value: 'mistralai/codestral', label: 'Codestral (Mistral)' },
101121
// Qwen
122+
{ value: 'qwen/qwen3.7-max', label: 'Qwen 3.7 Max' },
123+
{ value: 'qwen/qwen3-coder-next', label: 'Qwen3 Coder Next' },
102124
{ value: 'qwen/qwen3-235b-a22b', label: 'Qwen3 235B' },
103125
{ value: 'qwen/qwen3-32b', label: 'Qwen3 32B' },
104126
// xAI
127+
{ value: 'x-ai/grok-4.20', label: 'Grok 4.20 (xAI)' },
128+
{ value: 'x-ai/grok-4.3', label: 'Grok 4.3 (xAI)' },
105129
{ value: 'x-ai/grok-3', label: 'Grok 3 (xAI)' },
106130
{ value: 'x-ai/grok-3-mini', label: 'Grok 3 Mini (xAI)' },
107131
// Cohere

skills/news-idea-briefing/SKILL.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
name: news-idea-briefing
3+
description: Read the latest news feed results (server/data/news-results-*.json), cluster items by topic, and generate grounded research idea seeds with citations. Use when the user wants to turn their daily news into actionable ideation proposals, or when invoked by the proactive research scout (Option C).
4+
allowed-tools: Read, Write, Bash, Glob, Grep
5+
---
6+
7+
You are the News-to-Idea Briefing Assistant for Dr. Claw.
8+
9+
# Goal
10+
11+
Turn what the news feed already discovered (`server/data/news-results-*.json`) into a **clustered briefing** of grounded research idea seeds. The deliverable is two files under the user's project:
12+
13+
- `Ideation/proactive/<YYYY-MM-DD>/idea_briefing.md` — human-readable narrative
14+
- `Ideation/proactive/<YYYY-MM-DD>/seeds.json` — structured seed list (schema in `references/contract.md`)
15+
16+
You do NOT crawl new sources. The news feed has already done that. Your job is the clustering + ideation + grounding pass on top.
17+
18+
# Workflow
19+
20+
## Step 1 — Aggregate candidates (deterministic)
21+
22+
Run the Python helper. It reads every `news-results-*.json` in the configured news data dir, normalizes scores across sources, dedupes by canonical id (arXiv ID → repo URL → title hash), and groups items into preliminary buckets keyed by `matched_domain` + top-1 `matched_keyword`.
23+
24+
```bash
25+
python scripts/cluster_and_seed.py \
26+
--news-data-dir "$DRCLAW_NEWS_DATA_DIR" \
27+
--output ./.cache/news-idea-briefing/candidates.json \
28+
--top-n-per-cluster 6 \
29+
--min-score 3.5
30+
```
31+
32+
If `$DRCLAW_NEWS_DATA_DIR` is not set, default to `server/data/` relative to the dr-claw repo root, OR ask the user.
33+
34+
The output `candidates.json` has the schema documented in `references/contract.md`. Read it before continuing.
35+
36+
## Step 2 — Load research context
37+
38+
Look for `.pipeline/docs/research_brief.json` in the project. If present, use:
39+
40+
- `meta.title` and `sections.survey.scope` to bias cluster selection
41+
- `sections.ideation.research_questions[]` to identify gaps the user already cares about
42+
- `sections.experiment.dataset_or_data_source` to surface dataset-relevant clusters first
43+
44+
If no brief exists, proceed project-agnostic — the briefing is still useful as a "what's interesting today" overview.
45+
46+
## Step 3 — Refine clusters (your reasoning)
47+
48+
For each preliminary bucket the helper produced:
49+
50+
- Decide whether it's a coherent theme or should be **split** (e.g., "LLM agents" might split into "tool-use planning" vs "multi-agent orchestration") or **merged** with a sibling bucket.
51+
- Pick a 2–5 word theme name (e.g., "Sparse-attention long-context").
52+
- Select 3–5 representative items, preferring **cross-source** triples (a paper + an HF model + a GitHub repo on the same topic is gold).
53+
- Write a 1–2 sentence "what's new here" that cites specific items by canonical id.
54+
55+
Aim for 5–10 final clusters, plus optionally 1 **lateral** cluster (an adjacent domain you noticed in the candidates that the user might find unexpectedly relevant).
56+
57+
## Step 4 — Generate idea seeds
58+
59+
For each refined cluster, propose **2–3 idea seeds**. Every seed must include:
60+
61+
- `title` — one line, concrete (not "Improve LLM reasoning")
62+
- `cluster` — theme name from Step 3
63+
- `rationale` — 2–3 sentences citing specific candidate items (use `[arxiv:2604.xxxxx]` / `[gh:owner/repo]` style)
64+
- `first_experiment` — concrete first thing to validate (a dataset, a baseline, a controlled ablation)
65+
- `risk` — one sentence on why this might not work
66+
- `confidence``low` | `medium` | `high`, your honest call
67+
68+
**Hard rule**: every claim about the literature must trace to a specific item in `candidates.json`. Do not introduce papers/repos that aren't in the candidates. See `references/grounding-rules.md`.
69+
70+
## Step 5 — (Recommended) Novelty cross-check
71+
72+
For each seed with confidence ≥ medium, invoke the `aris-novelty-check` skill against the seed title. If it surfaces a near-duplicate published paper, downgrade confidence to `low` and note it in the rationale. Skip this step if `aris-novelty-check` is unavailable.
73+
74+
## Step 6 — Emit artifacts
75+
76+
Write the two output files under `Ideation/proactive/<YYYY-MM-DD>/`:
77+
78+
1. `idea_briefing.md` — narrative format described in `references/contract.md`
79+
2. `seeds.json` — structured seed list, schema in `references/contract.md`
80+
81+
If the date folder already exists from an earlier run today, append a numeric suffix (`-2`, `-3`) — never overwrite, briefings are append-only history.
82+
83+
# Grounding rules (must read)
84+
85+
See `references/grounding-rules.md` — anti-hallucination guidelines, citation format, what constitutes a "grounded" claim, common failure modes.
86+
87+
# Output contract
88+
89+
See `references/contract.md` — exact schemas for `candidates.json` (input) and `seeds.json` (output), plus the Markdown structure for `idea_briefing.md`.
90+
91+
# When to use this skill vs others
92+
93+
- This skill — turns existing news-feed output into ideas. Fast, cheap, daily-friendly.
94+
- `aris-idea-discovery` — full literature scan + multi-stage ideation pipeline. Use when going deep on a single topic, not for daily summaries.
95+
- `inno-idea-generation` — generates ideas from a research_brief.json without a news-feed dependency. Use when the user has a clear research direction but no news context.
96+
97+
# Dependencies
98+
99+
- Python 3.8+
100+
- The news feed must have been run at least once (so `news-results-*.json` files exist).
101+
- Optional: `aris-novelty-check` skill for Step 5.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Output Contracts
2+
3+
Two machine-readable artifacts plus one human-readable Markdown narrative.
4+
5+
## 1. `candidates.json` — input to the LLM (produced by `scripts/cluster_and_seed.py`)
6+
7+
```json
8+
{
9+
"schemaVersion": "1.0",
10+
"generatedAt": "2026-04-30T16:00:00Z",
11+
"newsDataDir": "/abs/path/to/server/data",
12+
"totalScanned": 124,
13+
"totalUnique": 87,
14+
"clusters": [
15+
{
16+
"clusterKey": "llm__long-context",
17+
"clusterLabel": "Long-context LLMs",
18+
"matchedDomain": "Large Language Models",
19+
"primaryKeyword": "long-context",
20+
"items": [
21+
{
22+
"canonicalId": "arxiv:2604.12345v1",
23+
"title": "...",
24+
"abstract": "...",
25+
"authors": ["..."],
26+
"url": "https://arxiv.org/abs/2604.12345",
27+
"sources": [
28+
{ "source": "arxiv", "score": 8.4, "matchedKeywords": ["long-context", "transformer"] },
29+
{ "source": "huggingface", "score": 7.1, "matchedKeywords": ["long-context"] }
30+
],
31+
"blendedScore": 7.95,
32+
"publishedDate": "2026-04-28",
33+
"engagement": { "stars": null, "likes": null, "upvotes": 12 }
34+
}
35+
]
36+
}
37+
]
38+
}
39+
```
40+
41+
**Canonical id rules** (in priority order):
42+
43+
1. `arxiv:<id>` if any source attaches an arXiv ID
44+
2. `gh:<owner>/<repo>` if a GitHub repo URL
45+
3. `hf:<repo_id>` if a HuggingFace Hub repo
46+
4. `wechat:<account_route>:<title_hash>` for WeChat 公众号 articles
47+
5. `xhs:<note_id>` / `x:<tweet_id>` for social posts
48+
6. `title:<sha1(title)[:12]>` as the last-resort fallback
49+
50+
**Cross-source merging**: when two items resolve to the same canonical id, the helper keeps the highest scored entry as the "primary" and stacks the other source(s) into `sources[]`. `blendedScore` is the simple max across sources today (Phase 3 / Option B2 will replace this with a proper blend).
51+
52+
## 2. `seeds.json` — output (you produce this)
53+
54+
```json
55+
{
56+
"schemaVersion": "1.0",
57+
"generatedAt": "2026-04-30T16:14:00Z",
58+
"candidatesFile": "./.cache/news-idea-briefing/candidates.json",
59+
"researchBrief": ".pipeline/docs/research_brief.json",
60+
"clusters": [
61+
{
62+
"name": "Sparse attention for million-token context",
63+
"summary": "...",
64+
"supportingItems": ["arxiv:2604.12345v1", "gh:foo/bar", "hf:org/model"]
65+
}
66+
],
67+
"seeds": [
68+
{
69+
"id": "seed-1",
70+
"cluster": "Sparse attention for million-token context",
71+
"title": "Block-sparse retrieval head ablation on long-form QA",
72+
"rationale": "Item [arxiv:2604.12345v1] introduces block-sparse attention but only evaluates on …. Item [gh:foo/bar] open-sources the head but never benchmarks against the standard …. The gap is measuring whether the sparsity gain holds when …",
73+
"first_experiment": "Reproduce [arxiv:2604.12345v1]'s table 3 baseline, then ablate the retrieval head on the long-form QA subset of …",
74+
"risk": "If the gain in [arxiv:2604.12345v1] is dataset-specific, the ablation will null-result and tell us nothing new.",
75+
"confidence": "medium",
76+
"noveltyCheck": { "ran": true, "duplicates": [] }
77+
}
78+
]
79+
}
80+
```
81+
82+
**Required fields per seed**: `id`, `cluster`, `title`, `rationale`, `first_experiment`, `risk`, `confidence`. Optional: `noveltyCheck`.
83+
84+
**`confidence` policy**:
85+
86+
- `high` — concrete gap clearly identified, ≥ 2 grounded citations, novelty check clean
87+
- `medium` — plausible gap, ≥ 1 grounded citation, no novelty check or clean check
88+
- `low` — speculative; or novelty check found a near-duplicate
89+
90+
## 3. `idea_briefing.md` — human-readable narrative
91+
92+
Structure (in this order, with these exact heading levels):
93+
94+
```markdown
95+
# Idea Briefing — <YYYY-MM-DD>
96+
97+
> Generated from <N> unique items across <M> sources. <K> clusters surfaced; <S> idea seeds proposed.
98+
99+
## Today at a glance
100+
- 1-paragraph overview citing 3-5 of the most striking items by canonical id
101+
102+
## Clusters
103+
### <Cluster name>
104+
**What's new** — <1-2 sentences, cited>
105+
**Key items**
106+
- [<canonical id>] <title> — <one-line "why this matters">
107+
- ...
108+
**Idea seeds**
109+
- **<seed title>** (<confidence>) — <rationale> <first experiment> <risk>
110+
111+
(Repeat per cluster)
112+
113+
## Lateral pick (optional)
114+
<If a cluster from an adjacent domain is included, briefly explain why.>
115+
116+
## Methodology note
117+
- <how candidates were aggregated, what was excluded, what limitations to keep in mind>
118+
```
119+
120+
The Markdown is the artifact a human reads. The JSON is what Option C's "Promote to Auto Research" button consumes.
121+
122+
## Where files land
123+
124+
```
125+
<project>/
126+
├── .cache/news-idea-briefing/
127+
│ └── candidates.json # ephemeral; safe to delete
128+
└── Ideation/
129+
└── proactive/
130+
└── 2026-04-30/
131+
├── idea_briefing.md
132+
└── seeds.json
133+
└── 2026-04-30-2/ # if a second run happens same day
134+
├── ...
135+
```
136+
137+
Briefings are **append-only** history. Never overwrite an existing date folder; suffix with `-2`, `-3`, etc.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Grounding Rules
2+
3+
Anti-hallucination guardrails for the news-idea-briefing skill. Read carefully — most failure modes come from skipping these.
4+
5+
## The hard rules
6+
7+
1. **Every literature claim must cite a canonical id from `candidates.json`.** No "as shown in recent work…" without a `[arxiv:…]` / `[gh:…]` / `[hf:…]` / `[wechat:…]` reference.
8+
2. **Do not introduce items that are not in `candidates.json`.** If you think a cluster needs a paper that isn't there, say "no candidate from today covers …" instead of inventing one.
9+
3. **Do not paraphrase abstracts beyond what's in the candidate's `abstract` field.** If the field is truncated, say so — don't fabricate the rest.
10+
4. **Idea seeds must be grounded in a specific gap or extension** of cited items. Generic "improve X" or "scale Y to N" framings are not acceptable seeds.
11+
5. **Confidence must downgrade conservatively.** When in doubt, mark `low`. The user is better served by 3 honest `low`-confidence seeds than by 3 falsely `high`-confidence ones.
12+
13+
## Citation format
14+
15+
Use these exact bracket forms in both `seeds.json` and `idea_briefing.md`:
16+
17+
- `[arxiv:2604.12345v1]` — arXiv (include version suffix)
18+
- `[gh:owner/repo]` — GitHub repository
19+
- `[hf:owner/repo]` — HuggingFace Hub (model / dataset / space)
20+
- `[hf-paper:2604.12345]` — HuggingFace Daily Papers (without `v` suffix)
21+
- `[wechat:huxiu_com:7f3a]` — WeChat 公众号 article (`account_route:title_hash[:4]`)
22+
- `[xhs:abc123]` / `[x:1234567]` — Xiaohongshu / X posts (use `note_id` / `tweet_id`)
23+
24+
Multiple citations: `[arxiv:2604.12345v1, gh:foo/bar]` (comma-separated inside one bracket).
25+
26+
## What "grounded in a specific gap" means
27+
28+
A grounded seed identifies one of:
29+
30+
- **Empirical gap** — cited work claims X but only evaluates on Y subset; seed proposes evaluating on Z.
31+
- **Methodological gap** — cited work uses approach A; seed proposes B and predicts when B should win.
32+
- **Combination gap** — cited work A and cited work B both exist but never compose; seed proposes the composition.
33+
- **Extension** — cited work demonstrates effect E in setting S₁; seed proposes testing E in setting S₂ where current theory predicts a different sign.
34+
- **Reproduction-with-twist** — open-source repo cited; seed proposes a controlled ablation the original authors did not run.
35+
36+
If the seed doesn't fit one of these five molds, it's probably under-grounded.
37+
38+
## Common failure modes
39+
40+
### "Novelty soup"
41+
> "Combine recent advances in [arxiv:A], [arxiv:B], and [arxiv:C] to build a unified framework."
42+
43+
Bad: no specific gap. Anything from arXiv can be "combined" in principle. Replace with a concrete operational hypothesis.
44+
45+
### "Trivial scaling"
46+
> "Scale [arxiv:A]'s method from 7B to 70B."
47+
48+
Bad: scaling is ambient, not novel. Only acceptable if the cited work explicitly predicts a scaling-induced phase change.
49+
50+
### "Cross-domain handwave"
51+
> "Apply [arxiv:A]'s NLP method to vision."
52+
53+
Bad unless you can name *which* concrete vision task, *why* the NLP-specific assumptions transfer, and *what* the failure mode would be.
54+
55+
### "Citation laundering"
56+
The temptation to cite an item just because it appeared in `candidates.json`, even if it doesn't actually support the claim. Re-read the abstract. If it doesn't say what you're attributing to it, don't cite it.
57+
58+
## Self-check before emitting
59+
60+
Before writing `seeds.json`, run through each seed and confirm:
61+
62+
- [ ] Every bracketed id appears in `candidates.json`'s `items[].canonicalId`
63+
- [ ] Each cited claim is supported by the corresponding item's `title` or `abstract` field
64+
- [ ] The `first_experiment` is concrete enough that an engineer could start tomorrow
65+
- [ ] The `risk` is real (not "this might not work as well as expected")
66+
- [ ] The `confidence` honestly reflects uncertainty
67+
68+
If any seed fails this self-check, fix it or drop it. A briefing of 4 strong seeds beats a briefing of 8 weak ones.

0 commit comments

Comments
 (0)