AGENT SKILL

python-sdk-and-cli

Use the MemMachine Python SDK and CLI for project context, memory add/search/list/delete, semantic profile operations, filters, formatting, config API wrappers, and LangGraph tool helpers.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
python-sdk-and-cli
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use the MemMachine Python SDK and CLI for project context, memory add/search/list/delete, semantic profile operations, filters, formatting, config API wrappers, and LangGraph tool helpers.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Python SDK And CLI

Use this sub-skill when a task names memmachine_client, MemMachineClient, Project, Memory, Config, mem-cli, memmachine, Python memory add or search, semantic categories/tags/features, metadata filters, agent_mode, or LangGraph memory tools.

Route Within This Sub-skill

  • Read python-sdk-reference.md for the verified Python object model, method signatures, and return-shape notes.
  • Read memory-workflows.md for project/context setup, add/search/list/delete, semantic feature/category/tag workflows, filters, and validation patterns.
  • Read cli-reference.md for mem-cli and memmachine command shapes, environment variables, JSON flags, and safe examples.
  • Read troubleshooting.md when imports, base URLs, project context, filters, closed clients, or server responses fail.
  • Run mem_cli_smoke.py to inspect CLI parser/help or build safe command examples without contacting a server.
  • Run python_client_recipe.py to print a minimal Python SDK recipe or optionally run a live health/add/search demo only when explicit live arguments are supplied.

Quick Python Pattern

from memmachine_client import MemMachineClient

client = MemMachineClient(base_url="http://localhost:8080", api_key=None)
try:
    project = client.get_or_create_project(org_id="my-org", project_id="my-project")
    memory = project.memory(
        metadata={"user_id": "alice", "agent_id": "assistant", "session_id": "demo"}
    )
    memory.add("Alice prefers aisle seats.", metadata={"category": "travel"})
    results = memory.search("What seating does Alice prefer?", limit=5)
finally:
    client.close()

Use explicit org_id, project_id, and memory metadata instead of relying on ambient defaults. Keep API keys in environment variables or secret stores.

Quick CLI Pattern

mem-cli --base-url "http://localhost:8080" memory add \
  "Alice prefers aisle seats." \
  --org-id "my-org" --project-id "my-project" \
  --metadata user_id=alice --metadata agent_id=assistant \
  --metadata category=travel

mem-cli --base-url "http://localhost:8080" memory search \
  "What seating does Alice prefer?" \
  --org-id "my-org" --project-id "my-project" --limit 5

Global flags such as --base-url and --api-key come before the subcommand. Project context flags belong on projects or memory subcommands.

Decision Points

  • SDK or CLI? Use SDK for application code and tests; use CLI for ad-hoc inspection, shell workflows, and agent memory retrieval/addition.
  • Filter style? Use modern filter="metadata.category = 'travel'" for boolean logic. Use filter_dict only for simple legacy equality filters.
  • Semantic or episodic? MemoryType supports episodic and semantic. Adding to both may be useful, but verify the server configuration supports both before assuming results appear in both surfaces.
  • Agent mode? agent_mode=True asks the server retrieval agent to do richer query handling. It needs server-side LLM/reranker resources; use ordinary search first for simple lookups.
  • LangGraph tools? Use MemMachineTools or helper factories when an agent runtime expects callable add/search tools. Ensure framework dependencies are installed separately.

Non-goals And Cross-links

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351