Python SDK for the 9D Labs runtime_v2 agent governance API
Project description
nined-agents
Python SDK for the 9D Labs runtime_v2 agent governance API.
Zero dependencies. Python 3.11+.
Install
pip install nined-agents
Quick start
from nined.agents import MemoryClient, PolicyDeniedError
client = MemoryClient(
base_url="http://127.0.0.1:8082",
api_key="your-api-key",
world_id="my-world",
workspace_id="ops-team",
actor_id="agent-alpha",
profile="builder", # "builder" | "team" | "autonomy"
)
# Ingest a document
client.ingest([{
"artifact_type": "document",
"raw_payload": {"title": "Runbook", "content": "Restart pod if OOM."},
}])
# Retrieve relevant context
pack = client.context_pack("What do I do if pods are down?")
# Run a governed task (lock → work → complete → release, in one call)
client.start_task("task-001", title="Fix prod")
client.work_on_task("task-001", "restart_deployment")
Profiles
| Profile | Capabilities |
|---|---|
builder |
memory + basic task ops |
team |
+ handoffs, locks, replay |
autonomy |
+ diffs, alerts (default) |
All methods
Memory
ingest(artifacts)— store documents/artifactscontext_pack(query, *, max_tokens, profile)— retrieve context
Tasks
start_task(task_id, *, title, metadata)attempt_action(task_id, action_name, *, decision_type, reason, ...)complete_task(task_id)fail_task(task_id, *, reason)
Coordination
acquire_lock(task_id, *, ttl_seconds)release_lock(task_id)handoff(task_id, *, to_actor_id, reason)
Convenience (recommended)
work_on_task(task_id, action_name, *, reason, complete)— full lock→work→complete→releasedelegate_task(task_id, to_actor_id, *, reason)— release + handoffescalate_task(task_id, *, reason)— signals need for higher authority
State
get_task_state(task_id)— includesallowed_actions+protocol_hintget_timeline(task_id)— append-only event history
Ops
replay(pack_hash)— verify determinismget_receipts(*, limit, offset)upsert_policy_bundle(bundle_version, *, role_capabilities, constraints)get_policy_bundle()
Errors
from nined.agents import PolicyDeniedError
try:
client.complete_task("t1")
except PolicyDeniedError as exc:
print(exc.reason_code) # e.g. "policy_denied_invalid_state_transition"
print(exc.recommended_action) # hint string
print(exc.recovery) # {"recovery_action": "get_task_state", ...}
| Exception | When |
|---|---|
PolicyDeniedError |
Runtime denied the action (state violation, missing approval, etc.) |
ConflictError |
Lock contention or stale handoff |
AuthorizationError |
Bad API key or missing capabilities |
MemoryAPIError |
Any other API error (base class) |
Runtime-guided behavior
get_task_state() always returns allowed_actions and protocol_hint:
state = client.get_task_state("task-001")
print(state["allowed_actions"]) # ["attempt_action", "complete_task", "release_lock"]
print(state["protocol_hint"]) # "You own this task and hold the lock. Do your work..."
Agents can use these to drive a self-correcting action loop without hardcoding state logic.
TLA+ verification
The specs/TaskFSM.tla model verifies four invariants over all reachable states:
- Terminal states are irreversible
- Lock is exclusive (at most one holder)
- Actions that mutate task state require holding the lock
- Only the owner can act on a task
java -XX:+UseParallelGC -jar tla2tools.jar \
-config specs/TaskFSM.cfg -workers 4 -nowarning -deadlock specs/TaskFSM.tla
Project details
Release history Release notifications | RSS feed
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 nined_agents-0.1.0.tar.gz.
File metadata
- Download URL: nined_agents-0.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea82cb1e4a2229a63c9e92bde39f5f8963ab7acc084a195b2815a0a5c7aa38e3
|
|
| MD5 |
1bcabcf65030d77c10fb6880b77f0327
|
|
| BLAKE2b-256 |
5d504caa569c64f85a084c53a43e85508f13d2050e98116d6370c050958cd114
|
File details
Details for the file nined_agents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nined_agents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7854fc38313114308a8f2d999ffdd3005d1da41c7799d9b1a0942f36c06d70ba
|
|
| MD5 |
8dac5e7306fceb1294a7601f020ef339
|
|
| BLAKE2b-256 |
f208f8ba237602a47b532dd2116a37266bc472bfbacb82d89cae46e8e834ed40
|