Skip to main content

reglow-agent-client(Python)

Reglow Agent 运行时薄 SDK:DTO + HTTP 客户端 + 错误映射。 不实现执行循环、不缓存状态、不自动重试非幂等请求。

适用于独立部署的 reglow-agent-service,也支持任意同契约的运行时实现。

安装

pip install reglow-agent-client

本地开发(仓库内):

cd reglow-library/reglow-agent-client/python
pip install -e ".[dev]"
pytest tests

快速开始

from reglow_agent_client import AgentClient

with AgentClient(
    "http://localhost:8000",
    tenant_id=1,            # 对应 X-Tenant-Id
    token="<platform-token>",
) as client:
    definition = client.definitions.create(
        key="cs_agent",
        name="客服 Agent",
        spec={"model_policy": {"primary": "deepseek/flash"}},
        eval_suite="eval://cs/default",
    )
    client.definitions.publish(definition.id)

    run = client.runs.create(agent_key="cs_agent", input={"q": "退款政策"})
    for event in client.runs.iter_events(run.id):
        print(event.seq, event.event_type)

能力

组 主要方法
definitions list/create/get/update/publish/versions/delete
tools list/register/update/delete
workflows list/create/get/update/delete/publish/versions/run
runs create/get/list/cancel/events/iter_events/timeline/diff/resume/compensate/replay
approvals list/approve/reject/modify
sessions create/get/list/messages/append/summarize/context/close
memory list/write/delete/purge
blackboard list/get/put/delete(乐观锁 expected_version)
knowledge search/citations
eval suites/cases/upsert_case/delete_case/run/runs/get_run/regression/gate
feedback submit/list/summary/sample_reviews/reviews/decide_review/review_summary/failure_clusters
audit list/verify(审计哈希链校验)

配置

参数 默认 说明
base_url 必填 运行时地址
tenant_id 0 写入 X-Tenant-Id
token None Authorization: Bearer
timeout 30 秒
admin_prefix /admin/api/v1/agent 管理端前缀
headers None 追加请求头
transport None httpx transport(测试可注入 MockTransport)

错误处理

from reglow_agent_client import ApiError

try:
    client.runs.cancel(1)
except ApiError as exc:
    print(exc.code, exc.http_status, exc.message, exc.payload)

智能工坊桥接

SdkStudioAgentBridge 是投影模式参考实现,宿主注入基础库注册表即可:

from reglow.modules.studio.agent_bridge import set_agent_bridge
from reglow_agent_client import AgentClient, SdkStudioAgentBridge

set_agent_bridge(SdkStudioAgentBridge(AgentClient(
    "http://localhost:8000", tenant_id=1, token=token,
)))

覆盖:工作流 get-or-create + 发布、启动运行、timeline 同步、审批/恢复/取消。

发布

当前版本:0.1.1(2026-11-24)。发布窗口、凭证与四语言顺序见 RELEASING.md。

python -m build
twine upload --repository testpypi dist/*   # 预发(可选)
twine upload dist/*                         # 正式(~/.pypirc 或 TWINE_* 凭证)

说明

  • 运行时需独立部署(或 Python 宿主 embedded 方式挂载)。
  • 事件推送需按 seq 游标轮询,SDK 不维持后台连接。
  • 版本与 contract/agent.json 对齐,升级时同步运行时与 SDK。

Metadata

Release files for reglow-agent-client 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reglow-agent-client 0.1.1
File Size Uploaded Provenance Actions
reglow_agent_client-0.1.1.tar.gz 24.0 kB Without provenance Details for reglow_agent_client-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reglow-agent-client 0.1.1
File Interpreter ABI Platform Actions
reglow_agent_client-0.1.1-py3-none-any.whl Python 3 none any Details for reglow_agent_client-0.1.1-py3-none-any.whl

Total release size: 44.3 kB

Release files / reglow_agent_client-0.1.1.tar.gz

Download URL reglow_agent_client-0.1.1.tar.gz
Size 24.0 kB
Tags Source
SHA-256 checksum
How to use checksums
655087dcfc518347218a66a39be42e8c21b1ea7203001da8336c164a3cbaef6e
BLAKE2b-256 checksum
How to use checksums
5612543d4d62fd7d155195125979835d9ab1467ea15b6da23cddaa8ad9642b1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / reglow_agent_client-0.1.1-py3-none-any.whl

Download URL reglow_agent_client-0.1.1-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ab02cb524434703e6beebf8a820be5cf67cdeb9f16975c98e04ac338587990a
BLAKE2b-256 checksum
How to use checksums
b5a364e1a3e9ed135497f498a955f7409dcde89b79cba32100d414a623798d46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for reglow-agent-client 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page