feat: 添加swarms团队编排功能并优化agent委派系统
- 引入AgentTeamOrchestrator支持多agent协同任务执行 - 增加第三方swarms库依赖并配置git协议替换以改善包管理 - 扩展DelegationManager支持团队任务调度和进度跟踪 - 实现中文bigram分词算法提升中文任务检索准确性 - 调整A2AClient和DelegationManager超时时间从30秒增至600秒 - 优化AgentRunResult状态判断逻辑增加有意义摘要检测 - 修改Dockerfile配置npm仓库镜像地址和git协议映射 - 更新CLI命令行接口支持网关端口配置传递 - 调整提供者超时配置机制增强请求稳定性 - 移除过时的support_group字段简化agent描述符结构 - 增强错误处理和进度事件报告机制改进用户体验
This commit is contained in:
@ -42,7 +42,7 @@ from nanobot.cron.runtime import run_cron_job
|
||||
from nanobot.cron.service import CronService
|
||||
from nanobot.cron.types import CronExecutionResult, CronJob, CronSchedule
|
||||
from nanobot.providers.registry import PROVIDERS
|
||||
from nanobot.session.manager import SessionManager
|
||||
from nanobot.session.manager import Session, SessionManager
|
||||
from nanobot.utils.helpers import get_cron_store_path, parse_session_key
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -281,23 +281,6 @@ def _slugify_agent_id(*values: Any) -> str:
|
||||
return "a2a-agent"
|
||||
|
||||
|
||||
def _card_supports_group(card: dict[str, Any]) -> bool:
|
||||
if "support_group" in card:
|
||||
return bool(card.get("support_group"))
|
||||
capabilities = card.get("capabilities")
|
||||
if not isinstance(capabilities, dict):
|
||||
return True
|
||||
group = capabilities.get("group")
|
||||
if isinstance(group, dict):
|
||||
for key in ("enabled", "supported"):
|
||||
if key in group:
|
||||
return bool(group.get(key))
|
||||
return True
|
||||
if group is None:
|
||||
return True
|
||||
return bool(group)
|
||||
|
||||
|
||||
async def _discover_agent_payload(
|
||||
req: AddAgentRequest,
|
||||
config: Config,
|
||||
@ -377,7 +360,6 @@ async def _discover_agent_payload(
|
||||
"tags": _dedupe_texts(req.tags, card.get("tags")),
|
||||
"aliases": _dedupe_texts(req.aliases, card.get("aliases")),
|
||||
"capabilities": card.get("capabilities") if isinstance(card.get("capabilities"), dict) else {},
|
||||
"support_group": _card_supports_group(card),
|
||||
"support_streaming": client._supports_streaming(card),
|
||||
"metadata": dict(req.metadata or {}),
|
||||
}
|
||||
@ -652,6 +634,7 @@ def create_app(
|
||||
mcp_servers=config.tools.mcp_servers,
|
||||
authz_config=config.authz,
|
||||
backend_identity=config.backend_identity,
|
||||
gateway_port=config.gateway.port,
|
||||
)
|
||||
|
||||
async def _handle_direct_delegation_announcement(
|
||||
@ -767,13 +750,17 @@ def _make_provider(config: Config):
|
||||
p = config.get_provider(model)
|
||||
|
||||
if provider_name == "openai_codex" or model.startswith("openai-codex/"):
|
||||
return OpenAICodexProvider(default_model=model)
|
||||
return OpenAICodexProvider(
|
||||
default_model=model,
|
||||
request_timeout_seconds=p.request_timeout_seconds if p else 600,
|
||||
)
|
||||
|
||||
if provider_name == "custom":
|
||||
return CustomProvider(
|
||||
api_key=p.api_key if p else "no-key",
|
||||
api_base=config.get_api_base(model) or "http://localhost:8000/v1",
|
||||
default_model=model,
|
||||
request_timeout_seconds=p.request_timeout_seconds if p else 600,
|
||||
)
|
||||
|
||||
if not (p and p.api_key) and not model.startswith("bedrock/"):
|
||||
@ -785,6 +772,7 @@ def _make_provider(config: Config):
|
||||
default_model=model,
|
||||
extra_headers=p.extra_headers if p else None,
|
||||
provider_name=provider_name,
|
||||
request_timeout_seconds=p.request_timeout_seconds if p else 600,
|
||||
)
|
||||
|
||||
|
||||
@ -1174,6 +1162,7 @@ def _register_routes(app: FastAPI) -> None:
|
||||
allow_local_delegation=allow_local,
|
||||
allow_plugin_delegation=allow_local,
|
||||
include_plugin_agents=allow_local,
|
||||
gateway_port=config.gateway.port,
|
||||
)
|
||||
try:
|
||||
return await loop.process_direct(
|
||||
|
||||
Reference in New Issue
Block a user