docs(python): iii-sdk example replaces standalone REST client#364
Conversation
Closes #342. agentmemory functions register as mem::remember, mem::observe, mem::context, mem::smart-search, mem::forget via sdk.registerFunction. iii-sdk already ships in Python, Rust, and Node — any of them can call those functions directly over the iii WebSocket transport. A standalone Python REST client would duplicate the transport layer and fragment the cross-language story. This patch adds: - examples/python/quickstart.py — minimal save + smart-search loop. - examples/python/observe_and_recall.py — observation ingest + context rendering at a token budget. - examples/python/README.md — function map + install + usage. - README "Programmatic access (Python / Rust / Node)" section pointing at the example and the three SDK install commands. REST on :3111 is unchanged for hosts without an iii runtime.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds documentation and Python examples for the iii SDK, which provides WebSocket-based programmatic access to agentmemory. The main README introduces the approach with language-specific installation snippets, the Python guide details all exposed memory functions and their payloads, and two example scripts demonstrate basic and advanced workflows. Changesiii SDK Documentation and Python Examples
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/python/observe_and_recall.py`:
- Around line 18-19: The SESSION_ID constant is hard-coded to
"py-example-session-001", causing context to persist across runs; update the
code that sets SESSION_ID to generate a unique ID per execution (e.g., combine a
timestamp or UUID) so each run uses a distinct session identifier; locate the
SESSION_ID symbol in the example (and any places that reference it) and replace
the fixed string with a runtime-generated unique value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b723e2db-4832-464f-9a91-549a2140b78e
📒 Files selected for processing (4)
README.mdexamples/python/README.mdexamples/python/observe_and_recall.pyexamples/python/quickstart.py
| SESSION_ID = "py-example-session-001" | ||
| PROJECT = "demo" |
There was a problem hiding this comment.
Use a unique session id per run to keep the example deterministic.
A fixed session id makes repeated runs bleed context across executions, which can confuse quick verification.
Suggested patch
from datetime import datetime, timezone
+from uuid import uuid4
from iii import register_worker
-SESSION_ID = "py-example-session-001"
+SESSION_ID = f"py-example-session-{uuid4().hex[:8]}"
PROJECT = "demo"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@examples/python/observe_and_recall.py` around lines 18 - 19, The SESSION_ID
constant is hard-coded to "py-example-session-001", causing context to persist
across runs; update the code that sets SESSION_ID to generate a unique ID per
execution (e.g., combine a timestamp or UUID) so each run uses a distinct
session identifier; locate the SESSION_ID symbol in the example (and any places
that reference it) and replace the fixed string with a runtime-generated unique
value.
Why this replaces the earlier #360 attempt
agentmemory registers its core operations as iii functions (
mem::remember,mem::observe,mem::context,mem::smart-search,mem::forget) viasdk.registerFunction(...). iii-sdk already ships in Python, Rust, and Node — any of them can call those functions directly over the iii WebSocket transport onws://localhost:49134.Shipping a standalone Python REST client would:
Closes #342.
What this PR adds
examples/python/quickstart.pyexamples/python/observe_and_recall.pyexamples/python/README.mdREADME.md— new "Programmatic access (Python / Rust / Node)" sectionexamples/python/.Function map exposed to Python
mem::rememberproject,title,contentmem::observehookType,sessionId,project,cwd,timestampmem::contextsessionId,project, optionalbudgetmem::smart-searchproject,query, optionallimitmem::forgetidREST stays untouched
The
api::*HTTP-trigger wrappers on:3111remain available for hosts without an iii runtime (e.g. shell scripts, browser, language without an iii SDK).Test plan
pip install iii-sdksucceeds on Python 3.10+.python examples/python/quickstart.pyagainst a running daemon (npx -y @agentmemory/agentmemory) saves and recalls.python examples/python/observe_and_recall.pyingests three observations and prints rendered context under the 2000-token budget.Summary by CodeRabbit
Release Notes