feat: add python_agent driver for Agno, LangGraph and plain-function agents - #1
Merged
Merged
Conversation
json_object 输出模式只保证输出是合法 JSON,不约束结构;现在和 prompt_json 一样附上结构 Schema。
模型返回合法 JSON 但外壳不是 {result, state_updates} 时,按校验反馈纠正一次,不再直接让
CaseRun 以 provider_exhausted 失败;网络等请求错误仍然立即失败。
…agents 新增 python_agent Driver 与只依赖标准库的 agentrig.sdk harness:用被测项目自己的解释器启动 harness,Agno Agent/Team 在 tool_hooks 链最内层、LangGraph 在 ToolNode 的 wrap_tool_call 链最内层接管工具,普通函数用 @agentrig.sdk.tool 标记。被测环境无需安装 AgentRig,支持 Python 3.10+;被测进程只继承基础环境变量,AgentRig 自身的 Secret 不会进入被测代码。 同时: - subprocess Driver 持续排空 stderr,单行上限 8 MiB,非 JSON 行返回错误事件,观察结果只留摘要; - DriverPrepareContext 增加 tool_mode,执行器与「对话验证」都会传入; - python_agent 支持 conversation_initial_state,对话验证可以向 Curator 描述业务世界; - 新增 Python Agent 接入指南,同步架构、实现、部署文档与中英文 README; - CI 增加 SDK 框架适配任务,在最新 Agno、LangGraph 与 Python 3.10 上验证 harness。
…6-63349 运行时依赖审计报告 anyio 4.14.1 存在三个已知漏洞,4.14.2 起修复;锁文件升级到 4.15.1, 其余依赖不变。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why / 动机
测试一个现有的 Agno 或 LangGraph Agent,原来必须先把它改造成一个实现
/chat/stream协议、把工具执行交给 AgentRig 的服务,这是接入时最大的门槛。这个 PR 让现有 Python Agent 不改代码即可接受 AgentRig 驱动。What changed / 改动
python_agentDriver 与只依赖标准库的agentrig.sdkharness:python -m agentrig.sdk.harness,通过PYTHONPATH提供 SDK 副本,被测环境无需安装 AgentRig,支持 Python 3.10+;tool_hooks链最内层接管用户声明的工具,Team 递归覆盖成员,委派等框架内置工具照常执行;create_agent、create_react_agent、手写 StateGraph):在每个 ToolNode 的wrap_tool_call链最内层接管,用户 middleware 照常运行;@agentrig.sdk.tool标记工具;credential_env或inherit_env显式传入。DriverPrepareContext增加tool_mode,执行器与「对话验证」都会传入。python_agent支持conversation_initial_state,「对话验证」可以向 Curator 描述业务世界。json_object模式附上结构 Schema;外壳不合法时按反馈纠正一次(独立提交)。sdk-frameworks任务:安装frameworks依赖组(Agno、LangChain、LangGraph,仅用于测试,不作为 extra 发布),并提供 Python 3.10 解释器。Boundaries and risk / 边界与风险
agentrig test(将另起 RFC)、真实工具结果录制、GitHub Action。ainvoke;工具循环跨多次 run 的 Agent 需要在入口里复刻服务逻辑(指南 §1.2 给出写法)。DriverPrepareContext.tool_mode为可选字段;subprocess Driver 遇到非 JSON 行时由抛异常改为返回错误事件。python_agent的解释器必须精确列入subprocess_allowlist;被测进程拿不到 AgentRig 自身的 Secret。python_agent意味着每 30 秒启动一次被测进程,计划改为手动触发或缓存结果。Verification / 验证
uv run ruff check src tests scripts examplesuv run mypy src/agentriguv run pytest:224 passed,5 skipped(跳过项是需要外部服务的 live 测试与 PostgreSQL 测试)tests/sdk31 条:运行时语义、标准库边界与 3.10 语法、Driver 协议、stdout/stderr 噪声、observe 模式、环境隔离、Agno Agent/Team 与 LangGraph 适配、Curator 兜底、对话转用例、A/B 纵切web/未改动Evidence / 证据
真实 Agent A/B 的发布门禁输出(节选):