Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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
```
43 changes: 43 additions & 0 deletions examples/agent_memory.py
Original file line number Diff line number Diff line change
@@ -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()
41 changes: 41 additions & 0 deletions examples/hello_runtime.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading