LiticaLitica
Docs/Namespaces

Python SDK

Namespaces

A namespace is memory that several agents share. What one agent writes there, the others can read — subject to per-agent grants.

By default an agent's memories are private to it. A namespace is the shared alternative: a scope that multiple agents read and write, each with its own access grant. This is how one agent's learning becomes another agent's context.

Create a namespace

ns = client.create_namespace(
    "team-shared",
    agents=["support-bot", "research-bot"],  # granted read AND write
)
ns.namespace_id   # "ns_..." — use this as the namespace_id in other calls

Creating a namespace with a name that already exists raises LiticaConflictError (409), and the server caps how many agents a namespace can hold.

Access policies

Each namespace has a read_policy and a write_policy, set at creation:

  • “grant” (the default) — only agents with an explicit grant can read or write.
  • “open” — any agent in your tenant can.
# Anyone in the tenant may read, but only granted agents may write:
ns = client.create_namespace(
    "company-facts",
    read_policy="open",
    write_policy="grant",
    agents=["curator-bot"],
)

Manage grants

Grants are per agent, split into read and write, and grant_namespace_agent upserts — calling it again for the same agent updates the existing grant:

# research-bot may read the shared memory but not write to it:
client.grant_namespace_agent(ns.namespace_id, "research-bot", can_write=False)

client.list_namespace_agents(ns.namespace_id)
# [NamespaceAgent(agent_id='curator-bot', can_read=True, can_write=True),
#  NamespaceAgent(agent_id='research-bot', can_read=True, can_write=False)]

client.remove_namespace_agent(ns.namespace_id, "research-bot")   # revoke

Use a namespace

Pass the namespace id per call, or set it once as the client default (see Configuration):

# Two agents, one shared brain:
support = litica.Client(agent_id="support-bot", namespace_id=ns.namespace_id)
research = litica.Client(agent_id="research-bot", namespace_id=ns.namespace_id)

support.add_memory("Customers keep asking for SSO on the Teams plan.")

# After the write lands, research-bot sees it:
hits = research.search_memories("what are customers asking for?")
hits[0].source_agent_id   # "support-bot" — you can see who wrote it

Remember: namespace_id=None passed explicitly means the agent's private scope — it is how you step out of a client-default namespace for one call.

List and delete

for ns in client.list_namespaces():
    print(ns.namespace_id, ns.name, ns.read_policy, ns.write_policy)

client.delete_namespace(ns.namespace_id)

Next steps

  • Inspection — audit who wrote what into a shared namespace, and when.
  • API Reference — full signatures for all six namespace methods.