Skip to main content

khwan-crewai

Memory for a CrewAI crew that outlives the run. Plugs Khwan — a pure AI-memory layer — into CrewAI as tools and as a wrapper around a crew run.

Khwan never runs your model. The crew's model is the "your model" step:

prepare()  ──►  recall memory + constitution     (no LLM)
   [ the crew runs ]                             ← Khwan never touches it
record()   ──►  persist what was actually said
pip install khwan-crewai

Two halves, and you want both

Tools let an agent look something up when it decides to. The loop runs whether it decided to or not — and that is what the next session recalls.

The loop — where memory accumulates

from khwan_crewai import KhwanMemory

async with KhwanMemory(api_key="kwk_live_xxx", core="acme") as mem:
    turn   = await mem.prepare(user_input)
    result = await crew.kickoff_async(inputs={
        "memory":   mem.seed_text(turn),   # "" when nothing is known
        "question": user_input,
    })
    await mem.record(turn, str(result))

It wraps the crew rather than living inside it, because what is worth keeping is the answer that actually went out — not every intermediate step an agent took to get there.

Tools — what an agent reaches for mid-task

from crewai import Agent
from khwan_crewai import khwan_tools

agent = Agent(
    role="Analyst",
    tools=khwan_tools(api_key="kwk_live_xxx", core="acme"),
    ...
)
Tool What it does
khwan_recall(query) standing rules + past exchanges on a topic
khwan_remember(fact) keep a decision or preference for future runs
khwan_verify(draft) check a draft against memory before it ships

Everything fails open

Memory that is down must never stop an answer. A failed prepare means the crew runs without recall; a failed record means the turn is not learned; a tool that cannot reach Khwan returns a sentence saying so rather than raising, because a raising tool aborts the agent's step. All of it logs at warning, so an outage is visible rather than silent.

An empty recall is an answer

Retrieval applies a relevance floor, so no results means the brain holds nothing close to this question — not that something went wrong. khwan_recall says so in words the agent can repeat, and seed_text returns "", which interpolates into a prompt harmlessly.

Isolation

One account holds many cores (separate brains), and each core can hold a sub-brain per end-user — a complete separate brain that does not spend one of your cores. A client with several projects is usually one core with a sub-brain each:

KhwanMemory(api_key=..., core="acme", user_id="Web")   # account::acme::@Web
KhwanMemory(api_key=..., core="acme", user_id="Api")   # shares nothing with @Web

Cores must exist before you point at one — create them in the dashboard. Sub-brains are created on first write.

Configuration

Argument Required Purpose
api_key yes From the dashboard (kwk_live_…). Not your model provider's key.
core no Which isolated brain (default: the account's default core).
user_id no Sub-brain within that core (paid plans).
base_url no Override the API base, e.g. a local engine.

Releasing

Publishing runs from a GitHub Release over PyPI's Trusted Publishing — OIDC, so there is no API token in the repository, in a secret, or anywhere to rotate.

One-time setup on PyPI: the project's Publishing settings, add a GitHub publisher for khwanlabs/khwan-crewai, workflow publish.yml, environment pypi. A name that has never been published is added the same way, as a pending publisher.

Then a release is a tag and a click; the workflow runs the tests first and refuses to publish something that does not pass them.

Related

Source

github.com/khwanlabs/khwan-crewai — this sits between your crew and its memory and runs with your key. Read it before you install it.

License

MIT — © Khwan Labs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

khwan_crewai-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

khwan_crewai-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file khwan_crewai-0.1.0.tar.gz.

File metadata

  • Download URL: khwan_crewai-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for khwan_crewai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdd1b0f8f0de6cd53377c6cdc93749240bfcb136b77e05ebf99dc8fc29a7241c
MD5 0ab08f0525c8f0827e3287dfa630cdba
BLAKE2b-256 f21140c3efe9ac41260e7dcae60b2776d510169552f282f4b07a346d1f9e7d4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for khwan_crewai-0.1.0.tar.gz:

Publisher: publish.yml on khwanlabs/khwan-crewai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file khwan_crewai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: khwan_crewai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for khwan_crewai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12b67c0726b550bc3b0f5ff995be7cd5dbe54f8dd8dc5606fa99bab0af451277
MD5 ab8c1bfe9a86ec9736674aebeb96cfb4
BLAKE2b-256 18d649353af70267267fa93d905ad64869f9faa0087b9d1305d0c26301524560

See more details on using hashes here.

Provenance

The following attestation bundles were made for khwan_crewai-0.1.0-py3-none-any.whl:

Publisher: publish.yml on khwanlabs/khwan-crewai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page