agenttrafficcop 2.1.0__tar.gz → 2.3.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.
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/CHANGELOG.md +33 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/PKG-INFO +116 -13
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/QUICKSTARTS.md +1 -1
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/README.md +115 -12
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/RUNTIME_FEATURES.md +14 -4
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/__init__.py +1 -1
- agenttrafficcop-2.3.0/agenttrafficcop/cli.py +749 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/client.py +100 -6
- agenttrafficcop-2.3.0/agenttrafficcop/langgraph.py +316 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop.egg-info/PKG-INFO +116 -13
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop.egg-info/SOURCES.txt +3 -0
- agenttrafficcop-2.3.0/agenttrafficcop.egg-info/entry_points.txt +2 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/pyproject.toml +4 -1
- agenttrafficcop-2.1.0/agenttrafficcop/langgraph.py +0 -159
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/FEATURES.md +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/LICENSE +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/MANIFEST.in +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/accounting.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/autogen.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/embeddings.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/exceptions.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/frameworks.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/local.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/models.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/normalization.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/openai_gateway.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/outage.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/py.typed +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/recipes.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/recovery.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/replay.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/runtime.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/security.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/semantic.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop/tracing.py +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop.egg-info/dependency_links.txt +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop.egg-info/requires.txt +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/agenttrafficcop.egg-info/top_level.txt +0 -0
- {agenttrafficcop-2.1.0 → agenttrafficcop-2.3.0}/setup.cfg +0 -0
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## 2.3.0
|
|
2
|
+
|
|
3
|
+
- Add a gateway setup wizard (`atc gateway init`) that fetches priced models,
|
|
4
|
+
writes a secret-safe environment template, and protects existing files unless
|
|
5
|
+
`--force` is specified.
|
|
6
|
+
- Add `atc gateway models` and an explicitly confirmed `atc gateway test`; the
|
|
7
|
+
live test sets a per-run budget first, limits output tokens, and prints only
|
|
8
|
+
safe error identifiers. A live provider request can still incur charges.
|
|
9
|
+
- Add automatic, cached gateway pricing refresh from the public LiteLLM model
|
|
10
|
+
catalog, with last-known-good fallback and exact `ATC_PROXY_MODEL_PRICES_JSON`
|
|
11
|
+
operator overrides. Rates remain estimates, not provider invoices or hard caps.
|
|
12
|
+
- Add optional per-run cumulative gateway token ceilings and warning thresholds.
|
|
13
|
+
Reservations include an input-token provider count where available or a
|
|
14
|
+
conservative byte-based estimate plus maximum output; actual provider-reported
|
|
15
|
+
usage and one-time threshold events appear in run history/dashboard. In-flight
|
|
16
|
+
calls and non-gateway use are not blocked by this estimate-based control.
|
|
17
|
+
- Add `atc init`/`atc doctor`, Anthropic model-aware input-token preflight with
|
|
18
|
+
labeled estimate fallback, and the LangGraph checkpointed-review adapter.
|
|
19
|
+
- Include the setup documentation and examples for the above release features.
|
|
20
|
+
|
|
21
|
+
## 2.2.0
|
|
22
|
+
|
|
23
|
+
- Publish the SDK LangGraph checkpointed-review adapter with a built-in,
|
|
24
|
+
read-only verifier for owner-scoped ATC approval status. Resume input must
|
|
25
|
+
carry the exact review ID; the action is rechecked by ATC immediately before
|
|
26
|
+
execution and the one-action grant is consumed by the server.
|
|
27
|
+
- Add a LangGraph-native first-run and deployment walkthrough with a supported
|
|
28
|
+
versioned container image and Helm defaults.
|
|
29
|
+
|
|
30
|
+
## Unreleased
|
|
31
|
+
|
|
32
|
+
- No unreleased changes.
|
|
33
|
+
|
|
1
34
|
## 2.1.0
|
|
2
35
|
|
|
3
36
|
- Add optional OpenAI SDK helpers that route BYOK Chat Completions through the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agenttrafficcop
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Python SDK for AgentTrafficCop — local and hosted deterministic checks for agent workflows.
|
|
5
5
|
Author: AgentTrafficCop
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,13 +82,55 @@ change. Unknown-cost exceptions retain holds; they are never settled as zero.
|
|
|
82
82
|
Python **3.11+**:
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
python -m pip install --upgrade 'agenttrafficcop==2.
|
|
85
|
+
python -m pip install --upgrade 'agenttrafficcop==2.3.0'
|
|
86
86
|
python -c "from importlib.metadata import version; print(version('agenttrafficcop'))"
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Base dependency: `httpx>=0.27.0,<0.30.0`. Use a virtual environment; optional
|
|
90
90
|
framework extras have their own requirements.
|
|
91
91
|
|
|
92
|
+
## CLI setup and deployment checks
|
|
93
|
+
|
|
94
|
+
`atc init` interactively generates a small hosted Guard example, an environment
|
|
95
|
+
variable template, and setup notes. Choose `python` or `langgraph`; no secret is
|
|
96
|
+
requested or written. Review the generated files and inject `ATC_API_KEY` from
|
|
97
|
+
your secret manager/environment before running them:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
atc init
|
|
101
|
+
# Or generate without prompts:
|
|
102
|
+
atc init --framework python --url https://your-atc-host --output ./atc-example
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Generated files are not overwritten unless you explicitly pass `--force`.
|
|
106
|
+
|
|
107
|
+
For the optional provider gateway, `atc gateway init` fetches currently priced
|
|
108
|
+
models and generates a secret-safe `.env.example` plus run instructions. It does
|
|
109
|
+
not fetch or write your provider key. After loading `ATC_API_KEY` and the chosen
|
|
110
|
+
provider key from a secret manager or local environment, `atc gateway test`
|
|
111
|
+
asks before making one small real provider request; `atc gateway models` lists
|
|
112
|
+
available model rates. The test sets a per-run USD budget, a 512-token ceiling
|
|
113
|
+
and 400-token warning threshold before sending (override with `--token-limit`,
|
|
114
|
+
`--token-alert-at`, or the generated env vars), and limits output tokens. Provider
|
|
115
|
+
billing and final token usage can still exceed admission estimates. OpenAI BYOK
|
|
116
|
+
keys are sent only with the HTTPS request; Groq/Anthropic keys are stored in the
|
|
117
|
+
ATC encrypted credential vault for that ATC API key before the live test (remove
|
|
118
|
+
with `DELETE /v1/provider-credentials/{provider}` when no longer needed):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
atc gateway init
|
|
122
|
+
# Review the generated files, then load secrets into your environment.
|
|
123
|
+
atc gateway models --provider openai
|
|
124
|
+
atc gateway test # asks for confirmation; a real provider request may cost money
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
For Kubernetes installs, `atc doctor` checks the ATC namespace/deployment,
|
|
128
|
+
service/endpoints, health URL, and expected agent egress policy shape. Add
|
|
129
|
+
`--probe-egress` to create a temporary probe pod that tests ATC reachability and
|
|
130
|
+
whether public TCP egress is blocked; this needs pod create/exec/delete access,
|
|
131
|
+
an image pull, and a NetworkPolicy-enforcing CNI. A passing policy-shape check
|
|
132
|
+
alone does not prove runtime enforcement.
|
|
133
|
+
|
|
92
134
|
## Route OpenAI calls through ATC with BYOK
|
|
93
135
|
|
|
94
136
|
Install the optional OpenAI integration:
|
|
@@ -121,8 +163,9 @@ with openai_gateway_client(
|
|
|
121
163
|
For async applications, create the client with `async_openai_gateway_client`
|
|
122
164
|
and use the returned client in `async with`. Set `provider="groq"` to route compatible OpenAI SDK calls to
|
|
123
165
|
the fixed Groq gateway route. The gateway currently supports text-only,
|
|
124
|
-
non-streaming Chat Completions for
|
|
125
|
-
|
|
166
|
+
non-streaming Chat Completions for supported priced models and requires an
|
|
167
|
+
eligible run budget on ATC. Its public price catalog refreshes while in use;
|
|
168
|
+
operator-provided prices can override it. No prompts or completions are
|
|
126
169
|
added to trace telemetry.
|
|
127
170
|
|
|
128
171
|
The adapter adds one operation ID to each `create` call before handing it to
|
|
@@ -580,8 +623,11 @@ raw-mode checks still transmit payloads for validation and hashing.
|
|
|
580
623
|
## Reported spending and run budgets — Pro/Team
|
|
581
624
|
|
|
582
625
|
```python
|
|
583
|
-
budget = await guard.set_run_budget(
|
|
584
|
-
|
|
626
|
+
budget = await guard.set_run_budget(
|
|
627
|
+
session_id=run_id, budget_usd="2.00",
|
|
628
|
+
token_limit=100_000, token_alert_at=80_000,
|
|
629
|
+
)
|
|
630
|
+
# GuardSync accepts the same keyword options.
|
|
585
631
|
```
|
|
586
632
|
|
|
587
633
|
Setting a budget does not connect provider billing. An authorized backend must
|
|
@@ -590,9 +636,14 @@ requests. Use matching key/session attribution and stable unique event IDs;
|
|
|
590
636
|
never report cumulative run totals or duplicate spending across integrations.
|
|
591
637
|
|
|
592
638
|
Run budgets are **API key + session** scoped. Rolling thresholds cover a key's
|
|
593
|
-
reported costs over 60 seconds.
|
|
594
|
-
|
|
595
|
-
|
|
639
|
+
reported costs over 60 seconds. Optional `token_limit` and `token_alert_at`
|
|
640
|
+
settings apply to actual provider-reported gateway token use for that run. Alert
|
|
641
|
+
crossings are retained in run budget history and shown in the dashboard; new
|
|
642
|
+
gateway reservations are rejected if their input estimate plus maximum output
|
|
643
|
+
would exceed the remaining ceiling. Updating budgets preserves spending; a new
|
|
644
|
+
run needs a new session ID. Byte-based input estimates are not exact token counts,
|
|
645
|
+
already in-flight requests can finish, and direct calls outside the gateway are
|
|
646
|
+
not covered. These are not provider-side hard caps.
|
|
596
647
|
|
|
597
648
|
## Shared spending reservations — Pro/Team
|
|
598
649
|
|
|
@@ -671,8 +722,10 @@ sync/async helper. No PyPI version change is required for the HTTP endpoint.
|
|
|
671
722
|
|
|
672
723
|
### LangGraph
|
|
673
724
|
|
|
725
|
+
Install the versioned SDK and the optional LangGraph extra:
|
|
726
|
+
|
|
674
727
|
```bash
|
|
675
|
-
python -m pip install 'agenttrafficcop[langgraph]==2.
|
|
728
|
+
python -m pip install 'agenttrafficcop[langgraph]==2.3.0'
|
|
676
729
|
```
|
|
677
730
|
|
|
678
731
|
```python
|
|
@@ -688,13 +741,63 @@ graph.add_node("reviewer", guarded_node(
|
|
|
688
741
|
```
|
|
689
742
|
|
|
690
743
|
Only wrapped nodes are protected. Keep exceptions propagating so failed checks
|
|
691
|
-
stop execution.
|
|
692
|
-
|
|
744
|
+
stop execution. To pause a circuit-breaker trip for a dashboard review, compile
|
|
745
|
+
with a **durable LangGraph checkpointer** (for example, a production
|
|
746
|
+
database-backed saver) and enable the built-in ATC verifier:
|
|
747
|
+
|
|
748
|
+
```python
|
|
749
|
+
builder.add_node("reviewer", guarded_node(
|
|
750
|
+
reviewer_fn, guard=guard, sender="coder", recipient="reviewer",
|
|
751
|
+
session_id=lambda state: state["run_id"],
|
|
752
|
+
payload=lambda state: {"draft": state["draft"]},
|
|
753
|
+
review_on_trip=True,
|
|
754
|
+
))
|
|
755
|
+
# durable_saver is your database-backed LangGraph checkpointer.
|
|
756
|
+
graph = builder.compile(checkpointer=durable_saver)
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
When paused, show `__interrupt__[0].value` to the authorized operator and use
|
|
760
|
+
the dashboard's run-review flow to approve/reject the exact action. Resume with
|
|
761
|
+
`Command(resume={"review_id": event["review_id"]})`; the resume payload itself
|
|
762
|
+
is never authorization. The SDK asks ATC to validate the grant against the
|
|
763
|
+
current detector state and exact action, then rechecks policy and consumes the
|
|
764
|
+
one-action approval before the node runs. The
|
|
765
|
+
status API is read-only; only an authenticated dashboard owner can decide a
|
|
766
|
+
review. A custom `review_approval` callback is optional and must fail closed.
|
|
767
|
+
|
|
768
|
+
For a complete live-service walkthrough, install the SQLite checkpointer extra
|
|
769
|
+
and run the safe no-op example. It pauses after repeated identical requests;
|
|
770
|
+
approve that exact review in the dashboard before pressing Enter. No model
|
|
771
|
+
provider or external tool is called:
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
python -m pip install 'agenttrafficcop[langgraph]==2.3.0' 'langgraph-checkpoint-sqlite>=3.1.3,<3.2.0'
|
|
775
|
+
export ATC_URL='https://api.agenttrafficcop.com'
|
|
776
|
+
export ATC_API_KEY='your-server-issued-key'
|
|
777
|
+
python examples/langgraph_native_review.py
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
The example persists LangGraph checkpoints to `atc-langgraph-checkpoints.sqlite`.
|
|
781
|
+
Keep that file and reuse the printed run ID plus `--resume-review-id` after a
|
|
782
|
+
process restart. For an offline walkthrough, run
|
|
783
|
+
`python -I examples/langgraph_checkpointed_review.py` from the repository; it
|
|
784
|
+
uses fake ATC/review services and an in-memory saver, so it is not a production
|
|
785
|
+
configuration.
|
|
786
|
+
|
|
787
|
+
A trip creates a checkpoint with only a generic review event, session ID,
|
|
788
|
+
opaque review ID and safe detector error code—never state, prompts, results or
|
|
789
|
+
exception text. On resume the verifier must approve that exact unchanged action;
|
|
790
|
+
only then does the node perform a fresh ATC check immediately before running. A
|
|
791
|
+
resume value by itself is never approval. Do not use an in-memory saver for
|
|
792
|
+
restart durability.
|
|
793
|
+
Approval does not bypass ATC spend/quota/policy controls. Adapters do not
|
|
794
|
+
automatically enable normalization, hash-only, shadow mode or spending
|
|
795
|
+
reservations. Use direct checks for unexposed options.
|
|
693
796
|
|
|
694
797
|
### Legacy AutoGen
|
|
695
798
|
|
|
696
799
|
```bash
|
|
697
|
-
python -m pip install 'agenttrafficcop[autogen]==2.
|
|
800
|
+
python -m pip install 'agenttrafficcop[autogen]==2.3.0'
|
|
698
801
|
```
|
|
699
802
|
|
|
700
803
|
This legacy adapter supports only `pyautogen==0.2.35`, not AgentChat or AG2.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Short integration recipes — SDK 2.1
|
|
2
2
|
|
|
3
3
|
Install the SDK and the optional OpenAI adapter with
|
|
4
|
-
`python -m pip install 'agenttrafficcop[openai]==2.
|
|
4
|
+
`python -m pip install 'agenttrafficcop[openai]==2.3.0'`. For editable
|
|
5
5
|
development, clone this repository and run
|
|
6
6
|
`python -m pip install -e './sdk[openai]'`
|
|
7
7
|
from its root.
|
|
@@ -33,13 +33,55 @@ change. Unknown-cost exceptions retain holds; they are never settled as zero.
|
|
|
33
33
|
Python **3.11+**:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
python -m pip install --upgrade 'agenttrafficcop==2.
|
|
36
|
+
python -m pip install --upgrade 'agenttrafficcop==2.3.0'
|
|
37
37
|
python -c "from importlib.metadata import version; print(version('agenttrafficcop'))"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
Base dependency: `httpx>=0.27.0,<0.30.0`. Use a virtual environment; optional
|
|
41
41
|
framework extras have their own requirements.
|
|
42
42
|
|
|
43
|
+
## CLI setup and deployment checks
|
|
44
|
+
|
|
45
|
+
`atc init` interactively generates a small hosted Guard example, an environment
|
|
46
|
+
variable template, and setup notes. Choose `python` or `langgraph`; no secret is
|
|
47
|
+
requested or written. Review the generated files and inject `ATC_API_KEY` from
|
|
48
|
+
your secret manager/environment before running them:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
atc init
|
|
52
|
+
# Or generate without prompts:
|
|
53
|
+
atc init --framework python --url https://your-atc-host --output ./atc-example
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Generated files are not overwritten unless you explicitly pass `--force`.
|
|
57
|
+
|
|
58
|
+
For the optional provider gateway, `atc gateway init` fetches currently priced
|
|
59
|
+
models and generates a secret-safe `.env.example` plus run instructions. It does
|
|
60
|
+
not fetch or write your provider key. After loading `ATC_API_KEY` and the chosen
|
|
61
|
+
provider key from a secret manager or local environment, `atc gateway test`
|
|
62
|
+
asks before making one small real provider request; `atc gateway models` lists
|
|
63
|
+
available model rates. The test sets a per-run USD budget, a 512-token ceiling
|
|
64
|
+
and 400-token warning threshold before sending (override with `--token-limit`,
|
|
65
|
+
`--token-alert-at`, or the generated env vars), and limits output tokens. Provider
|
|
66
|
+
billing and final token usage can still exceed admission estimates. OpenAI BYOK
|
|
67
|
+
keys are sent only with the HTTPS request; Groq/Anthropic keys are stored in the
|
|
68
|
+
ATC encrypted credential vault for that ATC API key before the live test (remove
|
|
69
|
+
with `DELETE /v1/provider-credentials/{provider}` when no longer needed):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
atc gateway init
|
|
73
|
+
# Review the generated files, then load secrets into your environment.
|
|
74
|
+
atc gateway models --provider openai
|
|
75
|
+
atc gateway test # asks for confirmation; a real provider request may cost money
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For Kubernetes installs, `atc doctor` checks the ATC namespace/deployment,
|
|
79
|
+
service/endpoints, health URL, and expected agent egress policy shape. Add
|
|
80
|
+
`--probe-egress` to create a temporary probe pod that tests ATC reachability and
|
|
81
|
+
whether public TCP egress is blocked; this needs pod create/exec/delete access,
|
|
82
|
+
an image pull, and a NetworkPolicy-enforcing CNI. A passing policy-shape check
|
|
83
|
+
alone does not prove runtime enforcement.
|
|
84
|
+
|
|
43
85
|
## Route OpenAI calls through ATC with BYOK
|
|
44
86
|
|
|
45
87
|
Install the optional OpenAI integration:
|
|
@@ -72,8 +114,9 @@ with openai_gateway_client(
|
|
|
72
114
|
For async applications, create the client with `async_openai_gateway_client`
|
|
73
115
|
and use the returned client in `async with`. Set `provider="groq"` to route compatible OpenAI SDK calls to
|
|
74
116
|
the fixed Groq gateway route. The gateway currently supports text-only,
|
|
75
|
-
non-streaming Chat Completions for
|
|
76
|
-
|
|
117
|
+
non-streaming Chat Completions for supported priced models and requires an
|
|
118
|
+
eligible run budget on ATC. Its public price catalog refreshes while in use;
|
|
119
|
+
operator-provided prices can override it. No prompts or completions are
|
|
77
120
|
added to trace telemetry.
|
|
78
121
|
|
|
79
122
|
The adapter adds one operation ID to each `create` call before handing it to
|
|
@@ -531,8 +574,11 @@ raw-mode checks still transmit payloads for validation and hashing.
|
|
|
531
574
|
## Reported spending and run budgets — Pro/Team
|
|
532
575
|
|
|
533
576
|
```python
|
|
534
|
-
budget = await guard.set_run_budget(
|
|
535
|
-
|
|
577
|
+
budget = await guard.set_run_budget(
|
|
578
|
+
session_id=run_id, budget_usd="2.00",
|
|
579
|
+
token_limit=100_000, token_alert_at=80_000,
|
|
580
|
+
)
|
|
581
|
+
# GuardSync accepts the same keyword options.
|
|
536
582
|
```
|
|
537
583
|
|
|
538
584
|
Setting a budget does not connect provider billing. An authorized backend must
|
|
@@ -541,9 +587,14 @@ requests. Use matching key/session attribution and stable unique event IDs;
|
|
|
541
587
|
never report cumulative run totals or duplicate spending across integrations.
|
|
542
588
|
|
|
543
589
|
Run budgets are **API key + session** scoped. Rolling thresholds cover a key's
|
|
544
|
-
reported costs over 60 seconds.
|
|
545
|
-
|
|
546
|
-
|
|
590
|
+
reported costs over 60 seconds. Optional `token_limit` and `token_alert_at`
|
|
591
|
+
settings apply to actual provider-reported gateway token use for that run. Alert
|
|
592
|
+
crossings are retained in run budget history and shown in the dashboard; new
|
|
593
|
+
gateway reservations are rejected if their input estimate plus maximum output
|
|
594
|
+
would exceed the remaining ceiling. Updating budgets preserves spending; a new
|
|
595
|
+
run needs a new session ID. Byte-based input estimates are not exact token counts,
|
|
596
|
+
already in-flight requests can finish, and direct calls outside the gateway are
|
|
597
|
+
not covered. These are not provider-side hard caps.
|
|
547
598
|
|
|
548
599
|
## Shared spending reservations — Pro/Team
|
|
549
600
|
|
|
@@ -622,8 +673,10 @@ sync/async helper. No PyPI version change is required for the HTTP endpoint.
|
|
|
622
673
|
|
|
623
674
|
### LangGraph
|
|
624
675
|
|
|
676
|
+
Install the versioned SDK and the optional LangGraph extra:
|
|
677
|
+
|
|
625
678
|
```bash
|
|
626
|
-
python -m pip install 'agenttrafficcop[langgraph]==2.
|
|
679
|
+
python -m pip install 'agenttrafficcop[langgraph]==2.3.0'
|
|
627
680
|
```
|
|
628
681
|
|
|
629
682
|
```python
|
|
@@ -639,13 +692,63 @@ graph.add_node("reviewer", guarded_node(
|
|
|
639
692
|
```
|
|
640
693
|
|
|
641
694
|
Only wrapped nodes are protected. Keep exceptions propagating so failed checks
|
|
642
|
-
stop execution.
|
|
643
|
-
|
|
695
|
+
stop execution. To pause a circuit-breaker trip for a dashboard review, compile
|
|
696
|
+
with a **durable LangGraph checkpointer** (for example, a production
|
|
697
|
+
database-backed saver) and enable the built-in ATC verifier:
|
|
698
|
+
|
|
699
|
+
```python
|
|
700
|
+
builder.add_node("reviewer", guarded_node(
|
|
701
|
+
reviewer_fn, guard=guard, sender="coder", recipient="reviewer",
|
|
702
|
+
session_id=lambda state: state["run_id"],
|
|
703
|
+
payload=lambda state: {"draft": state["draft"]},
|
|
704
|
+
review_on_trip=True,
|
|
705
|
+
))
|
|
706
|
+
# durable_saver is your database-backed LangGraph checkpointer.
|
|
707
|
+
graph = builder.compile(checkpointer=durable_saver)
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
When paused, show `__interrupt__[0].value` to the authorized operator and use
|
|
711
|
+
the dashboard's run-review flow to approve/reject the exact action. Resume with
|
|
712
|
+
`Command(resume={"review_id": event["review_id"]})`; the resume payload itself
|
|
713
|
+
is never authorization. The SDK asks ATC to validate the grant against the
|
|
714
|
+
current detector state and exact action, then rechecks policy and consumes the
|
|
715
|
+
one-action approval before the node runs. The
|
|
716
|
+
status API is read-only; only an authenticated dashboard owner can decide a
|
|
717
|
+
review. A custom `review_approval` callback is optional and must fail closed.
|
|
718
|
+
|
|
719
|
+
For a complete live-service walkthrough, install the SQLite checkpointer extra
|
|
720
|
+
and run the safe no-op example. It pauses after repeated identical requests;
|
|
721
|
+
approve that exact review in the dashboard before pressing Enter. No model
|
|
722
|
+
provider or external tool is called:
|
|
723
|
+
|
|
724
|
+
```bash
|
|
725
|
+
python -m pip install 'agenttrafficcop[langgraph]==2.3.0' 'langgraph-checkpoint-sqlite>=3.1.3,<3.2.0'
|
|
726
|
+
export ATC_URL='https://api.agenttrafficcop.com'
|
|
727
|
+
export ATC_API_KEY='your-server-issued-key'
|
|
728
|
+
python examples/langgraph_native_review.py
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
The example persists LangGraph checkpoints to `atc-langgraph-checkpoints.sqlite`.
|
|
732
|
+
Keep that file and reuse the printed run ID plus `--resume-review-id` after a
|
|
733
|
+
process restart. For an offline walkthrough, run
|
|
734
|
+
`python -I examples/langgraph_checkpointed_review.py` from the repository; it
|
|
735
|
+
uses fake ATC/review services and an in-memory saver, so it is not a production
|
|
736
|
+
configuration.
|
|
737
|
+
|
|
738
|
+
A trip creates a checkpoint with only a generic review event, session ID,
|
|
739
|
+
opaque review ID and safe detector error code—never state, prompts, results or
|
|
740
|
+
exception text. On resume the verifier must approve that exact unchanged action;
|
|
741
|
+
only then does the node perform a fresh ATC check immediately before running. A
|
|
742
|
+
resume value by itself is never approval. Do not use an in-memory saver for
|
|
743
|
+
restart durability.
|
|
744
|
+
Approval does not bypass ATC spend/quota/policy controls. Adapters do not
|
|
745
|
+
automatically enable normalization, hash-only, shadow mode or spending
|
|
746
|
+
reservations. Use direct checks for unexposed options.
|
|
644
747
|
|
|
645
748
|
### Legacy AutoGen
|
|
646
749
|
|
|
647
750
|
```bash
|
|
648
|
-
python -m pip install 'agenttrafficcop[autogen]==2.
|
|
751
|
+
python -m pip install 'agenttrafficcop[autogen]==2.3.0'
|
|
649
752
|
```
|
|
650
753
|
|
|
651
754
|
This legacy adapter supports only `pyautogen==0.2.35`, not AgentChat or AG2.
|
|
@@ -33,10 +33,20 @@ operation ID through ATC's `/v2` gateway. OpenAI SDK internal retries reuse the
|
|
|
33
33
|
same operation ID; pass a persisted ID explicitly for application retries after
|
|
34
34
|
process restarts. OpenAI and Groq non-streaming Chat Completions are supported;
|
|
35
35
|
this helper does not intercept other clients, frameworks, or Anthropic calls.
|
|
36
|
-
Install `agenttrafficcop[openai]`. The gateway
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
Install `agenttrafficcop[openai]`. The gateway uses the refreshable public
|
|
37
|
+
model-price catalog (with operator overrides) and requires an eligible run
|
|
38
|
+
budget. Optional `token_limit` / `token_alert_at` settings on the API-key +
|
|
39
|
+
run budget reject gateway reservations near the cumulative ceiling and record
|
|
40
|
+
threshold events in the run history/dashboard. Admission uses actual provider
|
|
41
|
+
input token counting where supported or a byte-based estimate plus requested
|
|
42
|
+
maximum output tokens; provider-reported usage settles the total. The ceiling is
|
|
43
|
+
not an exact tokenizer or provider-side cap, and in-flight work may overshoot.
|
|
44
|
+
In SDK 2.3.0, `atc gateway init` generates secret-safe setup files,
|
|
45
|
+
`atc gateway models` lists catalog prices, and `atc gateway test` confirms before
|
|
46
|
+
sending one small real provider request. That request may incur charges; the run
|
|
47
|
+
budget is not a guaranteed provider billing cap. For direct-egress blocking,
|
|
48
|
+
use the opt-in self-hosted Compose setup in `../deploy/EGRESS_LOCKED.md`; it
|
|
49
|
+
does not apply to hosted Render or arbitrary external workloads.
|
|
40
50
|
|
|
41
51
|
# Simpler setup — SDK 1.7.0
|
|
42
52
|
|