kag
Routes KAG knowledge-construction, question-answering, MCP, and benchmark workflows for the OpenSPG KAG package.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- kag
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Routes KAG knowledge-construction, question-answering, MCP, and benchmark workflows for the OpenSPG KAG package.
- disable-model-invocation
- true
02 资源文件 7
- 参考文档references/cli-reference.md3.4 KB
- 参考文档references/configuration-and-registry.md2.6 KB
- 参考文档references/repo-provenance.md1.3 KB
- 参考文档references/repo-routing-metadata.json482 B
- 参考文档references/troubleshooting.md4.5 KB
- 脚本scripts/check_kag_install.py7.7 KB
- 脚本scripts/inspect_kag_config.py5.7 KB
03 SKILL.md 正文
KAG
Use this repo skill for the OpenSPG KAG package when the user wants to create, inspect, or use a KAG project, not when they want a generic graph database or generic RAG answer.
What this skill covers
KAG is a Python toolkit for knowledge augmented generation with three major surfaces:
- project and schema setup through
knext - knowledge construction through builder chains and index managers
- query-time reasoning, MCP serving, and benchmark automation
If the task is about a KAG checkout that may be stale, read references/repo-provenance.md first.
First checks
- Confirm the package is installed with
scripts/check_kag_install.py. - Inspect any
kag_config.yamlwithscripts/inspect_kag_config.py. - Read
references/configuration-and-registry.mdwhen you need config keys, registry names, or config discovery rules. - Read
references/troubleshooting.mdwhen imports, config discovery, model keys, or CLI behavior look wrong.
Choose the right sub-skill
sub-skills/knowledge-construction/
Use this when the user wants to create or restore a project, commit schema, run a builder, choose readers/splitters/extractors/vectorizers/writers, inspect index managers, or validate a project layout before building.
sub-skills/question-answering/
Use this when the user wants to ask questions against a KAG project, inspect solver pipelines, use knext reasoner or knext thinker, or debug query-time retrieval and answer generation.
sub-skills/mcp-and-automation/
Use this when the user wants to launch or validate kag mcp-server, plan MCP tool configs, submit builder jobs to a cluster, or dry-run benchmark automation.
Shared files
references/cli-reference.md— CLI groups, flags, and when to use each command.references/configuration-and-registry.md— config discovery, registries, and dynamic component loading.references/troubleshooting.md— cross-cutting import, config, and runtime failures.scripts/check_kag_install.py— safe install/import/CLI smoke check from any working directory.scripts/inspect_kag_config.py— redacted summary of a KAG config file.
Runtime expectations
- The published distribution name is
openspg-kag. - The import names used by future agents are
kagandknext. - Console entry points are provided by the same distribution.
import kagmay need a discoverablekag_config.yaml; the bundled install check creates a temporary minimal config so the import can be tested from any directory.- Keep runtime instructions self-contained. Do not refer future agents to original repo docs or examples outside this skill tree.
Common requests
- "Help me set up a KAG project"
- "Which KAG index should I use for this corpus?"
- "Why is my KAG answer missing references?"
- "Can I launch KAG as an MCP server or benchmark runner?"
Working style
- Start with a safe local check before a live server or graph mutation.
- Prefer bundled config and layout helpers over guessing from source tree names.
- Route the task to a sub-skill as soon as the workflow becomes specific.
- Keep provenance in mind before reusing the skill on a different checkout.
- Treat knowledge construction, query answering, and service automation as separate concerns until the user asks to connect them.
When to stop and read more
- If a request mentions project creation, schema commits, builder chains, or index selection, go to
knowledge-construction. - If a request mentions solver pipelines, GQL queries, answer traces, or
knext reasoner, go toquestion-answering. - If a request mentions
mcp-server, builder submission, or benchmark planning, go tomcp-and-automation.
Provenance
Read references/repo-provenance.md before refreshing this skill or before deciding whether the current checkout still matches the generated knowledge.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).