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/xt765/langchain-chinese-comment/xmlgit clone --depth 1 https://github.com/xt765/LangChain-Chinese-CommentWhat 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.00571 |
| Opus 5 | $0.00000 | $0.00285 |
| Sonnet 5 | $0.00000 | $0.00114 |
| Haiku 4.5 | $0.00000 | $0.00057 |
Grade A, and why
xml 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.
What it actually says
XML Agent
XMLAgent 是一种使用 XML 标签(如 <tool>、<tool_input>)来结构化其思考和行动过程的代理。这种格式特别适合那些对 XML 结构化数据处理较好的模型(如 Anthropic 的 Claude 系列)。
核心工作流
- Prompt: 指示模型使用 XML 标签来调用工具。
- Execution: 模型生成类似
<tool>search</tool><tool_input>weather</tool_input>的内容。 - Parsing:
XMLAgentOutputParser提取标签内容并转换为AgentAction。 - Observation: 工具结果被包装在
<observation>标签中反馈给模型。
核心实现 (Verbatim Snippet)
1. 计划逻辑 (plan)
XML Agent 手动拼接中间步骤的 XML 字符串,而不是依赖通用的 Scratchpad 格式化函数。
def plan(
self,
intermediate_steps: list[tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> AgentAction | AgentFinish:
log = ""
for action, observation in intermediate_steps:
# 手动构建 XML 历史记录
log += (
f"<tool>{action.tool}</tool><tool_input>{action.tool_input}"
f"</tool_input><observation>{observation}</observation>"
)
inputs = {
"intermediate_steps": log,
"tools": tools,
"question": kwargs["input"],
"stop": ["</tool_input>", "</final_answer>"],
}
response = self.llm_chain(inputs, callbacks=callbacks)
return response[self.llm_chain.output_key]
迁移指南 (Migration)
现代 LangChain 推荐使用 create_xml_agent 工厂函数,或者直接使用原生支持 Tool Calling 的模型。
现代 XML Agent 创建
from langchain.agents import create_xml_agent
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model="claude-3-opus-20240229")
agent = create_xml_agent(model, tools, prompt)
为什么迁移?
- LCEL 支持:
create_xml_agent返回的是一个Runnable对象,可以轻松与其他组件集成。 - 异步支持: 现代实现对异步
aplan有更好的原生支持。 - 鲁棒性: 新的
XMLAgentOutputParser在处理不完整的 XML 或格式微调方面更加健壮。
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 · 57 lines · 0 tokens per session scan A b0852dcb4968
xml is an agent published in the GitHub repository xt765/LangChain-Chinese-Comment (20 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 571 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
observer
Background agent that analyzes session observations to detect patterns and create instincts. Uses Haiku for cost-efficiency.
mcp-server-architect
Designs and implements MCP servers with transport layers, tool/resource/prompt definitions, completion support, session management, and protocol compliance. Specializes in FastMCP 2.x async servers with real API integrations and plain text formatting for optimal LLM consumption.
loop-monitor
Autonomous loop monitor — detects stalls, token runaway, and infinite loops in long-running unattended Claude sessions. Use alongside a watchdog process when running autonomous pipelines.
claude-code-guide
Expert on the Claude Code Ultimate Guide. Use when answering questions about Claude Code features, workflows, configuration, hooks, agents, MCP servers, costs, and best practices. Searches the guide before answering. Cites file + line sources.
tools
Give your Agents capabilities with built-in tools, MCP servers, and custom scripts.
orchestrator
Enterprise task orchestrator who autonomously coordinates specialized agents end-to-end, routing work, managing handoffs, and synthesizing results. Classifies complexity, triages delegation, and sequences workflows. Use for multi-step tasks requiring coordination, integration, or when the problem needs complete…