Skip to content

docs(python): iii-sdk example replaces standalone REST client#364

Merged
rohitg00 merged 1 commit into
mainfrom
feat/iii-sdk-python-example-342
May 13, 2026
Merged

docs(python): iii-sdk example replaces standalone REST client#364
rohitg00 merged 1 commit into
mainfrom
feat/iii-sdk-python-example-342

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 13, 2026

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) 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 on ws://localhost:49134.

Shipping a standalone Python REST client would:

  • Duplicate the transport layer that iii-sdk already provides.
  • Fragment the cross-language story — three languages, one SDK becomes three languages, two SDKs for Python users only.
  • Force Python users to learn an agentmemory-specific surface instead of the same iii primitives every other language uses.

Closes #342.

What this PR adds

File Purpose
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 Install, function map, usage.
README.md — new "Programmatic access (Python / Rust / Node)" section Three-line install matrix + Python snippet pointing at examples/python/.

Function map exposed to Python

Function id Required payload
mem::remember project, title, content
mem::observe hookType, sessionId, project, cwd, timestamp
mem::context sessionId, project, optional budget
mem::smart-search project, query, optional limit
mem::forget id

REST stays untouched

The api::* HTTP-trigger wrappers on :3111 remain available for hosts without an iii runtime (e.g. shell scripts, browser, language without an iii SDK).

Test plan

  • pip install iii-sdk succeeds on Python 3.10+.
  • python examples/python/quickstart.py against a running daemon (npx -y @agentmemory/agentmemory) saves and recalls.
  • python examples/python/observe_and_recall.py ingests three observations and prints rendered context under the 2000-token budget.

Summary by CodeRabbit

Release Notes

  • Documentation
    • Introduced programmatic access guide for Python, Rust, and Node via WebSocket connection
    • Added Python SDK documentation covering available operations, payload requirements, and REST/direct call options
    • Provided example scripts demonstrating quickstart and observe/recall workflows

Review Change Stack

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.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 13, 2026 7:59pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

This 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.

Changes

iii SDK Documentation and Python Examples

Layer / File(s) Summary
Main README iii SDK overview
README.md
Main README documents the iii SDK as an alternative to REST API, explaining WebSocket connection at ws://localhost:49134 and showing a Python example using register_worker().connect() and iii.trigger() to invoke mem::smart-search.
Python SDK guide and quickstart example
examples/python/README.md, examples/python/quickstart.py
Python usage README explains installation, WebSocket connection flow, and the table of exposed mem::* functions with required payload fields; quickstart example demonstrates basic mem::remember and mem::smart-search workflows with formatted result printing.
Advanced observation and context workflow
examples/python/observe_and_recall.py
The observe_and_recall example demonstrates a multi-step workflow: connecting to a worker, emitting sequential observation events, requesting rendered context with a token budget, and formatting UTC ISO-8601 timestamps.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Through WebSocket threads we weave and bind,
Examples bloom in Python's kind design,
Observe, remember, context flows so free,
The iii bridge carries agentmemory's spree! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR does not implement the REST client requirements from issue #342 (typed Client/AsyncClient, HTTP wrapper, bearer-token auth, PyPI publication). Instead, it provides iii-sdk WebSocket examples. Either implement the REST client as specified in #342 (Client, AsyncClient, _http.py, _types.py, PyPI), or close #342 with a note that the approach has changed to iii-sdk focus.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title describes the main change (replacing standalone REST client plan with iii-sdk examples), but the PR actually implements iii-sdk examples rather than the REST client originally proposed in issue #342. Clarify whether this is a pivot away from issue #342's REST client objective or if the REST client work will continue separately.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed The PR adds iii-sdk WebSocket examples, which is a different approach than the REST client specified in issue #342. While the changes are well-scoped to documentation and examples, they do not address the REST client objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/iii-sdk-python-example-342

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 96c0ed0 and 690b9e4.

📒 Files selected for processing (4)
  • README.md
  • examples/python/README.md
  • examples/python/observe_and_recall.py
  • examples/python/quickstart.py

Comment on lines +18 to +19
SESSION_ID = "py-example-session-001"
PROJECT = "demo"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@rohitg00 rohitg00 merged commit f365d38 into main May 13, 2026
5 checks passed
@rohitg00 rohitg00 deleted the feat/iii-sdk-python-example-342 branch May 13, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python thin REST client (agentmemory-py)

1 participant