cendor-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cendor_sdk-1.0.0/.claude/skills/namespace-guard/SKILL.md +21 -0
- cendor_sdk-1.0.0/.gitattributes +4 -0
- cendor_sdk-1.0.0/.github/workflows/ci.yml +55 -0
- cendor_sdk-1.0.0/.github/workflows/release.yml +50 -0
- cendor_sdk-1.0.0/.gitignore +27 -0
- cendor_sdk-1.0.0/CHANGELOG.md +190 -0
- cendor_sdk-1.0.0/LICENSE +201 -0
- cendor_sdk-1.0.0/PKG-INFO +238 -0
- cendor_sdk-1.0.0/README.md +180 -0
- cendor_sdk-1.0.0/docs/eval.md +66 -0
- cendor_sdk-1.0.0/docs/hardening.md +68 -0
- cendor_sdk-1.0.0/docs/index.md +57 -0
- cendor_sdk-1.0.0/docs/interop.md +111 -0
- cendor_sdk-1.0.0/docs/multi-agent.md +108 -0
- cendor_sdk-1.0.0/docs/sdk.md +522 -0
- cendor_sdk-1.0.0/examples/README.md +20 -0
- cendor_sdk-1.0.0/examples/eval_suite.py +120 -0
- cendor_sdk-1.0.0/examples/foundry_agent.py +130 -0
- cendor_sdk-1.0.0/examples/handoff.py +71 -0
- cendor_sdk-1.0.0/examples/huggingface_agent.py +112 -0
- cendor_sdk-1.0.0/examples/mcp_agent.py +115 -0
- cendor_sdk-1.0.0/examples/single_agent.py +100 -0
- cendor_sdk-1.0.0/examples/supervisor.py +89 -0
- cendor_sdk-1.0.0/pyproject.toml +128 -0
- cendor_sdk-1.0.0/src/cendor/sdk/__init__.py +143 -0
- cendor_sdk-1.0.0/src/cendor/sdk/_governance.py +42 -0
- cendor_sdk-1.0.0/src/cendor/sdk/a2a.py +151 -0
- cendor_sdk-1.0.0/src/cendor/sdk/agent.py +94 -0
- cendor_sdk-1.0.0/src/cendor/sdk/checkpoint.py +55 -0
- cendor_sdk-1.0.0/src/cendor/sdk/embeddings.py +132 -0
- cendor_sdk-1.0.0/src/cendor/sdk/eval.py +129 -0
- cendor_sdk-1.0.0/src/cendor/sdk/foundry.py +58 -0
- cendor_sdk-1.0.0/src/cendor/sdk/hitl.py +85 -0
- cendor_sdk-1.0.0/src/cendor/sdk/mcp.py +132 -0
- cendor_sdk-1.0.0/src/cendor/sdk/memory.py +238 -0
- cendor_sdk-1.0.0/src/cendor/sdk/orchestration.py +356 -0
- cendor_sdk-1.0.0/src/cendor/sdk/otel.py +112 -0
- cendor_sdk-1.0.0/src/cendor/sdk/pricing.py +73 -0
- cendor_sdk-1.0.0/src/cendor/sdk/providers.py +1243 -0
- cendor_sdk-1.0.0/src/cendor/sdk/py.typed +0 -0
- cendor_sdk-1.0.0/src/cendor/sdk/rag.py +111 -0
- cendor_sdk-1.0.0/src/cendor/sdk/resilience.py +94 -0
- cendor_sdk-1.0.0/src/cendor/sdk/result.py +170 -0
- cendor_sdk-1.0.0/src/cendor/sdk/runner.py +735 -0
- cendor_sdk-1.0.0/src/cendor/sdk/tools.py +264 -0
- cendor_sdk-1.0.0/tests/conftest.py +110 -0
- cendor_sdk-1.0.0/tests/test_async.py +72 -0
- cendor_sdk-1.0.0/tests/test_embeddings.py +46 -0
- cendor_sdk-1.0.0/tests/test_eval.py +108 -0
- cendor_sdk-1.0.0/tests/test_governance.py +94 -0
- cendor_sdk-1.0.0/tests/test_hardening.py +177 -0
- cendor_sdk-1.0.0/tests/test_interop.py +282 -0
- cendor_sdk-1.0.0/tests/test_loop_extras.py +91 -0
- cendor_sdk-1.0.0/tests/test_mcp_prompts.py +33 -0
- cendor_sdk-1.0.0/tests/test_multi_agent_checkpoint.py +58 -0
- cendor_sdk-1.0.0/tests/test_orchestration.py +184 -0
- cendor_sdk-1.0.0/tests/test_providers.py +560 -0
- cendor_sdk-1.0.0/tests/test_rag.py +68 -0
- cendor_sdk-1.0.0/tests/test_replay.py +59 -0
- cendor_sdk-1.0.0/tests/test_session_and_namespace.py +48 -0
- cendor_sdk-1.0.0/tests/test_single_agent.py +149 -0
- cendor_sdk-1.0.0/tests/test_streaming.py +144 -0
- cendor_sdk-1.0.0/tests/test_structured_output.py +69 -0
- cendor_sdk-1.0.0/tests/test_summarizing_memory.py +68 -0
- cendor_sdk-1.0.0/tests/test_tools.py +85 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: namespace-guard
|
|
3
|
+
description: Verify the cendor PEP 420 namespace packaging is correct — there must be no src/cendor/__init__.py. Use before committing, building, or releasing, or whenever cross-package imports break.
|
|
4
|
+
---
|
|
5
|
+
# Namespace guard
|
|
6
|
+
|
|
7
|
+
`cendor-sdk` is one distribution contributing to the shared PEP 420 `cendor` namespace. It must own
|
|
8
|
+
`src/cendor/sdk/` **only** and never ship `src/cendor/__init__.py` — the #1 way multi-repo namespace
|
|
9
|
+
packages break.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Must print NOTHING:
|
|
13
|
+
find src -path '*/cendor/__init__.py' -print
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- If it prints any path → **delete that file.** A top-level `cendor/__init__.py` turns the implicit
|
|
17
|
+
namespace into a regular package and silently breaks every other `cendor.<tool>` import.
|
|
18
|
+
- `src/cendor/sdk/__init__.py` SHOULD exist — only the `src/cendor/__init__.py` *level* is forbidden.
|
|
19
|
+
- The same check runs in CI (`.github/workflows/ci.yml`).
|
|
20
|
+
|
|
21
|
+
If it passes, report "namespace-guard: OK".
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
# Cancel superseded runs for the same ref (PR pushes); never cancel a main-branch build.
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
os: [ubuntu-latest, windows-latest] # development happens on Windows — test it too
|
|
18
|
+
runs-on: ${{ matrix.os }}
|
|
19
|
+
defaults:
|
|
20
|
+
run:
|
|
21
|
+
shell: bash # Git Bash on the Windows runner, so `find`/heredocs work cross-platform
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v5
|
|
24
|
+
with:
|
|
25
|
+
repository: cendorhq/Cendor
|
|
26
|
+
path: Cendor # the dev source override in pyproject resolves ../Cendor/packages/*
|
|
27
|
+
- uses: actions/checkout@v5
|
|
28
|
+
with:
|
|
29
|
+
path: cendor-sdk
|
|
30
|
+
- uses: astral-sh/setup-uv@v3
|
|
31
|
+
- name: sync
|
|
32
|
+
working-directory: cendor-sdk
|
|
33
|
+
run: uv sync
|
|
34
|
+
- name: ruff lint
|
|
35
|
+
working-directory: cendor-sdk
|
|
36
|
+
run: uv run ruff check .
|
|
37
|
+
- name: ruff format check
|
|
38
|
+
working-directory: cendor-sdk
|
|
39
|
+
run: uv run ruff format --check .
|
|
40
|
+
- name: namespace guard (no top-level cendor/__init__.py)
|
|
41
|
+
working-directory: cendor-sdk
|
|
42
|
+
run: |
|
|
43
|
+
if find src -path '*/cendor/__init__.py' | grep . ; then
|
|
44
|
+
echo "ERROR: a top-level cendor/__init__.py exists — it breaks the PEP 420 namespace"; exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "namespace-guard: OK"
|
|
47
|
+
- name: type-check
|
|
48
|
+
working-directory: cendor-sdk
|
|
49
|
+
run: uv run mypy -p cendor.sdk
|
|
50
|
+
- name: tests
|
|
51
|
+
working-directory: cendor-sdk
|
|
52
|
+
run: uv run pytest -q
|
|
53
|
+
- name: import check
|
|
54
|
+
working-directory: cendor-sdk
|
|
55
|
+
run: uv run python -c "import cendor.sdk; print('import cendor.sdk OK', cendor.sdk.__version__)"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags:
|
|
5
|
+
- 'v*.*.*' # e.g. v1.0.0 — publishing is tag-triggered
|
|
6
|
+
|
|
7
|
+
# PyPI **trusted publishing** (OIDC) — no stored API token. Configure a trusted publisher for the
|
|
8
|
+
# `cendor-sdk` project on PyPI with:
|
|
9
|
+
# Owner: cendorhq · Repository: cendor-sdk · Workflow: release.yml · Environment: sdk
|
|
10
|
+
# The GitHub OIDC identity of this workflow authenticates the upload; the (repo, workflow, env)
|
|
11
|
+
# triple must match the publisher exactly.
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment: sdk
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write # OIDC trusted publishing
|
|
19
|
+
contents: write # checkout (read) + create the GitHub Release (write)
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v5
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
- name: Assert tag version matches pyproject version
|
|
26
|
+
run: |
|
|
27
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
28
|
+
PYPROJECT="$(grep -m1 -E '^version[[:space:]]*=' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')"
|
|
29
|
+
echo "tag=$VERSION pyproject=$PYPROJECT"
|
|
30
|
+
if [ "$VERSION" != "$PYPROJECT" ]; then
|
|
31
|
+
echo "::error::tag $GITHUB_REF_NAME says v$VERSION but pyproject.toml is $PYPROJECT — fix one and re-tag"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
- name: Build sdist + wheel
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade build
|
|
37
|
+
python -m build # backend-only (hatchling); ignores the dev [tool.uv.sources] override
|
|
38
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
39
|
+
- name: Create GitHub Release (notes from CHANGELOG)
|
|
40
|
+
env:
|
|
41
|
+
GH_TOKEN: ${{ github.token }}
|
|
42
|
+
run: |
|
|
43
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
44
|
+
awk -v hdr="## [$VERSION]" '
|
|
45
|
+
index($0, hdr)==1 {p=1; next}
|
|
46
|
+
p && index($0, "## [")==1 {exit}
|
|
47
|
+
p {print}
|
|
48
|
+
' CHANGELOG.md > /tmp/notes.md
|
|
49
|
+
[ -s /tmp/notes.md ] || echo "cendor-sdk $VERSION" > /tmp/notes.md
|
|
50
|
+
gh release create "$GITHUB_REF_NAME" --title "cendor-sdk $VERSION" --notes-file /tmp/notes.md
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
.venv/
|
|
7
|
+
.uv/
|
|
8
|
+
uv.lock
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
coverage.json
|
|
14
|
+
htmlcov/
|
|
15
|
+
.smoke/
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
.DS_Store
|
|
19
|
+
*.log
|
|
20
|
+
|
|
21
|
+
# Local scratch / audit artifacts produced by examples & tests
|
|
22
|
+
audit.jsonl
|
|
23
|
+
*.audit.jsonl
|
|
24
|
+
checkpoints/
|
|
25
|
+
|
|
26
|
+
# Planning docs — kept local, not tracked
|
|
27
|
+
plan/
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `cendor-sdk` are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [1.0.0] — 2026-07-05
|
|
8
|
+
|
|
9
|
+
First public release on PyPI — the governed agent loop, multi-agent orchestration, ecosystem
|
|
10
|
+
interop, and production hardening + governed eval, consolidated with the gap-analysis remediation,
|
|
11
|
+
retrieval (RAG), and rolling memory. Requires `cendor-core>=1.3` (Hugging Face detection).
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Tool calling on Gemini & Bedrock** (P0) — `build_kwargs` dropped assistant `tool_calls` and all
|
|
15
|
+
`tool` results, so multi-turn tool loops silently broke on those providers. Added
|
|
16
|
+
`_canonical_to_gemini` / `_canonical_to_bedrock` (functionCall/functionResponse; toolUse/toolResult),
|
|
17
|
+
mirroring the Anthropic translator, with round-trip tests.
|
|
18
|
+
|
|
19
|
+
### Added — gap-analysis remediation (see `plan/SDK_FIT_GAP_ANALYSIS.md`)
|
|
20
|
+
- **Provider param passthrough** — `Agent.extra` merges arbitrary request kwargs (`tool_choice`,
|
|
21
|
+
`reasoning_effort`, `top_p`, `stop`, `seed`, `response_format`, `extra_body`, …) into every call.
|
|
22
|
+
- **o-series temperature guard** — the OpenAI provider omits `temperature` for `o1`/`o3`/`o4` models
|
|
23
|
+
(which reject it) instead of erroring.
|
|
24
|
+
- **Robust structured output** — an `output_type` now derives a JSON Schema used via each provider's
|
|
25
|
+
native structured-output feature: OpenAI `json_schema`, Ollama `format`, Gemini `response_schema`;
|
|
26
|
+
Anthropic/Bedrock/Responses embed the schema in the JSON nudge. Dataclass / Pydantic / dict.
|
|
27
|
+
- **Streaming** — `run.stream(agent, input)` / `run.astream(...)` yield `TextDelta` / `ToolCallEvent`
|
|
28
|
+
/ `ToolResultEvent` and a terminal `RunComplete(result)`. Native reassembly for the OpenAI family +
|
|
29
|
+
Ollama (tool-call deltas included); whole-response fallback for the rest. Single-agent.
|
|
30
|
+
- **Multimodal input** — message `content` may be a parts list (`text` + `image_url`); OpenAI-family
|
|
31
|
+
passes it through, Anthropic/Gemini translate to image blocks (base64/url), Bedrock keeps the text.
|
|
32
|
+
- **Unpriced-model cost governance** — `register_model_price(model, input=…, output=…)` registers a
|
|
33
|
+
rate so cost/USD budgets bind on HF/Azure-deployment/Foundry-Local/custom ids; `configure`
|
|
34
|
+
(`on_unpriced="raise"`) re-exported.
|
|
35
|
+
- **Embeddings** — `embed(model, inputs)` / `aembed(...)` return vectors and emit a governed
|
|
36
|
+
`LLMCall` (tokens/cost/audit captured) for OpenAI-family providers — RAG calls become first-class.
|
|
37
|
+
- **RAG seam** — `VectorIndex` (a dependency-free in-memory cosine index over `embed()`) +
|
|
38
|
+
`Agent(retriever=…)`, which injects retrieved context as a system message before the call
|
|
39
|
+
("always-on" RAG). Bring your own embedder via `embedder=`, or plug a real vector DB as a
|
|
40
|
+
retriever. The SDK governs retrieval; it does not store your vectors.
|
|
41
|
+
- **Summarizing memory** — `SummarizingSession(model=… | summarizer=…, max_messages=…,
|
|
42
|
+
keep_recent=…)` folds old turns into a durable summary note when a conversation grows, keeping
|
|
43
|
+
recent turns verbatim so memory stays bounded but the gist persists (beyond `context_budget`
|
|
44
|
+
trimming). `llm_summarizer(model)` builds a governed summarizer; pass any callable for offline
|
|
45
|
+
summaries.
|
|
46
|
+
- **Multi-agent checkpointing** — `run([...], checkpoint=…)` persists the trajectory per turn/segment
|
|
47
|
+
and resumes a crashed team run.
|
|
48
|
+
- **MCP prompts** — `load_mcp_prompts(session)` + `get_mcp_prompt(session, name, args)` (renders to
|
|
49
|
+
canonical messages); `load_mcp_resources` now exported too.
|
|
50
|
+
- **Concurrent tool execution** — a turn's multiple tool calls run via `asyncio.gather` in async runs.
|
|
51
|
+
- **`max_turns` signal** — `Result.incomplete` is `True` when a run ends with no final answer.
|
|
52
|
+
- **Nested tool params** — tool schema generation expands nested dataclass / Pydantic parameters.
|
|
53
|
+
- **Richer OTel spans** — `span_tree` now records latency, finish reason, reasoning tokens, and tool
|
|
54
|
+
argument names.
|
|
55
|
+
- **Eval judge** — `EvalCase.judge` adds a pluggable semantic / LLM-judge scorer.
|
|
56
|
+
|
|
57
|
+
### Added
|
|
58
|
+
- **Hugging Face provider** (`provider="huggingface"` / `"hf"`, extra `[huggingface]`) — wraps
|
|
59
|
+
`huggingface_hub.InferenceClient.chat_completion` (OpenAI-shaped response, so request formatting
|
|
60
|
+
and normalization are reused). Token via `api_key=` or `HF_TOKEN`/`HUGGINGFACEHUB_API_TOKEN`;
|
|
61
|
+
`base_url=` targets a dedicated Inference Endpoint; `HF_PROVIDER` routes through a specific
|
|
62
|
+
inference provider. `cendor-core`'s `instrument` now detects `chat_completion` structurally and
|
|
63
|
+
attributes the `LLMCall` to `huggingface`, so budgets/guard/audit apply.
|
|
64
|
+
- **Azure AI Foundry provider** (`provider="azure"` / `"azure_openai"` / `"foundry"`, extra
|
|
65
|
+
`[azure]`) — connects to Foundry deployments via the **standard `openai` SDK** on the
|
|
66
|
+
`/openai/v1/` endpoint, per Microsoft's current guidance (the `AzureOpenAI` client and
|
|
67
|
+
`azure-ai-inference` are being retired). `model` is the Foundry **deployment name**; `base_url`
|
|
68
|
+
(or `AZURE_OPENAI_ENDPOINT`) is normalized to the v1 route; `api_key` falls back to
|
|
69
|
+
`AZURE_OPENAI_API_KEY`/`AZURE_INFERENCE_CREDENTIAL`. Entra ID via a bearer-token `api_key` or a
|
|
70
|
+
bring-your-own `client=`. See `docs/sdk.md` → *Connecting to Hugging Face & Azure AI Foundry*.
|
|
71
|
+
- **Azure Foundry Responses API** (`provider="azure_responses"` / `"foundry_responses"`) — drives
|
|
72
|
+
the OpenAI Responses API over a Foundry endpoint for OpenAI-family deployments; same Foundry-aware
|
|
73
|
+
construction as `provider="azure"` (Chat Completions).
|
|
74
|
+
- **Foundry Local provider** (`provider="foundry_local"` / `"foundry-local"`, extra
|
|
75
|
+
`[foundry-local]`) — Microsoft's on-device runtime over its local OpenAI-compatible REST server
|
|
76
|
+
(the local counterpart to Ollama). Endpoint via `base_url=` or `FOUNDRY_LOCAL_ENDPOINT` (e.g.
|
|
77
|
+
`foundry_local.FoundryLocalManager(alias).endpoint`); no key required. `model` is the resolved
|
|
78
|
+
Foundry Local model id.
|
|
79
|
+
- **Examples**: `examples/foundry_agent.py` (Azure Foundry + Foundry Local) and
|
|
80
|
+
`examples/huggingface_agent.py`, both offline.
|
|
81
|
+
|
|
82
|
+
### Consolidation & docs (Phases 1–4)
|
|
83
|
+
|
|
84
|
+
Consolidates Phases 1–4 into a stable, documented release (plan §12): the governed agent loop,
|
|
85
|
+
multi-agent orchestration, ecosystem interop, and production hardening + governed eval — complete,
|
|
86
|
+
provider-agnostic, local-first, and tested offline.
|
|
87
|
+
|
|
88
|
+
- Full docs pass: `docs/index.md` links every page and lists the public API surface; the two-door
|
|
89
|
+
framing (libraries primary, SDK secondary) is consistent across the README and docs.
|
|
90
|
+
- Marked `Development Status :: 5 - Production/Stable`.
|
|
91
|
+
- Verification: `uv run pytest` green (91 tests, no network), `ruff check`/`ruff format` clean,
|
|
92
|
+
mypy clean, namespace-guard clean, `import cendor.sdk` works.
|
|
93
|
+
|
|
94
|
+
## [0.4.0] — Phase 4: Production hardening & governed eval
|
|
95
|
+
|
|
96
|
+
The "safe for real workloads" layer plus the testing wedge fully realized.
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
- **Retries & backoff** — `RetryPolicy` retries transient model-call failures (timeouts,
|
|
100
|
+
connection errors, rate limits, 5xx) with exponential backoff; governance decisions
|
|
101
|
+
(`BudgetExceeded`/`PolicyViolation`) are never retried. `run(..., retry=RetryPolicy(...))`.
|
|
102
|
+
- **Checkpointed / resumable runs** — `run(..., checkpoint="run.ckpt.json")` persists the
|
|
103
|
+
conversation after each turn; re-running with the same checkpoint resumes without re-executing
|
|
104
|
+
completed tools. Backed by `Checkpointer` (atomic local JSON).
|
|
105
|
+
- **Durable memory** — `SQLiteSessionStore` persists many named conversations locally (no server);
|
|
106
|
+
`Session.save`/`Session.load` for JSON.
|
|
107
|
+
- **Governed eval / regression harness** — `evaluate(agent, [EvalCase(...)])` replays recorded
|
|
108
|
+
cassettes as tests and asserts output, tool sequence, and cost/token ceilings; cost/tokens are
|
|
109
|
+
real on replay. `EvalReport.assert_ok()` fails CI on a behaviour *or* spend regression.
|
|
110
|
+
- **Docs/examples**: `docs/hardening.md`, `docs/eval.md`; `examples/eval_suite.py`.
|
|
111
|
+
- **Tests** (+9): transient failure recovers, retry gives up / doesn't retry non-transient, a
|
|
112
|
+
checkpointed run resumes after a simulated crash, SQLite durable memory round-trips, and an eval
|
|
113
|
+
suite catches a cost regression + a tool-sequence change.
|
|
114
|
+
|
|
115
|
+
## [0.3.0] — Phase 3: Ecosystem & interop
|
|
116
|
+
|
|
117
|
+
Governed `cendor-sdk` agents become first-class citizens elsewhere — all optional and local-first.
|
|
118
|
+
|
|
119
|
+
### Added
|
|
120
|
+
- **MCP client** (`[mcp]` extra) — `load_mcp_tools(session)` turns an MCP server's tools into
|
|
121
|
+
governed `Tool`s (duck-typed against `mcp.ClientSession`; async, use with `run.aio`).
|
|
122
|
+
`load_mcp_resources(session)` reads resources.
|
|
123
|
+
- **A2A** — `A2AServer` serves an agent over the Agent-to-Agent protocol (JSON-RPC `message/send` +
|
|
124
|
+
agent card); `A2AClient` calls it **in-process**; `a2a.serve(...)` is an optional stdlib HTTP
|
|
125
|
+
server. Replies carry governance metadata (trace id, cost).
|
|
126
|
+
- **Foundry / Copilot** — `FoundryAdapter` publishes an agent as a Microsoft 365 / Foundry
|
|
127
|
+
custom-engine agent over the Bot Framework Activity protocol (`on_activity`, `manifest`).
|
|
128
|
+
- **OpenTelemetry span tree** (`[otel]` extra) — `span_tree(result)` emits a `gen_ai.*` span tree
|
|
129
|
+
(root `agent.run` → per-agent → per model call / tool) mirroring the correlated `Result`; a
|
|
130
|
+
no-op when OTel isn't installed.
|
|
131
|
+
- **Human-in-the-loop** — `require_approval(tool, approver=…)` gates a tool behind approval and
|
|
132
|
+
records the verdict via `decision.human_oversight(...)` on the run's audit chain; rejection blocks
|
|
133
|
+
the tool. The runner now exposes the active audit `decision` via a contextvar for this wiring.
|
|
134
|
+
- **Docs/examples**: `docs/interop.md`; `examples/mcp_agent.py`.
|
|
135
|
+
- **Tests** (+7): MCP round-trip (mocked session), A2A serve+call (in-proc), Foundry adapter, OTel
|
|
136
|
+
span-tree assertions (in-memory exporter), HITL approval + rejection recorded in a verified chain.
|
|
137
|
+
|
|
138
|
+
## [0.2.0] — Phase 2: Multi-agent orchestration
|
|
139
|
+
|
|
140
|
+
Orchestration patterns land, with the correlation that was impossible beneath frameworks: a whole
|
|
141
|
+
multi-agent trajectory is one governed, correlated tree on one verifiable audit chain.
|
|
142
|
+
|
|
143
|
+
### Added
|
|
144
|
+
- **Handoff** — an agent transfers control to a named peer via a synthetic `transfer_to_<peer>`
|
|
145
|
+
tool; the canonical conversation carries across the switch, so **handoff works across providers**.
|
|
146
|
+
- **Supervisor / router** — `supervisor(coordinator, [sub_agents], ...)`; a coordinator routes to
|
|
147
|
+
sub-agents by handoff. `run([entry, *peers], input)` is the handoff-team shortcut.
|
|
148
|
+
- **Sequential & parallel** — `sequential([...])` pipes each agent's output into the next;
|
|
149
|
+
`parallel([...])` / `parallel_async([...])` fan out over the same input (`{agent: output}`).
|
|
150
|
+
- **Nested trace correlation** — one parent `run_id`; each agent segment runs under a child trace
|
|
151
|
+
id (`{run_id}:{agent}#i`), so every `Step` carries its agent name and a `trace_id` that starts
|
|
152
|
+
with the parent — one correlated tree.
|
|
153
|
+
- **Per-agent governance** — each segment is wrapped in `track(agent=…)` (spend attribution) and,
|
|
154
|
+
when the agent sets `max_usd`, a per-agent `budget(...)`; each segment opens its own audit
|
|
155
|
+
`decision()` on a shared `AuditLog` — one verifiable chain, distinct agents distinguishable.
|
|
156
|
+
- **Session persistence** — `Session.save(path)` / `Session.load(path)` (local JSON), resumable.
|
|
157
|
+
- **Refactor** — the per-agent loop is extracted (`run_agent_sync`/`run_agent_async`) so the
|
|
158
|
+
single-agent `Runner` and the orchestrator share exactly one loop.
|
|
159
|
+
- **Docs/examples**: `docs/multi-agent.md`; `examples/handoff.py`, `examples/supervisor.py`.
|
|
160
|
+
- **Tests**: supervisor + 2 sub-agents with a correlated audit trail; per-agent budgets enforced;
|
|
161
|
+
handoff across OpenAI↔Anthropic; sequential/parallel pipelines; session persistence.
|
|
162
|
+
|
|
163
|
+
## [0.1.0] — Phase 1: Governed single agent
|
|
164
|
+
|
|
165
|
+
The wedge lands: a governed single agent runs on OpenAI **and** Anthropic, with budgets, audit,
|
|
166
|
+
redaction, and deterministic replay — provider-agnostic, local-first, no network in tests.
|
|
167
|
+
|
|
168
|
+
### Added
|
|
169
|
+
- **`Agent`** — a small, opinionated agent bound to any core-supported provider id, with tools,
|
|
170
|
+
instructions, structured output, and a bounded ReAct loop.
|
|
171
|
+
- **`tool` / `Tool`** — decorator that generates a JSON Schema from a function's type hints +
|
|
172
|
+
docstring, and formats it per provider (OpenAI functions, Anthropic tools, Gemini function
|
|
173
|
+
declarations, Bedrock toolConfig). Sync **and** async tools; every call emits a `ToolCall`.
|
|
174
|
+
- **`run` / `Runner`** — the single-agent loop, **sync (`run`) and async (`run.aio`)**: assemble →
|
|
175
|
+
format → call (inside `trace(run_id)`) → normalize → tools → repeat → finalize.
|
|
176
|
+
- **Provider response normalization** (`providers.py`) — extract assistant content + tool calls +
|
|
177
|
+
finish reason for OpenAI (Chat Completions + Responses), Anthropic, Gemini, Bedrock, and Ollama.
|
|
178
|
+
- **Structured output** — `output_type` as a dataclass or JSON-schema dict, parsed from the final
|
|
179
|
+
message.
|
|
180
|
+
- **In-memory `Session`** — conversation memory across `run()` calls.
|
|
181
|
+
- **`Result` / `Run` / `Step`** — the data model; steps are the actual bus `LLMCall`/`ToolCall`
|
|
182
|
+
records, correlated by one `trace_id`, with aggregate `usage` and Decimal `cost`.
|
|
183
|
+
- **Governance re-exports** — `budget`, `track`, `report` (tokenguard); `AuditLog`, `Policy`,
|
|
184
|
+
`guard` (acttrace, with `guard` wrapped as a context manager); all composing through core's seams
|
|
185
|
+
with zero SDK glue. An ungoverned `run()` still works on `cendor-core` alone.
|
|
186
|
+
- **Docs**: `README.md` (two doors + killer metric), `docs/index.md`, `docs/sdk.md`;
|
|
187
|
+
`examples/single_agent.py`.
|
|
188
|
+
- **Tests**: governed single-agent runs across OpenAI and Anthropic (respx-mocked, no network);
|
|
189
|
+
usage/cost/reasoning captured, budget blocks, guard redacts, audit chain `verify()`s, `trace_id`
|
|
190
|
+
correlates, and cassette replay is deterministic.
|
cendor_sdk-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Raghav Mishra (PowerAI Labs)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|