并行任务执行工具

Agent Farm v3.4 是一个AI驱动的并行任务执行工具,支持通过分块写入模式生成大型文档和代码文件。

  • by BossX429
  • Python
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 BossX429/agent-farm

使用说明

Agent Farm v3.4-分块编写版

人工智能生物进化和使用工具代理的并行任务执行。 现在有了 分块书写模式 用于生成大型文档和代码文件!

v3.4中的新增功能

  • 分块书写模式:Bug并行编写部分,Python直接组装
  • 分块写入:生成大的标记/文本文档(大小不限)
  • chunked_code_gen:并行生成多功能代码文件
  • 分块分析:多角度综合分析
  • 绕过500个字符的限制:每个bug写入小块,组合输出不受限制

演出

  • 速度提高8.6倍 比v3.0(4任务群为103s->12s)
  • 1次迭代 每项任务(3-5)
  • 100%成功率 使用真实的工具数据
  • 局部合成 -qwen2.5:14b合成结果(没有云标记!)

模型

角色 型号 VRAM 用途
侦察 qwen3:4b 2.5GB 侦察
Worker qwen3:4b 2.5GB 任务执行
内存 qwen3:4b 2.5GB 上下文保留
Guardian qwen3:4b 2.5GB 系统监控
学习者 qwen3:4b 2.5GB 模式获取
合成器 问题2.5:14b 8.99GB 结果综合

MCP工具(30)

群体管理

  • spawn_colony -创建bug群体(标准/快速/重型/混合型)
  • list_colonies -列出活动殖民地
  • colony_status -详细的殖民地信息
  • quick_colony -快速健康检查
  • dissolve_colony -删除殖民地
  • cleanup_idle -删除闲置殖民地
  • farm_stats -综合统计

Swarm部署

  • deploy_swarm -将任务部署到殖民地
  • quick_swarm -一键生成+部署

专用Swarms

  • code_review_swarm -4视角代码审查
  • code_gen_swarm -生成代码+测试+文档
  • file_swarm -并行文件操作
  • exec_swarm -并行shell命令
  • api_swarm -并行HTTP请求
  • kmkb_swarm -多角度知识查询

工具启用代理

  • tool_swarm -使用真实的系统工具部署bug
  • system_health_swarm -快速系统健康检查
  • recon_swarm -目录/代码库侦察
  • deep_analysis_swarm -深度磁盘/文件分析
  • worker_task -配备齐全工具的单人工人

直接操作

  • heavy_write -直接文件写入(对于大内容绕过LLM)
  • synthesize -独立合成任何JSON结果

分块写入模式(新)

  • chunked_write -通过并行分段编写生成大型文档
  • chunked_code_gen -使用并行编写的函数生成代码文件
  • chunked_analysis -多视角综合分析

Bug工具权限

角色 工具
Scout read_file、list_dir、file_exists、system_status、process_list、disk_usage、check_service、exec_cmd
Worker read_file、write_file、list_dir、exec_cmd、http_get、http_post、system_status、disk_usage、check_service
内存 read_file、kmkb_search、kmkb_ask、list_dir、system_status、process_list、disk_usage、check_service、exec_cmd
Guardian system_status、process_list、disk_usage、check_service、read_file、list_dir、exec_cmd
学习者 read_file、analyze_code、list_dir、kmkb_search、system_status、process_list、disk_usage、check_service、exec_cmd

结构化输出详细信息

Agent Farm v3.3使用Ollama的结构化输出功能在模型响应上强制执行JSON模式:

# Bug responds with guaranteed-valid JSON:
{"tool": "system_status", "arg": ""}
{"tool": "exec_cmd", "arg": "df -h"}
{"tool": "check_service", "arg": "ollama"}

约束解码(GBNF语法)在生成过程中屏蔽了无效令牌,确保:

  • 始终有效的JSON
  • 正确的工具名称
  • 正确的论证结构
  • 无解析失败

结果现在包括a mode 字段显示使用了哪种方法:

  • structured -JSON模式已强制执行
  • structured+autoformat -JSON+简单的结果格式化
  • structured+deep -具有多步骤推理的JSON
  • regex -回退正则表达式解析
  • regex+autoformat -正则表达式+简单的结果格式化

分块书写模式

分块写入模式通过分解大型任务解决了小型模型的~500个字符输出限制:

1. PLANNER BUG (qwen2.5:14b)
   |-- Creates structured JSON outline
   |-- {"sections": [{"title": "...", "description": "..."}]}

2. WORKER BUGS (qwen3:4b) - IN PARALLEL
   |-- Each writes one section (~300-500 chars)
   |-- 4 workers = 4 sections simultaneously

3. PYTHON CONCATENATION (NO LLM)
   |-- header + separator.join(sections)
   |-- Zero token cost, instant assembly

4. DIRECT FILE WRITE (NO LLM)
   |-- tool_write_file() saves result
   |-- Bypasses any output corruption

演出

工具 输出大小 部分 时间
分块写入 9.6 KB 5 78秒
chunked_code_gen 1.9 KB 4个函数 88秒
分块分析 不同 4个视角 ~60s

为什么它有效

  • 小型模型擅长专注、短输出
  • 每个部分都在“安全区”内(<500个字符)
  • Python处理程序集(无LLM令牌成本)
  • 通过ThreadPoolExecutor并行执行
  • 结构化输出确保可靠的规划

用法示例

系统健康检查

agent-farm:system_health_swarm

自定义任务群

agent-farm:tool_swarm
  colony_type: "heavy"
  tasks: [
    {"prompt": "Check CPU temperature"},
    {"prompt": "List top 5 memory processes"},
    {"prompt": "Check if docker is running"}
  ]

大文件写入(直接)

agent-farm:heavy_write
  path: "/tmp/large_output.txt"
  content: "... large content ..."

代码库侦察

agent-farm:recon_swarm
  target_path: "/home/kyle/repos/my-project"

生成大文档(分块)

agent-farm:chunked_write
  output_path: "/tmp/security_guide.md"
  spec: "Linux server security hardening guide"
  num_sections: 5
  doc_type: "markdown"

输出:9KB+文档,包含5个连贯的部分

生成代码文件(分块)

agent-farm:chunked_code_gen
  output_path: "/tmp/utils.py"
  spec: "File utilities: read, write, copy, delete"
  language: "python"
  num_functions: 4

输出:包含4个函数的完整Python模块

多视角分析

agent-farm:chunked_analysis
  target: "/home/kyle/repos/project"
  question: "What are the architectural patterns?"
  num_perspectives: 4

输出:从结构、模式、质量、性能角度进行分析

安装

cd ~/repos/agent-farm
uv venv
uv pip install -e .

Claude桌面配置

{
  "mcpServers": {
    "agent-farm": {
      "command": "/home/kyle/repos/agent-farm/.venv/bin/python",
      "args": ["-m", "agent_farm.server"]
    }
  }
}

更新日志

v3.4.0版本(2026年1月23日)

  • 分块书写模式 -Bug并行编写部分,Python组装
  • 分块写入 -生成无限大小的文档(测试:78秒内9.6KB)
  • chunked_code_gen -并行生成多功能代码文件
  • 分块分析 -多视角综合分析
  • 通过任务分解绕过500个字符的bug限制
  • Planner使用结构化JSON输出实现可靠的轮廓

v3.3.0版本(2026年1月23日)

  • Olama结构化输出 -通过约束解码实现JSON模式强制
  • 可靠的工具解析 -不再有正则表达式失败
  • 模式跟踪 -结果显示使用的解析方法
  • 正则表达式回退 -遗留解析仍然可用作备份
  • 对于复杂的shell查询,所有角色都会获得exec_cmd

v3.2.0版本(2026年1月22日)

  • 合成器角色 -qwen2.5:14b用于精确的结果合成
  • 综合参数 -添加到工具_温暖、系统_健康_温暖、识别_温暖、深度_分析_温暖
  • 综合工具 -独立合成任何JSON结果
  • 不再征收克劳德合成税 -bug在本地完成所有工作

v3.1.0(2026-01-20)

  • 速度提高8.6倍(103秒->12秒)
  • 自动格式化结果跳过冗余的LLM调用
  • 立即拒绝无效工具
  • 回答前强制使用工具
  • 修复了复杂shell命令支持
  • 所有角色至少升级到qwen3:4b

v3.0.0(2026-01-19)

  • 从Windows版本重建Linux
  • 具有角色权限的启用工具的代理
  • 系统健康、侦察、工人群体
  • 通过ThreadPoolExecutor实现真正的并行