SuperAPI AI Directory

AgentChat-IndependentTasks

Agents & models

View repository

Updated 10-15 23:44

About this skill

AgentChat-IndependentTasks: Independent Task Parallel Distribution + Solutions Manual Synthesis

⛔ Role Boundaries

You are the pipeline'sCaller, and do only three things: prepare input → call scripts → report results. It is forbidden to manually simulate any part of the pipeline (extracting questions, grouping, writing prompts, reviewing answers, compiling PDF).

Core Model

N independent tasks, M AIs of equivalent capability (at most 7: gemini/chatgpt/qwen/kimi/minimax/mimo/deepseek), pure distribution, zero collaboration.

题目 → 按主题分组 → JSON Plan → node index.js 并行派发 → 校验 → 合成 → md2pdf.sh → PDF

Three Iron Rules:

  1. All AIs use the same prompt template, only the question subset differs. Differentiated role settings are forbidden.
  2. One authoritative answer per question (best-of or fused, rewritten in a unified tone), do not display multiple versions side by side.
  3. Zero AI attribution—no provider names/badges/coverage matrices/audit reports/AI metadata may appear in the PDF.

Mandatory Execution Rules (cannot be skipped, cannot be bypassed)

  1. Must genuinely dispatch. All AI queries must pass through node ~/.claude/skills/AgentChat-IndependentTasks/index.js for actual execution; Claude Code is forbidden to answer on its own behalf.

  2. Must generate a run receipt. Generated by skills/lib/receipt.js ; a missing receipt = not executed.

  3. File modification tiers:

    • Frozen (read-only): index.js(orchestration layer),AgentChat-OneWeb/index.js(Provider layer)
    • Shared library (changes require cross-skill verification + full test suite): lib/*.js(including lib/plan.js、lib/execute.js、lib/locks.js , etc.)
    • Freely modifiable: SKILL.md、synthesize.js、validate_answers.js、md2pdf.sh
  4. Failure-tiered degradation protocol. Failure = provider timeout/bridge failure/Step 2.5 off-topic answer. Three-tier path:

    • L1 (automatic): resend once, reassign to the next available provider in the fallback chain. Foreign anchor failure (routing crosstalk) → resend serially group by group; anchor line missing/forgery detected (refusal/empty bridge return) → resend in parallel.
    • L2 (stop and wait for user): still failing after L1 → output failure report + two options (user specifies a plan then resend / authorize generating a partial PDF, with missing answers marked by > ⚠ 本题答案待补 placeholders) then STOP.
    • Absolutely forbidden: Claude Code filling in by answering itself / reporting failure in the same turn yet unauthorizedly generating a "complete" PDF.
  5. Must pass the content validation gate (machine-executed) before synthesis. After dispatch, must run validate_answers.js(validates anchor lines appear verbatim, foreign anchor detection, noise stripping). Non-zero exit code → L1. Synthesis materials use the clean/ directory, not raw stdout.

  6. User provider constraints are written into exclude, overriding the fallback chain and L1. Only not setting primary is not enough—the fallback chain will automatically route to the banned provider. Must set plan top-level "exclude": ["claude"] and also skip it during L1 resend.

  7. Each validation --out directory must be unique (with timestamp). Historical clean files left over in the old directory will cause incorrect answers to be mistakenly retrieved.

  8. semantic_check.json must be "generate → read → batch-modify verdict → write back". validate_answers.js Auto-generated, initial PENDING. Must Read → verify item by item against the original questions (no item may be skipped) → construct the complete JSON in memory → Write back to the same path in one go. Constraints:

    • Only modify the verdict and note fields; all other fields (subtask/question/restatement , etc.) are kept as-is.
    • note must be a single sentence (≤30 characters) and must state the basis for the judgment; vague "content match" is prohibited.
    • Before writing back, self-check JSON validity (quote escaping, trailing commas).
    • When the number of items ≤3, Edit may be used to modify them one by one; when >3, Write must be used for batch replacement to save tokens. Writing from scratch by hand is prohibited.md2pdf.sh If PENDING/MISMATCH is encountered, refuse to compile (exit code 5).
  9. Multi-round dispatch must merge the clean directory. Based on the last round, trace backward for each question's first PASS <id>.txt; reconcile the full set of questions → PASS; merge semantic_check.json. Entering Step 3 without merging is prohibited.

  10. M=N fully-configured deployment is prohibited (zero-fallback trap). When all available providers are dispatched as primary in the same wave,index.js 's skipList mechanism will pre-filter and remove other primaries from each worker's fallback chain—each worker is left with only [自身], and a single failure means ALL_EXHAUSTED。defenses: (a) always keep ≥1 provider without a primary as a "hot standby"; (b) or set AGENTCHAT_MAX_TABS_PER_PROVIDER=2 to enable concurrent multi-tab use of the same provider; (c) when (a)(b) cannot be satisfied, the number of L1 resend groups ≤ M−1.

  11. Attachments have already been extracted in parallel in Step 0. moodle_scraper.js 's parallel detail fetch stage has already downloaded all attachments to /tmp/agentchat_scraper_attachments/(files[].localPath). After that, proceed directly to OCR/text extraction;it is prohibitedto start a second round of Playwright connection downloads.

  12. Local context must be injected into the prompt by Claude Code. Web-based AI cannot access the local file system. Before dispatch, Claude Code must read the contents of the involved local files/code into the prompt body; passing only paths and expecting the web-based AI to read them itself is prohibited.

Step 0: Web content crawling (only when the question source is a browser page)

node ~/.claude/skills/AgentChat-OneWeb/moodle_scraper.js --detail-timeout=15000 --max-detail=15

Step 0a: Check attachments

Check the scraper output for files[].localPath existing attachments (moodle_scraper has already downloaded them to /tmp/agentchat_scraper_attachments/during the parallel detail fetch stage). Also list questionText assignments that are clear enough and directly usable.

Step 0b: Attachment OCR/text extraction (sources already downloaded in Step 0)

Attachment files are located at files[].localPath, extract text from them:

  • Images such as PNG:tesseract <localPath> <outbase> -l chi_sim+eng
  • PDF:pdftotext <localPath> -
  • When no OCR/text tool is available, in tasks_extracted.json 's question mark "题目见附件图片 [文件名]" and briefly describe the image content (e.g., "spectroscopic term list", "character table"), leaving it to the AI in Step 2 to interpret directly

Step 0.5: Local document quick extraction protocol (token-saving)

0.5.1 Read-once principle

Source documents (.docx/.pdf/.md)read only once. Single pandoc conversion → single complete read → one-shot output of the structured question list.

pandoc "source.docx" -t markdown -o /tmp/source_tasks.md

0.5.2 Structured extraction output format

After reading, Claude Code outputs in one shot /tmp/tasks_extracted.json:

{
  "source": "Response Letter.docx",
  "background": "≤100-word shared context",
  "tasks": [
    {
      "id": "R1Q1",
      "reviewer": 1,
      "question": "verbatim question text",
      "author_draft": "verbatim draft or null",
      "topic": "1-3 word slug (e.g. 'STE-size', 'solvent', 'doping')"
    }
  ],
  "meta": {
    "manuscript_id": "7669388 or null",
    "title": "paper title or null",
    "journal": "journal name or null",
    "language": "en | zh | mixed"
  }
}

question / author_draft verbatim quote of the original text.topic used for automatic grouping.background automatically condensed from the first ≤100 words of the document.

0.5.3 Automatic background extraction

From pandoc condense the first ~300 words of the output: research subject + method + key findings + journal name. ≤100 English words, shared by all groups. Template:

This [theoretical/experimental] study investigates [WHAT] in [SYSTEM]
using [METHOD]. [ONE-SENTENCE KEY FINDING].

0.5.4 Template-filled prompt generation (hand-writing prohibited)

Absolutely prohibitedto hand-write the prompt body for each group. The prompt template is built into index.js (expandSharedPlan function), template definition see references/prompt-templates.md(for reference only, not included in Claude Code context).

Recommended approach: use the plan JSON's shared + questionBank compressed format (saves ~3K tokens per run),index.js automatically expands:

{
  "exclude": ["claude"],
  "shared": {
    "background": "This theoretical study investigates...",
    "template": "dual_en"
  },
  "subtasks": [
    {
      "id": "STE-size", "primary": "gemini", "depends_on": [],
      "questions": ["R1Q1", "R2Q1"]
    }
  ],
  "questionBank": {
    "R1Q1": {
      "text": "Why the emission energy shows...",
      "author_draft": null,
      "type": "explain"
    },
    "R2Q1": {
      "text": "It should be clarified whether...",
      "author_draft": "量子点尺寸越小...",
      "type": "clarify"
    }
  }
}

index.js 's expandSharedPlan() will: take shared.template select template → fill {BG} → from questionBank build {TASKS_BLOCK}(automatically match requirements by type ) → generate the complete prompt.shared.template values:single_en | dual_en | single_zh | dual_zh。

Fallback approach: each subtask carries the complete prompt field (traditional format), in which case shared/questionBank is optional.

{TASKS_BLOCK} format:【Task {n}】[ANSWER {ID}] + original question text + author's reasoning + requirements (automatically matched by type : explain/compare/provide/clarify/literature/mixed).

0.5.5 Complete operation sequence

Step 0.5a: pandoc source.docx → /tmp/source_tasks.md
Step 0.5b: Read 一次 → 输出 /tmp/tasks_extracted.json
Step 0.5c: 自动分组 + 分配 primary(P ≤ U−1)
Step 0.5d: 生成 Plan JSON(heredoc → /tmp/agentchat_plan.json)
           推荐 shared+questionBank 压缩格式(省 ~3K token)
Step 2:   lint + dispatch(0 Claude Code tokens)

Step 1: Question grouping and AI allocation

Grouping principle: same topic → same group. Only when N > M (7) may groups be merged (reviewer replies ≤1 question/group per person preferred). Global ID (e.g. R2Q3) is locally renumbered within each group as "Task 1..k" with the [ANSWER <ID>] anchor line attached. Using the reviewer's original numbering "(2)/(3)" is prohibited.

Full-configuration constraint: P = number of deduplicated primaries in the plan, U = total number of available providers after excluding exclude.

  • P ≤ U−1 (recommended): always keep ≥1 hot-spare idle
  • P = U (high risk): zero fallback, index.js automatically enables multi-tab (AGENTCHAT_MAX_TABS_PER_PROVIDER=2)
  • AGENTCHAT_MAX_TABS_PER_PROVIDER=2: recommended to enable when G > U, values 1–4

Browser admission semaphore:AGENTCHAT_MAX_CONCURRENT_PAGES(default 3). It is the cross-process global browser automation concurrency limit; each OneWeb subprocess, before tryAllProviders() , acquires it via acquireBrowserSlot() (lib/locks.js:161)。the default value 3 is the hidden bottleneck of IndependentTasks——the first 3 workers in a wave grab browser-slot-0..2, and the remaining workers enter min(60s, 0.25×timeout) waiting (typically ~45s), and after timeout fail-open(OneWeb/index.js:1180) forcibly break in, causing: (a) degradation of the 3+burst mode——rate limiting fails; (b) waiting time is counted into the subprocess budget, shrinking the effective automation time of later workers; (c) during the wait, the provider lock is held, blocking the fallback chain.Recommended: when dispatching ≥6 workers, set AGENTCHAT_MAX_CONCURRENT_PAGES=8(values 1–16), and write it together with AGENTCHAT_MAX_TABS_PER_PROVIDER into the settings.json 's env block.

Prompt generation: use App A template (or index.js built-in expansion). Hand-writing is prohibited. Hard constraints: consistent language, length ≤400/600 words, flattened with no sub-numbering, no role-playing, embed author materials.

Step 2: JSON Plan format and dispatch

Traditional format(each group carries a complete prompt):

{
  "exclude": ["claude"],
  "subtasks": [
    {
      "id": "group_x", "primary": "gemini", "depends_on": [],
      "questions": ["P01", "P02"], "prompt": "…[ANSWER P01]…[ANSWER P02]…"
    }
  ]
}

Compressed format(recommended, saves ~3K tokens): add shared + questionBank, omit prompt(index.js expands automatically). See Step 0.5.4.

Dispatch(v25 optimization, saves ~5K tokens):

# lint
node ~/.claude/skills/AgentChat-IndependentTasks/validate_answers.js --lint /tmp/agentchat_plan.json

# dispatch(--summary-only: 终端只输出一行 JSON;--raw-out: 完整原始输出写文件)
node ~/.claude/skills/AgentChat-IndependentTasks/index.js \
  --plan=/tmp/agentchat_plan.json \
  --summary-only --raw-out=/tmp/agentchat_raw.txt

Decomposer pitfall: always use --plan=<file> + --lint, to avoid falling into the AI re-decomposition path after JSON corruption.

Step 2.5: Content validation gate (mandatory, machine-executed)

OUTDIR="/tmp/agentchat_answers_$(date +%H%M%S)"
node ~/.claude/skills/AgentChat-IndependentTasks/validate_answers.js \
  /tmp/agentchat_plan.json /tmp/agentchat_raw.txt --out="$OUTDIR"

Output:clean/<id>.txt + clean/all_clean.txt(merged file; synthesis requires only one Read) + validation_report.json + semantic_check.json。

Non-zero exit code → L1; still failing → L2. semantic_check.json: Read → revise verdict item by item (MATCH/MISMATCH) → Write back to the same path.md2pdf.sh rejects compilation on PENDING/MISMATCH.

Step 3: Synthesize a textbook-style solutions manual

Recommended approach(saves ~10K tokens): use synthesize.js to generate automatically → Claude Code only performs final review.

node ~/.claude/skills/AgentChat-IndependentTasks/synthesize.js \
  --clean="$OUTDIR/clean" \
  --meta=/tmp/tasks_extracted.json \
  --out=/tmp/solutions.md

Script automatically: strips anchor-line restatement sentences → extracts Key Result boxes → groups by reviewer → generates cover + TOC + solutions + summary table. Claude Code only needs to Read /tmp/solutions.md → fine-tune wording/fix Key Result → Write back.

Manual fallback:Read clean/all_clean.txt(once) → merge/rewrite problem by problem (unified third-person academic tone) → Key Result box at the end → Write solutions.md.

Step 4: PDF generation

export AGENTCHAT_VALIDATED_DIR=/tmp/agentchat_answers_XXXXXX
bash ~/.claude/skills/AgentChat-IndependentTasks/md2pdf.sh /tmp/solutions.md output.pdf

Markdown: YAML cover → #outline() → ## Problem N: 标题 → **Question:** → **Solution:**(LaTeX $$...$$)→ **Key Result:**(> quote blocks).

Prohibited: provider names/badges, coverage matrix, audit report, "Generated by…".

Fall back to WeasyPrint + when Typst is unavailable math_render.py。