From a3f1e7e829bb458d57d19d9c7aa70ef00bd23202 Mon Sep 17 00:00:00 2001 From: Jascha Wanger Date: Tue, 30 Jun 2026 23:01:36 -0700 Subject: [PATCH] examples: add runnable examples; fix setup.py license to Apache-2.0 - Add examples/ with a self-contained MarkdownMemoryStore example (no runtime needed) and a runtime hello example (health check + list agents). - setup.py declared MIT while pyproject.toml, the LICENSE file, and the classifiers all say Apache-2.0. Align setup.py to Apache-2.0 and add the matching license classifier. --- examples/README.md | 21 +++++++++++++++++++ examples/agent_memory.py | 43 +++++++++++++++++++++++++++++++++++++++ examples/hello_runtime.py | 41 +++++++++++++++++++++++++++++++++++++ setup.py | 3 ++- 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 examples/README.md create mode 100644 examples/agent_memory.py create mode 100644 examples/hello_runtime.py diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..e5d3f7a --- /dev/null +++ b/examples/README.md @@ -0,0 +1,21 @@ +# Examples + +Runnable examples for the Symbiont Python SDK. + +```bash +pip install symbiont-sdk +``` + +| Example | Needs a runtime? | What it shows | +|---------|:---:|---------------| +| [`agent_memory.py`](agent_memory.py) | No | Persistent, file-based agent memory with `MarkdownMemoryStore` — fully self-contained. | +| [`hello_runtime.py`](hello_runtime.py) | Yes | Connect to a running runtime, health-check it, and list agents. | + +For the runtime example, start a Symbiont runtime first (`symbi up` or the +Docker quick-start in the main [Symbiont README](https://github.com/thirdkeyai/symbiont)), +then set `SYMBIONT_BASE_URL` (and `SYMBIONT_API_KEY` if required). + +```bash +python examples/agent_memory.py +python examples/hello_runtime.py +``` diff --git a/examples/agent_memory.py b/examples/agent_memory.py new file mode 100644 index 0000000..c968043 --- /dev/null +++ b/examples/agent_memory.py @@ -0,0 +1,43 @@ +"""Persistent agent memory — a self-contained example (no runtime required). + +MarkdownMemoryStore gives an agent file-based context that survives restarts, +stored as human-readable markdown. This example writes a context, reads it +back, and prints storage stats — it talks to the local filesystem only, so it +runs without a Symbiont runtime. + +Run: + pip install symbiont-sdk + python examples/agent_memory.py +""" + +import tempfile + +from symbiont import AgentMemoryContext, MarkdownMemoryStore + + +def main() -> None: + root = tempfile.mkdtemp(prefix="symbi-memory-") + store = MarkdownMemoryStore(root_dir=root) + + store.save_context( + "agent-1", + AgentMemoryContext( + agent_id="agent-1", + facts=["The user prefers concise answers."], + procedures=["Validate input before acting."], + learned_patterns=["Batch related tool calls."], + metadata={"team": "research"}, + ), + ) + + context = store.load_context("agent-1") + print("loaded facts:", context.facts) + print("known agents:", store.list_agent_contexts()) + + stats = store.get_storage_stats() + print("contexts:", stats.total_contexts, "bytes:", stats.total_size_bytes) + print("stored under:", root) + + +if __name__ == "__main__": + main() diff --git a/examples/hello_runtime.py b/examples/hello_runtime.py new file mode 100644 index 0000000..fdc13ae --- /dev/null +++ b/examples/hello_runtime.py @@ -0,0 +1,41 @@ +"""Hello, runtime — the smallest end-to-end Symbiont SDK example. + +Connects to a running Symbiont runtime, checks its health, and lists the +agents it knows about. + +Prerequisites: + - A Symbiont runtime reachable at SYMBIONT_BASE_URL (default + http://localhost:8080/api/v1). Start one with `symbi up` or the Docker + quick-start (see the main Symbiont README). + - Optionally SYMBIONT_API_KEY if your runtime requires authentication. + +Run: + pip install symbiont-sdk + python examples/hello_runtime.py +""" + +import os + +from symbiont import Client + + +def main() -> None: + client = Client( + api_key=os.environ.get("SYMBIONT_API_KEY"), + base_url=os.environ.get("SYMBIONT_BASE_URL", "http://localhost:8080/api/v1"), + ) + + print("health:", client.health_check()) + + agent_ids = client.list_agents() + if not agent_ids: + print("no agents registered yet — scaffold one with `symbi init`") + return + + for agent_id in agent_ids: + status = client.get_agent_status(agent_id) + print(agent_id, status.state, status.resource_usage) + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 27e2a9f..4d392d1 100644 --- a/setup.py +++ b/setup.py @@ -30,10 +30,11 @@ def read_requirements(): install_requires=read_requirements(), python_requires='>=3.7', keywords=['symbiont', 'sdk', 'api', 'ai', 'agents'], - license='MIT', + license='Apache-2.0', classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8',