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/agent_iteratorgit 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.00674 |
| Opus 5 | $0.00000 | $0.00337 |
| Sonnet 5 | $0.00000 | $0.00135 |
| Haiku 4.5 | $0.00000 | $0.00067 |
Grade A, and why
agent_iterator 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
libs\langchain\langchain_classic\agents\agent_iterator.py
此文档提供了 libs\langchain\langchain_classic\agents\agent_iterator.py 文件的详细中文注释。该模块提供了 AgentExecutorIterator 类,允许以迭代器的方式运行代理执行器。
功能描述
AgentExecutorIterator 是对 AgentExecutor 运行逻辑的包装,它将原本黑盒式的 run 或 invoke 过程转变为可观察、可干预的迭代过程。
这对于需要实时展示代理思考过程(思考 -> 行动 -> 观察)或在步骤间插入自定义逻辑的场景非常有用。
核心类:AgentExecutorIterator
代理执行器的迭代器实现,支持同步和异步迭代。
1. 初始化参数表
| 参数 | 类型 | 描述 |
|---|---|---|
agent_executor |
AgentExecutor |
要迭代运行的代理执行器实例。 |
inputs |
Any |
传递给代理的原始输入。 |
callbacks |
Callbacks |
用于监控迭代过程的回调管理器。 |
include_run_info |
bool |
是否在产出结果中包含运行元数据。 |
yield_actions |
bool |
是否在生成动作(Action)时立即产出,而不等待工具执行结果。 |
2. 核心状态管理
intermediate_steps: 记录当前的动作-观察链条。iterations: 累计迭代步数。time_elapsed: 累计执行时长。
3. 主要方法
__next__()/__anext__(): 执行代理的下一个逻辑步。如果代理结束,则抛出StopIteration或返回最终结果。reset(): 重置迭代器状态,准备开始新的任务运行。
内部工作流程
- 初始化: 预处理输入,初始化回调环境和计时器。
- 步进逻辑 (
_iter_next_step):- 验证停止条件(最大次数/超时)。
- 调用代理的
plan方法。 - 处理
AgentAction: 如果yield_actions为真,则直接返回动作;否则执行工具并记录观察结果。 - 处理
AgentFinish: 触发结束回调并返回最终输出。
- 清理: 迭代结束后,触发
on_chain_end。
应用场景
- 实时日志展示: 在终端或 Web 端逐条流式输出代理的思考轨迹。
- 断点调试: 允许开发者在代理执行特定工具前进行人工干预。
- 自定义限制: 在迭代过程中根据动态条件(如预算、资源消耗)随时中断代理运行。
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 · 53 lines · 0 tokens per session scan A 9934367b1226
agent_iterator 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 674 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
milestone-planner
Use when you say "break this epic into milestones", "plan this roadmap item", or hand it a roadmap epic. Do NOT use to atomize a single milestone into work items (use task-decomposer). High-rigor planning assistant who translates roadmap epics into implementation-ready work packages with clear milestones…
deployment-specialist
部署操作领域的专家.
alert-analyzer
分析系统健康状态和告警.
incident-commander
管理事件响应流程.
API-documenter
创建全面的 API 文档.
code-commentator
改进代码文档质量.