安全公告 — 恶意 litellm 版本 1.82.7 与 1.82.8 已从 PyPI 移除(存在 API 密钥外泄风险)。请卸载、轮换已暴露凭据,并升级至安全版本(如 1.82.9+)。运行 pip show litellm 以确认。 PyPI · README

快速上手

用 Python 跑一个智能体,或启动 Near 连接的本机 Studio。

快速上手

两条都成立的第一次运行,选一条。它们不是同一套循环。

路径入口循环
SDKAgent + Task + AgentExecutoragenticx/core/agent_executor.py 里的经典任务执行器
Studio / Nearagx serve 再开桌面agenticx/runtime/agent_runtime.pyAgentRuntime.run_turn
示意图:两条第一次运行——AgentExecutor.run 返回 dict;Studio 推 SSE。

路径 A — 嵌进 Python

python
1from agenticx import Agent, Task, AgentExecutor
2from agenticx.llms import OpenAIProvider
3from agenticx.tools.function_tool import tool
4
5@tool(name="add", description="Add two integers.")
6def add(a: int, b: int) -> int:
7 return a + b
8
9agent = Agent(
10 name="Analyst",
11 role="Data analysis helper",
12 goal="Answer numeric questions",
13 organization_id="my-org",
14)
15task = Task(
16 id="sum-1",
17 description="What is 42 + 58?",
18 expected_output="The integer sum",
19)
20
21executor = AgentExecutor(
22 llm_provider=OpenAIProvider(model="gpt-4o"),
23 tools=[add],
24)
25result = executor.run(agent=agent, task=task)
26print(result)

环境里要有能用的供应商密钥。细节见 智能体运行时工具

路径 B — 给 Near 用的本机 Studio

bash
1agx serve --host 127.0.0.1 --port 8000

桌面端通常会自己在 127.0.0.1 上拉起,端口随机,并写入 ~/.agenticx/serve.port~/.agenticx/serve.token。若你自己起服务,Near 必须指到这个地址。

agx studio终端 REPL,不是 FastAPI 进程。见 Studio 服务

路径 C — 一次性 CLI

bash
1agx run "用两句话说明 AgenticX 是什么"

适合在开桌面之前先确认供应商配置能通。

如果没反应

  1. agx --version 失败 → 当前 PATH 里没有这个包
  2. 供应商 401 → 密钥没配或环境变量不对
  3. 桌面分身 / 历史全空 → agx serve 没在听(看 ~/.agenticx/serve.port
  4. 工具循环过早停 → 在 配置 里调大 runtime.max_tool_rounds / AGX_MAX_TOOL_ROUNDS

下一步