ctxt 知识检索
ctxt-knowledge-retrieval
训练并提示 AI 智能体使用 ctxt 进行确定性知识检索,具备语义回退、来源溯源(provenance tracking)和可复用记忆捕获能力。适用于构建基于 ctxt 的智能体循环、调试检索质量不佳的问题,或跨智能体和会话共享洞察、试错结果与决策。
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- ctxt-knowledge-retrieval
- description
- Train and prompt AI agents to use ctxt for deterministic knowledge retrieval with semantic fallback, provenance tracking, and reusable memory capture. Use when building agent loops over ctxt, debugging weak retrieval quality, or sharing insights, trial-and-error outcomes, and decisions across agents and sessions.
02 资源文件 24
- 其他.gitignore723 B
- 参考文档agents/openai.yaml264 B
- 参考文档AUTHENTICATION.md7.3 KB
- 参考文档catalog.json543 B
- 参考文档CHANGELOG.md1.7 KB
- 资产文件images/example_notebookchat.png134.3 KB
- 许可证LICENSE1.0 KB
- 参考文档README.md17.5 KB
- 参考文档references/api_reference.md8.9 KB
- 参考文档references/ctxt-memory-taxonomy.md1.5 KB
- 参考文档references/troubleshooting.md4.4 KB
- 参考文档references/usage_patterns.md11.3 KB
- 参考文档requirements.txt279 B
- 脚本scripts/__init__.py2.6 KB
- 脚本scripts/ask_question.py8.4 KB
- 脚本scripts/auth_manager.py11.8 KB
- 脚本scripts/browser_session.py9.1 KB
- 脚本scripts/browser_utils.py3.5 KB
- 脚本scripts/cleanup_manager.py10.0 KB
- 脚本scripts/config.py3.6 KB
- 脚本scripts/input_safety.py4.4 KB
- 脚本scripts/notebook_manager.py15.8 KB
- 脚本scripts/run.py3.4 KB
- 脚本scripts/setup_environment.py6.9 KB
03 SKILL.md 正文
ctxt Knowledge Retrieval
Objective
Use ctxt as an agent memory and retrieval substrate with reproducible queries, explicit provenance, and continuous write-back of learned experience.
Canonical Sources
Use these docs as source of truth before changing agent behavior:
docs/manual/personas/agents-llms.mddocs/manual/workflows/search-retrieval.mddocs/manual/workflows/ingestion-capture.mddocs/manual/workflows/composition-reporting.mddocs/manual/reference/query-language-and-ranking.mddocs/manual/reference/api-cli-reference.md
Runtime Preconditions
Start the runtime and verify readiness:
dpkms serve
ctxt version
curl http://127.0.0.1:8080/health
Agent Retrieval Contract
Run this loop in order for reliable retrieval:
- Ingest (
ctxt analyze). - Poll jobs to completion (
ctxt job status/ctxt job list). - Retrieve with deterministic filters first (
ctxt list,ctxt list --q). - Use semantic search only as fallback (
ctxt find). - Inspect top objects (
ctxt open) before composing. - Compose outputs (
ctxt make ...) and keep source IDs. - Write back new memory from task outcomes.
Command Playbook
Ingest
ctxt analyze "Investigate checkout funnel anomalies" --type text --hints "#checkout #funnel"
ctxt analyze https://example.com/incident-postmortem --type url
ctxt job list --limit 20
ctxt job status <job_id>
ctxt job retry <job_id>
Deterministic retrieval first
ctxt list --type url --after 2026-02-01 --limit 20
ctxt list --q "type==url;tag=in=(checkout,pricing)" --limit 20
ctxt list --mention @project.checkout-redesign --after 2026-02-01 --limit 20
Semantic fallback second
ctxt find "recent checkout architecture decisions" --limit 10
Inspect and compose
ctxt open <object_id> --output json
ctxt make brief --tag checkout,funnel --since 2026-02-01 --output-file agent-brief.md
ctxt make plan --mention @project.checkout-redesign --since 2026-02-01 --output-file agent-plan.md
Shared Memory Contract (Insights + Trial-and-Error)
After each meaningful task, persist one memory object that captures what worked, what failed, and why.
Use this template:
Memory Record
Task: <what was attempted>
Context: <system/user constraints>
Hypothesis: <expected outcome>
Actions Tried: <ordered attempts>
Observed Result: <actual outcome>
Failure Mode: <error/why it failed, or "none">
Fix or Decision: <what changed>
Confidence: <low|medium|high>
Source Object IDs: <id1,id2,...>
Next Reuse Hint: <when another agent should reuse this>
Write it back:
ctxt analyze --type text --hints "#insight #trial #error #decision #lesson" --mentions "@agent.codex @team.platform" "Memory Record
Task: Improve checkout conversion query quality
Context: release-week, high auditability requirement
Hypothesis: deterministic filters outperform broad semantic search
Actions Tried: 1) ctxt find broad query 2) ctxt list --q with tag/date constraints
Observed Result: deterministic query returned stable top results
Failure Mode: semantic-only query produced irrelevant matches
Fix or Decision: adopt deterministic-first retrieval policy
Confidence: high
Source Object IDs: obj_123,obj_456
Next Reuse Hint: reuse for incident reports and recurring summaries"
Retrieve shared memory later:
ctxt list --q "type==text;tag=in=(insight,trial,error,decision,lesson)" --after 2026-02-01 --limit 50
ctxt find "lessons learned from failed retrieval attempts" --limit 10
ctxt make brief --tag insight,trial,error,decision --since 2026-02-01 --output-file agent-memory-brief.md
Quality Gates
Treat retrieval as acceptable only when all checks pass:
- Deterministic query is reproducible across repeated runs.
- Top results map to the intended tags/mentions/time window.
- Composition output can be traced to source object IDs.
- At least one reusable memory record is written for future agents.
Failure Handling
- Empty deterministic result: remove one filter at a time, confirm objects exist with simpler
ctxt list. - Ingestion/composition race: never compose before jobs reach
completed. - Ambiguous semantic matches: reduce limit and add structured filters.
- Runtime/story drift: follow current CLI/API docs first; treat story contracts as forward-looking.
Resources
Use references/ctxt-memory-taxonomy.md for standard tags, mention conventions, and query presets for cross-agent memory sharing.
04 同仓库更多 Skills
模拟分词步骤
tokenizer-step
模拟步骤(Mock step)。
模拟提取步骤
my-extractor
模拟步骤(Mock step)。
pii-mask
Masks email addresses and phone numbers in captured text
ctxt 知识上下文管理
ctxt
使用 ctxt CLI —— 一个智能体上下文大脑,基于 dPKMS(去中心化个人知识底座) 进行内容捕获、搜索与编排。 自动适用于:任务涉及通过 ctxt CLI 捕获内容、搜索知识、 编排简报/计划,或管理焦点配置文件。 适用于:将内容捕获到知识库、运行语义搜索、生成 编排内容、管理配置/配置文件,或操作 dPKMS 后台工作进程。 描述清单: - [x] 功能:面向人类和 AI 智能体的上下文即服务 CLI - [x] 自动激活时机:任何 ctxt/dpkms CLI 操作 - [x] 关键功能面:捕获、搜索、编排、配置、注册表、实体 - [x] 本地优先、支持离线、可脚本化