Python SDK for Show Holdings AgentOps monitoring
Project description
showholdings-agentmon
showholdings-agentmon 是 Show Holdings AgentOps 的 Python SDK。
它讓你可以在自己的 Python 程式中,用最小改動接入 run-level 與 step-level monitoring。
安裝
pip install showholdings-agentmon
最小使用範例
from showholdings_agentmon import Monitor
monitor = Monitor(
api_key="YOUR_API_KEY",
base_url="https://agentops.showholdings.com",
project_name="my-agent",
)
with monitor.run(agent_name="general-agent", session_id="session-123"):
result = run_my_agent()
auto_instrumentation v1(預設啟用)
在 v1 中,Monitor(...) 初始化後就會在 monitor.run(...) 期間自動補抓常見 steps,
你不需要額外呼叫 auto_instrument() 或新增 setup code。
目前預設自動補抓:
- OpenAI / Anthropic / Gemini 模型呼叫(
llm_call) - 模型層 tool use 事件(
tool_call) - 外部 HTTP(S) 呼叫(
http_call,requests / httpx) - 常見 DB 查詢(
db_query,SQLite / SQLAlchemy 第一版) - exception / timeout(自動標記 failed 並保留錯誤訊息)
- fallback step(
執行中):即使你只寫monitor.run(...),也會有基本 step 動態可視化
fallback step 行為:
- 若整個 run 都沒有任何 step(手動或 auto-detected),SDK 會補一個粗粒度
執行中step(processing) - 若 run 內已有手動 step 或 auto-detected step,SDK 不會再插入 fallback step
- run 失敗且沒有任何 step 時,fallback step 會以 failed 結束並帶錯誤訊息
說明:v1 是 deterministic runtime instrumentation,不包含 AI assist setup 或 function-level 自動建議插樁。
標準版(含步驟監測)
from showholdings_agentmon import Monitor
monitor = Monitor(
api_key="YOUR_API_KEY",
base_url="https://agentops.showholdings.com",
project_name="my-agent"
)
with monitor.run(agent_name="填入你的 agent 名稱", session_id="填入你自訂的 session 編號"):
# 記錄步驟 1
with monitor.step("填入步驟 1 的名稱", step_type="例如:資料處理 / 模型呼叫 / 輸出結果"):
result_1 = code_of_step_1()
# 記錄步驟 2
with monitor.step("填入步驟 2 的名稱", step_type="例如:資料處理 / 模型呼叫 / 輸出結果"):
result_2 = code_of_step_2()
SDK 行為說明
- 進入
with monitor.run(...)時,自動呼叫POST /api/sdk/runs/start - 離開 context 時,自動呼叫
POST /api/sdk/runs/end - 進入
with monitor.step(...)時,自動呼叫POST /api/sdk/steps/start - 離開 step context 時,自動呼叫
POST /api/sdk/steps/end - auto-detected steps 也會走同一組
steps/start/steps/endAPI - 成功結束會送出
status=success - 區塊內拋出例外會送出
status=failed,並附帶:failure_reason_type(例外類別名稱)error_count=1
- step 區塊內拋出例外會送出
status=failed與error_message - SDK 對監控 API 採 best effort;監控 API 失敗不會中斷你的主要業務流程
本地開發
pip install -e .[dev]
pytest
python -m build
發布概要
本專案已提供 GitHub Actions:
ci.yml:在 push / pull_request 執行測試publish.yml:以 PyPI Trusted Publishing 為目標的正式發布流程
你可先用 TestPyPI 驗證流程,再切換到正式 PyPI 發布。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file showholdings_agentmon-0.3.2.tar.gz.
File metadata
- Download URL: showholdings_agentmon-0.3.2.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ed0435a475daf0bdd818d55f6156e8deac0c2623332f13705eed9cd53eb7e02
|
|
| MD5 |
1c5fface412d259ce0a4ce56f099e19d
|
|
| BLAKE2b-256 |
c16083e342d965522372885f3a1fd15633d62861120f8e1897d4a3c8342969a1
|
Provenance
The following attestation bundles were made for showholdings_agentmon-0.3.2.tar.gz:
Publisher:
publish.yml on andy07s97/showholdings-agentmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
showholdings_agentmon-0.3.2.tar.gz -
Subject digest:
3ed0435a475daf0bdd818d55f6156e8deac0c2623332f13705eed9cd53eb7e02 - Sigstore transparency entry: 1283526326
- Sigstore integration time:
-
Permalink:
andy07s97/showholdings-agentmon@4f1579558ebc5074cc8417b8dc59ddf706ffad51 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/andy07s97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f1579558ebc5074cc8417b8dc59ddf706ffad51 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file showholdings_agentmon-0.3.2-py3-none-any.whl.
File metadata
- Download URL: showholdings_agentmon-0.3.2-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a7e22daa23963b8f03061f7fffe1f182ccee8756a5eb2977d1518e08346d3c
|
|
| MD5 |
47d7de1be3d5a8256dbe993d7254da81
|
|
| BLAKE2b-256 |
84b5055af8ca8ab3172e14b470e5c05bf315740924eec39c458e60f818e32305
|
Provenance
The following attestation bundles were made for showholdings_agentmon-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on andy07s97/showholdings-agentmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
showholdings_agentmon-0.3.2-py3-none-any.whl -
Subject digest:
31a7e22daa23963b8f03061f7fffe1f182ccee8756a5eb2977d1518e08346d3c - Sigstore transparency entry: 1283526396
- Sigstore integration time:
-
Permalink:
andy07s97/showholdings-agentmon@4f1579558ebc5074cc8417b8dc59ddf706ffad51 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/andy07s97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f1579558ebc5074cc8417b8dc59ddf706ffad51 -
Trigger Event:
workflow_dispatch
-
Statement type: