用途:创建、运行并迭代单个 AgenticFlow AI 智能体,包含系统提示词、模型、可选 MCP 工具挂载和可选代码执行沙箱。适合一个聊天界面加一套规则的场景;若需要多个智能体互相交接(研究→写作、分诊→专家、预置团队模板),应改用 agenticflow-workforce。
主要能力:支持 welcome_message、agent_type(standard/autonomous)、recursion_limit、model_user_config、code_execution_tool_config、file_system_tool_config、attachment_config、response_format、knowledge、skills_config、task_management_config、sub_agents、plugins、suggested_messages 等字段。
使用方式:先运行 af bootstrap --json 获取 auth.project_id、auth.workspace_id、_links.workspace、models[] 和 agents[];若 data_fresh 为 false 则先运行 af doctor --json --strict。用 af schema agent --json 及 --field 查看字段结构。创建前先预览:af agent create --body @agent.json --dry-run --json,再正式创建。运行冒烟测试:af agent run --agent-id <id> --message "Test prompt" --json,可用 --thread-id 保持上下文,--wait --timeout 60 轮询,af agent stream 做 SSE 流式输出。迭代时使用 --patch 做局部更新,避免整体替换丢失已挂载工具。
限制:更新时 knowledge、recursion_limit、task_management_config、suggest_replies_*、file_system_tool_config、attachment_config、response_format、skills_config 等字段必须省略而非传 null。completed_empty 表示递归上限耗尽且响应为空,不应视为成功。模型 id 应从 bootstrap 的 models[] 读取,不要硬编码。错误信封会给出提示,如 404、422、401 对应处理建议。