Skip to content

feat(bash-py): add OpenAI and LangChain examples#15

Open
mvanhorn wants to merge 1 commit into
supermemoryai:mainfrom
mvanhorn:feat/bash-py-parity-examples
Open

feat(bash-py): add OpenAI and LangChain examples#15
mvanhorn wants to merge 1 commit into
supermemoryai:mainfrom
mvanhorn:feat/bash-py-parity-examples

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented May 10, 2026

Summary

The TypeScript @supermemory/bash package ships three example agents (anthropic-sdk.ts, openai-sdk.ts, vercel-ai-sdk.ts). The Python supermemory_bash package only shipped anthropic_agent.py. This adds two more so the Python coverage matches the TypeScript coverage.

Demo

demo

Why this matters

bash-py exports the same surface as bash (Shell, SupermemoryVolume, TOOL_DESCRIPTION, PathIndex, SessionCache). The asymmetry was in the example directory, not the API. A Python developer surveying the repo today would reasonably conclude Anthropic is the supported path, even though create_bash is provider-agnostic.

Reference points in the repo at HEAD:

  • bash/examples/openai-sdk.ts, bash/examples/anthropic-sdk.ts, bash/examples/vercel-ai-sdk.ts — three TS examples
  • bash-py/examples/anthropic_agent.py — single Python example
  • bash-py/supermemory_bash/__init__.py — exports match the TS index.ts

Changes

  • bash-py/examples/openai_agent.py (105 lines): AsyncOpenAI tool-use loop, max 8 turns. Mirrors bash/examples/openai-sdk.ts — same model default (gpt-4o), same prompt seed, same bash tool name.
  • bash-py/examples/langchain_agent.py (72 lines): LangChain create_agent + @tool wrapper. LangChain is the closest Python analogue to Vercel AI SDK (ergonomic agent framework wrapper).

Both default CONTAINER_TAG=user_42 to match the TS examples, take OPENAI_MODEL and PROMPT from env so they're reconfigurable without code edits, and add no entries to pyproject.tomlopenai and langchain are user-installed via uv run --with, same pattern as the existing anthropic_agent.py.

Testing

  • python3 -m py_compile bash-py/examples/openai_agent.py bash-py/examples/langchain_agent.py — both compile
  • ruff format --check bash-py/examples/ — clean
  • ruff check bash-py/examples/ — clean (I001 import-sort applied during the implementation pass)

The examples themselves aren't run end-to-end here; that requires a SUPERMEMORY_API_KEY + OPENAI_API_KEY pair the local environment doesn't have. The structure mirrors the working anthropic_agent.py.

AI was used for assistance.

The TypeScript bash package ships three runtime examples (anthropic-sdk,
openai-sdk, vercel-ai-sdk). The Python bash-py package only had
anthropic_agent.py. This adds two more so the Python surface matches.

- bash-py/examples/openai_agent.py: AsyncOpenAI tool-use loop, max 8 turns
- bash-py/examples/langchain_agent.py: langchain create_agent + tool wrapper

Both default CONTAINER_TAG=user_42 to match the TS examples, take MODEL
and PROMPT from env, and add no install requirements (deps are user-side
via uv run --with).
@Prasanna721
Copy link
Copy Markdown
Member

@vorflux review this PR

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.

2 participants