Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/demondamon/agenticx/query_optimizer_agent_plangit clone --depth 1 https://github.com/DemonDamon/AgenticXWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01480 |
| Opus 5 | $0.00000 | $0.00740 |
| Sonnet 5 | $0.00000 | $0.00296 |
| Haiku 4.5 | $0.00000 | $0.00148 |
Grade A, and why
query_optimizer_agent_plan scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Query Optimizer Agent 建设规划
1. 简介
Query Optimizer Agent 是一个专门用于在 RAG (Retrieval-Augmented Generation) 流程中优化用户查询的智能体。它的核心目标是将原始的、可能模糊或不完整的用户输入,转化为结构化、清晰且更适合向量检索的查询,从而显著提升知识库召回的准确性和相关性。
2. Agent 目标与职责
- 提升检索准确性: 通过查询重写、扩展和分解,生成高质量的检索指令。
- 增强语义理解: 理解用户真实意图,处理复杂的、多跳的或隐含的查询。
- 动态适应: 根据查询的不确定性和上下文,决定是否以及如何触发检索。
- 结构化转换: 在需要时将自然语言查询转换为结构化查询语言(如 SQL, Cypher)。
- 反馈优化: 利用初步检索结果迭代式地优化查询。
3. 架构设计
Query Optimizer Agent 将作为 AgenticX 框架中的一个核心组件,嵌入在用户查询和知识库检索之间。
graph TD
A[用户原始查询] --> B(Query Optimizer Agent);
B --> C{优化策略选择};
C -->|查询重写| D1[Query Rewriting Tool];
C -->|查询扩展| D2[Query Expansion Tool];
C -->|查询分解| D3[Query Decomposition Tool];
C -->|结构化转换| D4[Structured Query Tool];
D1 --> E(优化后的查询);
D2 --> E;
D3 --> E;
D4 --> E;
E --> F[知识库检索模块];
F --> G[LLM 生成答案];
4. 核心能力与工具 (Tools)
为了实现上述目标,Query Optimizer Agent 将配备一系列专用工具,这些工具将作为 agenticx.tools 的一部分被实现。
4.1. query_rewriting_tool
- 功能: 修正和重构查询。
- 子功能:
contextual_rewrite: 结合对话历史,将 "它怎么样了?" 这样的模糊问题重写为 "XX产品2024年的定价方案"。hyde_generate: (Hypothetical Document Embeddings) - 根据原始查询生成一个假设性的答案文档,并使用该文档的向量进行检索。fix_spelling_grammar: 自动进行拼写和语法纠正。
4.2. query_expansion_tool
- 功能: 扩展查询的语义边界,提高召回率。
- 子功能:
expand_with_synonyms: 利用词向量或同义词词典(如 WordNet)为查询增加同义词或近义词。generate_multiple_queries: 使用 LLM 从单一问题生成多个不同角度的相关问题,进行多路检索。add_term_weights: 识别并增加查询中关键术语的权重。
4.3. query_decomposition_tool
- 功能: 将复杂问题分解为多个可独立检索的原子查询。
- 子功能:
decompose_multi_hop_question: 将 "为什么健康饮食后仍感觉疲劳?是否应尝试生酮饮食?" 分解为多个子问题。route_sub_queries: (未来规划) 将不同的子查询路由到最合适的数据源(例如,一个子查询发往向量数据库,另一个发往 SQL 数据库)。
4.4. adaptive_retrieval_tool
- 功能: 智能判断何时需要触发外部知识检索。
- 子功能:
check_uncertainty: 当 Agent 对内部知识的回答置信度较低时,触发此工具进行外部检索。analyze_semantic_importance: 识别查询中需要通过检索来补充信息的关键部分。
4.5. structured_query_tool
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 100 lines · 0 tokens per session scan A fa32dcd0f5e0
query_optimizer_agent_plan is an agent published in the GitHub repository DemonDamon/AgenticX (219 stars, last pushed 2d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,480 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
ai-output-code-review-super-auditor
Agent "ai-output-code-review-super-auditor" from alfredolopez80/multi-agent-ralph-loop, covering the vision, your work, step by step, ultrathink principles in practice, 0. role & mission and 1. scope of work.
prompt-optimizer
Agente que transforma prompts ordinarios en prompts profesionales para IA usando arquitectura en 5 capas.
gap-analyst
Analyzes feature requests for missing requirements, edge cases, and ambiguities BEFORE implementation. Prevents rework by finding gaps early.
senior-frontend-developer
Agent "senior-frontend-developer" from alfredolopez80/multi-agent-ralph-loop, covering the vision, your work, step by step, ultrathink principles in practice, role & persona and operating mode.
autoresearch
Autonomous researcher - iteratively modifies code, runs experiments, evaluates metrics, keeps improvements. Never stops unless budget exhausted or manually interrupted.
plan-sync
Synchronizes downstream plan steps after implementation drift. Spawned by orchestrator after each step completes to patch stale references.