Skip to content

feat: 添加代码交付 Agent 和 Agent 互调用功能#32

Merged
69gg merged 8 commits intomainfrom
feature/code-writing
Feb 15, 2026
Merged

feat: 添加代码交付 Agent 和 Agent 互调用功能#32
69gg merged 8 commits intomainfrom
feature/code-writing

Conversation

@69gg
Copy link
Owner

@69gg 69gg commented Feb 15, 2026

功能概述

本 PR 新增了代码交付 Agent 和 Agent 互调用机制,显著增强了机器人的代码编写能力和 Agent 协作能力。

主要改动

1. 新增 code_delivery_agent(代码交付助手)

  • 功能定位:在隔离的 Docker 容器环境中编写、修改、调试代码并打包交付
  • 核心工作流
    • 理解需求 → 规划方案(todo)→ 编写代码(write)
    • 验证测试(run_bash_command)→ 检查结果(read/glob/grep)
    • 补全文档 → 交付打包(end)
  • 内置工具(10 个):
    • 文件操作:read, write, copy, delete, glob, grep, tree
    • 代码分析:diff
    • 任务管理:todo, end
    • 命令执行:run_bash_command
    • 时间工具:get_current_time
  • 环境特性
    • 基于 Ubuntu 24.04 Docker 容器
    • 工作目录限制在 /workspace
    • 全程联网,支持 apt/pip/npm 等包管理器
  • MCP 集成:支持 Context7 MCP 用于文档查询

2. Agent 互调用功能

  • 配置方式:在 Agent 目录下添加 callable.json 文件
  • 访问控制:支持白名单机制,可指定允许调用的 Agent
  • 自动注册:系统自动扫描并注册可调用的 Agent
  • 工具命名:自动生成 call_{agent_name} 格式的工具名
  • 已启用互调用的 Agent
    • info_agent:可被所有 Agent 调用
    • web_agent:可被所有 Agent 调用
  • 文档:新增 docs/agent-calling.md 详细说明使用方法

3. 提示词和配置优化

  • 系统提示词改进(undefined.xml / undefined_nagaagent.xml):
    • 添加"让 AI 总是相信自己"的指导
    • 添加增量审计规则,防止相同任务多次触发
    • 优化 end 检查提示,更友好的用户体验
  • 配置示例更新config.toml.example 新增相关配置项
  • 配置加载器增强config/loader.py 支持更多配置选项

4. 其他改进

  • todo 工具串行化:防止并发调用导致的数据覆盖问题
  • OneBot 客户端增强:新增更多 API 支持
  • 文档更新:README.md 和 CLAUDE.md 更新相关说明

技术细节

Agent 互调用实现

  • 核心逻辑在 skills/agents/agent_tool_registry.py
  • 通过 callable.json 控制访问权限
  • 自动生成工具描述和参数定义
  • 支持嵌套调用和递归保护

code_delivery_agent 架构

  • 使用 skills/agents/runner.py 统一执行入口
  • 所有工具异步实现,支持高并发
  • 文件操作使用 utils/io.py 确保原子性
  • 命令执行支持超时和错误处理

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41a21a80c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 206 to 208
result = await ai_client.agent_registry.execute_agent(
target_agent_name, args, context
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate and retag context before calling another agent

This call forwards the original context directly into execute_agent, so nested agent calls run with the caller’s agent_name/state instead of the callee’s. In an A→B→C chain, C will still see agent_name=A, which can incorrectly allow/deny allowed_callers checks and leak/mutate caller-scoped fields (for example agent_history and runtime keys) across agents. Create a copied callee context and set callee identity before dispatch.

Useful? React with 👍 / 👎.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect configured default archive format

The end tool hardcodes zip when archive_format is omitted, but code_delivery_default_archive_format is parsed and documented as configurable. If operators set the default to tar.gz, deliveries will still be zipped unless the model explicitly passes archive_format, so runtime behavior diverges from configuration and can break downstream expectations.

Useful? React with 👍 / 👎.

Comment on lines 40 to 41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use path-aware boundary checks for workspace writes

The workspace guard uses string startswith, which is bypassed by sibling paths sharing the same prefix (for example ../workspace_backup/... resolves outside the workspace but still passes). That breaks the tool’s /workspace confinement guarantee and allows writes outside the intended root. Use Path.is_relative_to (or equivalent parent checks) on resolved paths.

Useful? React with 👍 / 👎.

@69gg 69gg merged commit f48f30b into main Feb 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments