agntz 0.1.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.
- agntz-0.1.0/.gitignore +9 -0
- agntz-0.1.0/PKG-INFO +266 -0
- agntz-0.1.0/README.md +244 -0
- agntz-0.1.0/pyproject.toml +59 -0
- agntz-0.1.0/src/agntz/__init__.py +96 -0
- agntz-0.1.0/src/agntz/cli/__init__.py +78 -0
- agntz-0.1.0/src/agntz/client/__init__.py +21 -0
- agntz-0.1.0/src/agntz/client/_sse.py +92 -0
- agntz-0.1.0/src/agntz/client/client.py +570 -0
- agntz-0.1.0/src/agntz/client/errors.py +32 -0
- agntz-0.1.0/src/agntz/client/events.py +128 -0
- agntz-0.1.0/src/agntz/client/models.py +118 -0
- agntz-0.1.0/src/agntz/context.py +214 -0
- agntz-0.1.0/src/agntz/core/__init__.py +56 -0
- agntz-0.1.0/src/agntz/core/http_tool.py +81 -0
- agntz-0.1.0/src/agntz/core/ids.py +23 -0
- agntz-0.1.0/src/agntz/core/litellm_provider.py +125 -0
- agntz-0.1.0/src/agntz/core/mcp_tool.py +52 -0
- agntz-0.1.0/src/agntz/core/model_provider.py +78 -0
- agntz-0.1.0/src/agntz/core/resources.py +85 -0
- agntz-0.1.0/src/agntz/core/tools.py +48 -0
- agntz-0.1.0/src/agntz/manifest/__init__.py +65 -0
- agntz-0.1.0/src/agntz/manifest/conditions.py +92 -0
- agntz-0.1.0/src/agntz/manifest/executor.py +157 -0
- agntz-0.1.0/src/agntz/manifest/parser.py +205 -0
- agntz-0.1.0/src/agntz/manifest/state.py +93 -0
- agntz-0.1.0/src/agntz/manifest/template.py +148 -0
- agntz-0.1.0/src/agntz/manifest/types.py +119 -0
- agntz-0.1.0/src/agntz/manifest/validate.py +114 -0
- agntz-0.1.0/src/agntz/memrez.py +529 -0
- agntz-0.1.0/src/agntz/memrez_postgres.py +388 -0
- agntz-0.1.0/src/agntz/memrez_provider.py +110 -0
- agntz-0.1.0/src/agntz/memrez_reasoner.py +140 -0
- agntz-0.1.0/src/agntz/memrez_sqlite.py +324 -0
- agntz-0.1.0/src/agntz/py.typed +1 -0
- agntz-0.1.0/src/agntz/sdk/__init__.py +5 -0
- agntz-0.1.0/src/agntz/sdk/local.py +1004 -0
- agntz-0.1.0/src/agntz/stores/__init__.py +23 -0
- agntz-0.1.0/src/agntz/stores/memory.py +256 -0
- agntz-0.1.0/src/agntz/stores/sqlite.py +438 -0
- agntz-0.1.0/tests/cli/test_cli.py +57 -0
- agntz-0.1.0/tests/client/test_hosted_client.py +287 -0
- agntz-0.1.0/tests/contracts/test_memrez_contracts.py +96 -0
- agntz-0.1.0/tests/contracts/test_phase0_contracts.py +88 -0
- agntz-0.1.0/tests/manifest/test_manifest_contract.py +158 -0
- agntz-0.1.0/tests/sdk/test_local_sdk.py +453 -0
- agntz-0.1.0/tests/test_context_memrez.py +161 -0
- agntz-0.1.0/tests/test_memrez_postgres.py +121 -0
- agntz-0.1.0/tests/test_memrez_reasoner.py +122 -0
- agntz-0.1.0/tests/test_memrez_resource_provider.py +192 -0
- agntz-0.1.0/tests/test_memrez_sqlite.py +110 -0
agntz-0.1.0/.gitignore
ADDED
agntz-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agntz
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK and hosted client for Agntz
|
|
5
|
+
Author: Agntz
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: httpx>=0.28.0
|
|
9
|
+
Requires-Dist: pydantic>=2.8.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: basedpyright>=1.31.0; extra == 'dev'
|
|
13
|
+
Requires-Dist: build>=1.2.0; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest>=8.3.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
17
|
+
Provides-Extra: litellm
|
|
18
|
+
Requires-Dist: litellm>=1.75.0; extra == 'litellm'
|
|
19
|
+
Provides-Extra: postgres
|
|
20
|
+
Requires-Dist: psycopg[binary]>=3.2.0; extra == 'postgres'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Agntz Python
|
|
24
|
+
|
|
25
|
+
Python SDK and hosted client for Agntz.
|
|
26
|
+
|
|
27
|
+
The compatibility rule is simple: an agent definition YAML file should have the
|
|
28
|
+
same observable behavior in the TypeScript and Python runtimes. Python code uses
|
|
29
|
+
Python naming conventions, but the agent, run, session, trace, and tool concepts
|
|
30
|
+
match the TypeScript SDK.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install agntz
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For local LLM execution through LiteLLM:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install "agntz[litellm]"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Create an agent
|
|
45
|
+
|
|
46
|
+
Save this as `agents/support.yaml`:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
id: support
|
|
50
|
+
kind: llm
|
|
51
|
+
name: Support Assistant
|
|
52
|
+
description: Answers support questions with a concise plan.
|
|
53
|
+
model:
|
|
54
|
+
provider: openai
|
|
55
|
+
name: gpt-5.4
|
|
56
|
+
temperature: 0.2
|
|
57
|
+
instruction: |
|
|
58
|
+
You are a careful support agent.
|
|
59
|
+
prompt: |
|
|
60
|
+
Help with this request: {{userQuery}}
|
|
61
|
+
inputSchema:
|
|
62
|
+
userQuery: string
|
|
63
|
+
outputSchema:
|
|
64
|
+
answer: string
|
|
65
|
+
confidence: number
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The same file can be loaded by the TypeScript and Python SDKs.
|
|
69
|
+
|
|
70
|
+
## Run locally
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from agntz import LiteLLMModelProvider, agntz
|
|
74
|
+
|
|
75
|
+
client = agntz(
|
|
76
|
+
agents="./agents",
|
|
77
|
+
model_provider=LiteLLMModelProvider(),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
result = client.agents.run(
|
|
81
|
+
agent_id="support",
|
|
82
|
+
input={"userQuery": "Help me debug this invoice"},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
print(result.output)
|
|
86
|
+
print(result.session_id)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `client.agents.arun(...)` inside an existing event loop.
|
|
90
|
+
|
|
91
|
+
## Hosted client
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import os
|
|
95
|
+
from agntz import AgntzClient
|
|
96
|
+
|
|
97
|
+
client = AgntzClient(
|
|
98
|
+
api_key=os.environ["AGNTZ_API_KEY"],
|
|
99
|
+
base_url="https://api.agntz.co",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
result = client.agents.run(agent_id="support", input="Hello")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The async hosted client has the same resource shape:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from agntz import AsyncAgntzClient
|
|
109
|
+
|
|
110
|
+
async with AsyncAgntzClient(api_key="...", base_url="https://api.agntz.co") as client:
|
|
111
|
+
result = await client.agents.run(agent_id="support", input="Hello")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Pass runtime namespace grants with `context` when the run needs resource access:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
result = client.agents.run(
|
|
118
|
+
agent_id="support",
|
|
119
|
+
input="Hello",
|
|
120
|
+
context=["app/user/u_123"],
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Local tools
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from typing import Any
|
|
128
|
+
|
|
129
|
+
from pydantic import BaseModel
|
|
130
|
+
from agntz import LiteLLMModelProvider, agntz, tool
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class LookupInput(BaseModel):
|
|
134
|
+
order_id: str
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def lookup_order(args: LookupInput) -> dict[str, Any]:
|
|
138
|
+
return {"status": "shipped", "eta": "Tomorrow"}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
client = agntz(
|
|
142
|
+
agents="./agents",
|
|
143
|
+
tools=[
|
|
144
|
+
tool(
|
|
145
|
+
name="lookup_order",
|
|
146
|
+
description="Look up an order by ID",
|
|
147
|
+
input_schema=LookupInput,
|
|
148
|
+
execute=lookup_order,
|
|
149
|
+
)
|
|
150
|
+
],
|
|
151
|
+
model_provider=LiteLLMModelProvider(),
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Reference the tool from YAML:
|
|
156
|
+
|
|
157
|
+
```yaml
|
|
158
|
+
tools:
|
|
159
|
+
- kind: local
|
|
160
|
+
tools: [lookup_order]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
LLM agents can also call HTTP tools, MCP tools over HTTP JSON-RPC, and
|
|
164
|
+
agent-as-tool entries from the same manifest tool declarations used by the
|
|
165
|
+
TypeScript runtime.
|
|
166
|
+
|
|
167
|
+
## Sessions
|
|
168
|
+
|
|
169
|
+
Pass the same `session_id` across runs to continue a conversation. Local
|
|
170
|
+
sessions are persisted by the configured store and are replayed into model calls.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
first = client.agents.run(
|
|
174
|
+
agent_id="support",
|
|
175
|
+
input={"userQuery": "Hi, I need help"},
|
|
176
|
+
session_id="customer-42",
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
second = client.agents.run(
|
|
180
|
+
agent_id="support",
|
|
181
|
+
input={"userQuery": "My order is #12345"},
|
|
182
|
+
session_id=first.session_id,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
messages = client.sessions.get_messages("customer-42")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Runs and traces
|
|
189
|
+
|
|
190
|
+
Local execution records runs, sessions, and trace spans. The same store backs all
|
|
191
|
+
three surfaces.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
runs = client.runs.list(status="completed")
|
|
195
|
+
trace_rows = client.traces.list(agent_id="support")
|
|
196
|
+
|
|
197
|
+
trace_id = trace_rows["rows"][0]["traceId"]
|
|
198
|
+
detail = client.traces.get(trace_id)
|
|
199
|
+
|
|
200
|
+
print(detail["summary"])
|
|
201
|
+
print(detail["spans"])
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## SQLite persistence
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from agntz import LiteLLMModelProvider, SQLiteStore, agntz
|
|
208
|
+
|
|
209
|
+
client = agntz(
|
|
210
|
+
agents="./agents",
|
|
211
|
+
store=SQLiteStore("./agntz.sqlite"),
|
|
212
|
+
model_provider=LiteLLMModelProvider(),
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
SQLite persists local runs, trace spans, sessions, and messages across process
|
|
217
|
+
restarts.
|
|
218
|
+
|
|
219
|
+
## Memrez
|
|
220
|
+
|
|
221
|
+
The Python package includes the same namespace-grant and memrez core primitives
|
|
222
|
+
as the TypeScript package.
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from agntz.memrez import create_memrez
|
|
226
|
+
|
|
227
|
+
memrez = create_memrez()
|
|
228
|
+
memrez.write(["app/user/u_123"], "Prefers metric units.", topics_hint=["prefs"])
|
|
229
|
+
entries = memrez.read(["app/user/u_123"], "prefs")
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## CLI
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
agntz validate ./agents
|
|
236
|
+
agntz run ./agents support --input '{"userQuery":"hello"}'
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Current parity
|
|
240
|
+
|
|
241
|
+
Implemented in this package:
|
|
242
|
+
|
|
243
|
+
- Hosted sync and async clients for run, run stream, runs, and traces.
|
|
244
|
+
- Local YAML execution for `llm`, `tool`, `sequential`, and `parallel` agents.
|
|
245
|
+
- Local Python tools, HTTP tools, MCP JSON-RPC tools, and agent-as-tool calls.
|
|
246
|
+
- Runtime namespace grants and the in-memory memrez core.
|
|
247
|
+
- LiteLLM-backed model execution with tool-call loop support.
|
|
248
|
+
- Memory and SQLite stores for runs, trace spans, sessions, and messages.
|
|
249
|
+
- Contract fixtures shared with the TypeScript manifest package.
|
|
250
|
+
|
|
251
|
+
Still intentionally outside this first Python package slice:
|
|
252
|
+
|
|
253
|
+
- The hosted app and worker remain TypeScript services.
|
|
254
|
+
- Python does not reimplement the TypeScript eval product yet.
|
|
255
|
+
- Streaming token deltas for local Python execution are not exposed yet.
|
|
256
|
+
|
|
257
|
+
## Development
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
python -m venv .venv
|
|
261
|
+
.venv/bin/python -m pip install -e '.[dev,litellm]'
|
|
262
|
+
.venv/bin/python -m pytest
|
|
263
|
+
.venv/bin/python -m ruff check .
|
|
264
|
+
.venv/bin/python -m basedpyright
|
|
265
|
+
.venv/bin/python -m build
|
|
266
|
+
```
|
agntz-0.1.0/README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Agntz Python
|
|
2
|
+
|
|
3
|
+
Python SDK and hosted client for Agntz.
|
|
4
|
+
|
|
5
|
+
The compatibility rule is simple: an agent definition YAML file should have the
|
|
6
|
+
same observable behavior in the TypeScript and Python runtimes. Python code uses
|
|
7
|
+
Python naming conventions, but the agent, run, session, trace, and tool concepts
|
|
8
|
+
match the TypeScript SDK.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install agntz
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For local LLM execution through LiteLLM:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install "agntz[litellm]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Create an agent
|
|
23
|
+
|
|
24
|
+
Save this as `agents/support.yaml`:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
id: support
|
|
28
|
+
kind: llm
|
|
29
|
+
name: Support Assistant
|
|
30
|
+
description: Answers support questions with a concise plan.
|
|
31
|
+
model:
|
|
32
|
+
provider: openai
|
|
33
|
+
name: gpt-5.4
|
|
34
|
+
temperature: 0.2
|
|
35
|
+
instruction: |
|
|
36
|
+
You are a careful support agent.
|
|
37
|
+
prompt: |
|
|
38
|
+
Help with this request: {{userQuery}}
|
|
39
|
+
inputSchema:
|
|
40
|
+
userQuery: string
|
|
41
|
+
outputSchema:
|
|
42
|
+
answer: string
|
|
43
|
+
confidence: number
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The same file can be loaded by the TypeScript and Python SDKs.
|
|
47
|
+
|
|
48
|
+
## Run locally
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from agntz import LiteLLMModelProvider, agntz
|
|
52
|
+
|
|
53
|
+
client = agntz(
|
|
54
|
+
agents="./agents",
|
|
55
|
+
model_provider=LiteLLMModelProvider(),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
result = client.agents.run(
|
|
59
|
+
agent_id="support",
|
|
60
|
+
input={"userQuery": "Help me debug this invoice"},
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
print(result.output)
|
|
64
|
+
print(result.session_id)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Use `client.agents.arun(...)` inside an existing event loop.
|
|
68
|
+
|
|
69
|
+
## Hosted client
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import os
|
|
73
|
+
from agntz import AgntzClient
|
|
74
|
+
|
|
75
|
+
client = AgntzClient(
|
|
76
|
+
api_key=os.environ["AGNTZ_API_KEY"],
|
|
77
|
+
base_url="https://api.agntz.co",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
result = client.agents.run(agent_id="support", input="Hello")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The async hosted client has the same resource shape:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from agntz import AsyncAgntzClient
|
|
87
|
+
|
|
88
|
+
async with AsyncAgntzClient(api_key="...", base_url="https://api.agntz.co") as client:
|
|
89
|
+
result = await client.agents.run(agent_id="support", input="Hello")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Pass runtime namespace grants with `context` when the run needs resource access:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
result = client.agents.run(
|
|
96
|
+
agent_id="support",
|
|
97
|
+
input="Hello",
|
|
98
|
+
context=["app/user/u_123"],
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Local tools
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from typing import Any
|
|
106
|
+
|
|
107
|
+
from pydantic import BaseModel
|
|
108
|
+
from agntz import LiteLLMModelProvider, agntz, tool
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class LookupInput(BaseModel):
|
|
112
|
+
order_id: str
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def lookup_order(args: LookupInput) -> dict[str, Any]:
|
|
116
|
+
return {"status": "shipped", "eta": "Tomorrow"}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
client = agntz(
|
|
120
|
+
agents="./agents",
|
|
121
|
+
tools=[
|
|
122
|
+
tool(
|
|
123
|
+
name="lookup_order",
|
|
124
|
+
description="Look up an order by ID",
|
|
125
|
+
input_schema=LookupInput,
|
|
126
|
+
execute=lookup_order,
|
|
127
|
+
)
|
|
128
|
+
],
|
|
129
|
+
model_provider=LiteLLMModelProvider(),
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Reference the tool from YAML:
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
tools:
|
|
137
|
+
- kind: local
|
|
138
|
+
tools: [lookup_order]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
LLM agents can also call HTTP tools, MCP tools over HTTP JSON-RPC, and
|
|
142
|
+
agent-as-tool entries from the same manifest tool declarations used by the
|
|
143
|
+
TypeScript runtime.
|
|
144
|
+
|
|
145
|
+
## Sessions
|
|
146
|
+
|
|
147
|
+
Pass the same `session_id` across runs to continue a conversation. Local
|
|
148
|
+
sessions are persisted by the configured store and are replayed into model calls.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
first = client.agents.run(
|
|
152
|
+
agent_id="support",
|
|
153
|
+
input={"userQuery": "Hi, I need help"},
|
|
154
|
+
session_id="customer-42",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
second = client.agents.run(
|
|
158
|
+
agent_id="support",
|
|
159
|
+
input={"userQuery": "My order is #12345"},
|
|
160
|
+
session_id=first.session_id,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
messages = client.sessions.get_messages("customer-42")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Runs and traces
|
|
167
|
+
|
|
168
|
+
Local execution records runs, sessions, and trace spans. The same store backs all
|
|
169
|
+
three surfaces.
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
runs = client.runs.list(status="completed")
|
|
173
|
+
trace_rows = client.traces.list(agent_id="support")
|
|
174
|
+
|
|
175
|
+
trace_id = trace_rows["rows"][0]["traceId"]
|
|
176
|
+
detail = client.traces.get(trace_id)
|
|
177
|
+
|
|
178
|
+
print(detail["summary"])
|
|
179
|
+
print(detail["spans"])
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## SQLite persistence
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from agntz import LiteLLMModelProvider, SQLiteStore, agntz
|
|
186
|
+
|
|
187
|
+
client = agntz(
|
|
188
|
+
agents="./agents",
|
|
189
|
+
store=SQLiteStore("./agntz.sqlite"),
|
|
190
|
+
model_provider=LiteLLMModelProvider(),
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
SQLite persists local runs, trace spans, sessions, and messages across process
|
|
195
|
+
restarts.
|
|
196
|
+
|
|
197
|
+
## Memrez
|
|
198
|
+
|
|
199
|
+
The Python package includes the same namespace-grant and memrez core primitives
|
|
200
|
+
as the TypeScript package.
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from agntz.memrez import create_memrez
|
|
204
|
+
|
|
205
|
+
memrez = create_memrez()
|
|
206
|
+
memrez.write(["app/user/u_123"], "Prefers metric units.", topics_hint=["prefs"])
|
|
207
|
+
entries = memrez.read(["app/user/u_123"], "prefs")
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## CLI
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
agntz validate ./agents
|
|
214
|
+
agntz run ./agents support --input '{"userQuery":"hello"}'
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Current parity
|
|
218
|
+
|
|
219
|
+
Implemented in this package:
|
|
220
|
+
|
|
221
|
+
- Hosted sync and async clients for run, run stream, runs, and traces.
|
|
222
|
+
- Local YAML execution for `llm`, `tool`, `sequential`, and `parallel` agents.
|
|
223
|
+
- Local Python tools, HTTP tools, MCP JSON-RPC tools, and agent-as-tool calls.
|
|
224
|
+
- Runtime namespace grants and the in-memory memrez core.
|
|
225
|
+
- LiteLLM-backed model execution with tool-call loop support.
|
|
226
|
+
- Memory and SQLite stores for runs, trace spans, sessions, and messages.
|
|
227
|
+
- Contract fixtures shared with the TypeScript manifest package.
|
|
228
|
+
|
|
229
|
+
Still intentionally outside this first Python package slice:
|
|
230
|
+
|
|
231
|
+
- The hosted app and worker remain TypeScript services.
|
|
232
|
+
- Python does not reimplement the TypeScript eval product yet.
|
|
233
|
+
- Streaming token deltas for local Python execution are not exposed yet.
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
python -m venv .venv
|
|
239
|
+
.venv/bin/python -m pip install -e '.[dev,litellm]'
|
|
240
|
+
.venv/bin/python -m pytest
|
|
241
|
+
.venv/bin/python -m ruff check .
|
|
242
|
+
.venv/bin/python -m basedpyright
|
|
243
|
+
.venv/bin/python -m build
|
|
244
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "agntz"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python SDK and hosted client for Agntz"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "Agntz" }]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"httpx>=0.28.0",
|
|
11
|
+
"pydantic>=2.8.0",
|
|
12
|
+
"PyYAML>=6.0.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
litellm = [
|
|
17
|
+
"litellm>=1.75.0",
|
|
18
|
+
]
|
|
19
|
+
postgres = [
|
|
20
|
+
"psycopg[binary]>=3.2.0",
|
|
21
|
+
]
|
|
22
|
+
dev = [
|
|
23
|
+
"build>=1.2.0",
|
|
24
|
+
"basedpyright>=1.31.0",
|
|
25
|
+
"pytest>=8.3.0",
|
|
26
|
+
"pytest-asyncio>=0.24.0",
|
|
27
|
+
"ruff>=0.8.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
agntz = "agntz.cli:main"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["hatchling>=1.25.0"]
|
|
35
|
+
build-backend = "hatchling.build"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["src/agntz"]
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
testpaths = ["tests"]
|
|
42
|
+
pythonpath = ["src"]
|
|
43
|
+
asyncio_mode = "auto"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
target-version = "py311"
|
|
47
|
+
line-length = 100
|
|
48
|
+
src = ["src", "tests"]
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
52
|
+
|
|
53
|
+
[tool.basedpyright]
|
|
54
|
+
include = ["src", "tests"]
|
|
55
|
+
typeCheckingMode = "standard"
|
|
56
|
+
pythonVersion = "3.11"
|
|
57
|
+
reportUnknownMemberType = "none"
|
|
58
|
+
reportUnknownVariableType = "none"
|
|
59
|
+
reportUnknownArgumentType = "none"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Python SDK and hosted client for Agntz."""
|
|
2
|
+
|
|
3
|
+
from .client import (
|
|
4
|
+
AgntzClient,
|
|
5
|
+
AgntzError,
|
|
6
|
+
AsyncAgntzClient,
|
|
7
|
+
AuthenticationError,
|
|
8
|
+
NotFoundError,
|
|
9
|
+
StreamError,
|
|
10
|
+
)
|
|
11
|
+
from .context import (
|
|
12
|
+
NamespaceGrantError,
|
|
13
|
+
NamespaceGrantPolicy,
|
|
14
|
+
ProtectedNamespaceRule,
|
|
15
|
+
normalize_namespace_grant,
|
|
16
|
+
normalize_namespace_grants,
|
|
17
|
+
validate_namespace_grant_policy,
|
|
18
|
+
)
|
|
19
|
+
from .core import (
|
|
20
|
+
GenerateTextResult,
|
|
21
|
+
LiteLLMModelProvider,
|
|
22
|
+
ModelMessage,
|
|
23
|
+
ModelProvider,
|
|
24
|
+
ModelTool,
|
|
25
|
+
ResourceProvider,
|
|
26
|
+
ResourceProviderToolDefinition,
|
|
27
|
+
ResourceRegistrationContext,
|
|
28
|
+
ResourceToolContext,
|
|
29
|
+
ToolCall,
|
|
30
|
+
ToolDefinition,
|
|
31
|
+
ToolResult,
|
|
32
|
+
tool,
|
|
33
|
+
)
|
|
34
|
+
from .memrez import Memrez, MemrezScopeError, create_memrez
|
|
35
|
+
from .memrez_postgres import PostgresMemoryStore, PostgresMemoryStoreOptions
|
|
36
|
+
from .memrez_provider import MemoryResourceProvider, create_memory_resource_provider
|
|
37
|
+
from .memrez_reasoner import AgntzReasoner, agntz_reasoner, memrez_agents_path
|
|
38
|
+
from .memrez_sqlite import SqliteMemoryStore, SqliteMemoryStoreOptions
|
|
39
|
+
from .sdk import LocalClient, agntz
|
|
40
|
+
from .stores import (
|
|
41
|
+
LocalMessageRecord,
|
|
42
|
+
LocalSessionSummary,
|
|
43
|
+
LocalTraceSpanRecord,
|
|
44
|
+
MemoryStore,
|
|
45
|
+
SQLiteStore,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"__version__",
|
|
50
|
+
"AgntzClient",
|
|
51
|
+
"AgntzError",
|
|
52
|
+
"AgntzReasoner",
|
|
53
|
+
"AsyncAgntzClient",
|
|
54
|
+
"AuthenticationError",
|
|
55
|
+
"GenerateTextResult",
|
|
56
|
+
"LiteLLMModelProvider",
|
|
57
|
+
"LocalClient",
|
|
58
|
+
"LocalMessageRecord",
|
|
59
|
+
"LocalSessionSummary",
|
|
60
|
+
"LocalTraceSpanRecord",
|
|
61
|
+
"ModelMessage",
|
|
62
|
+
"ModelProvider",
|
|
63
|
+
"ModelTool",
|
|
64
|
+
"MemoryStore",
|
|
65
|
+
"MemoryResourceProvider",
|
|
66
|
+
"Memrez",
|
|
67
|
+
"MemrezScopeError",
|
|
68
|
+
"NamespaceGrantError",
|
|
69
|
+
"NamespaceGrantPolicy",
|
|
70
|
+
"NotFoundError",
|
|
71
|
+
"PostgresMemoryStore",
|
|
72
|
+
"PostgresMemoryStoreOptions",
|
|
73
|
+
"ProtectedNamespaceRule",
|
|
74
|
+
"ResourceProvider",
|
|
75
|
+
"ResourceProviderToolDefinition",
|
|
76
|
+
"ResourceRegistrationContext",
|
|
77
|
+
"ResourceToolContext",
|
|
78
|
+
"SQLiteStore",
|
|
79
|
+
"SqliteMemoryStore",
|
|
80
|
+
"SqliteMemoryStoreOptions",
|
|
81
|
+
"StreamError",
|
|
82
|
+
"ToolCall",
|
|
83
|
+
"ToolDefinition",
|
|
84
|
+
"ToolResult",
|
|
85
|
+
"agntz",
|
|
86
|
+
"agntz_reasoner",
|
|
87
|
+
"create_memory_resource_provider",
|
|
88
|
+
"create_memrez",
|
|
89
|
+
"memrez_agents_path",
|
|
90
|
+
"normalize_namespace_grant",
|
|
91
|
+
"normalize_namespace_grants",
|
|
92
|
+
"validate_namespace_grant_policy",
|
|
93
|
+
"tool",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
__version__ = "0.1.0"
|