Skip to main content

Install

pip install synap-openai-agents

What’s included

FunctionPurpose
create_search_toolAsync function tool that searches Synap memory
create_store_toolAsync function tool that stores a memory in Synap

Quick start

from agents import Agent, FunctionTool, Runner
from synap_openai_agents import create_search_tool, create_store_tool

search_fn = create_search_tool(sdk=sdk, user_id="alice", customer_id="acme")
store_fn = create_store_tool(sdk=sdk, user_id="alice", customer_id="acme")

agent = Agent(
    name="Memory Agent",
    instructions="Use synap_search to recall facts about the user. Use synap_store to remember new information.",
    tools=[
        FunctionTool(search_fn, name_override="synap_search"),
        FunctionTool(store_fn, name_override="synap_store"),
    ],
)

result = await Runner.run(agent, "What do you know about my project deadlines?")
print(result.final_output)

Tool signatures

synap_search(query: str, max_results: int = 5) -> list[dict] Returns a list of memory objects: [{"content": "...", "type": "fact", "confidence": 0.91}, ...] synap_store(content: str, memory_type: str = "fact") -> dict Stores a new memory and returns {"status": "stored", "id": "..."}.

Scoping

Pass customer_id to scope memories to an organization, or omit it for user-only scope:
# User-scoped only
search_fn = create_search_tool(sdk=sdk, user_id="alice")

# Organization-scoped (user sees org memories too)
search_fn = create_search_tool(sdk=sdk, user_id="alice", customer_id="acme-corp")

Next steps

Pydantic AI

Type-safe deps and tools for Pydantic AI agents.

AutoGen

BaseTool implementations for AutoGen agents.