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
khwan— the client underneath, sync and asynckhwan-mcp— the same memory for any MCP client- docs.khwan.ai
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdd1b0f8f0de6cd53377c6cdc93749240bfcb136b77e05ebf99dc8fc29a7241c
|
|
| MD5 |
0ab08f0525c8f0827e3287dfa630cdba
|
|
| BLAKE2b-256 |
f21140c3efe9ac41260e7dcae60b2776d510169552f282f4b07a346d1f9e7d4f
|
Provenance
The following attestation bundles were made for khwan_crewai-0.1.0.tar.gz:
Publisher:
publish.yml on khwanlabs/khwan-crewai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khwan_crewai-0.1.0.tar.gz -
Subject digest:
bdd1b0f8f0de6cd53377c6cdc93749240bfcb136b77e05ebf99dc8fc29a7241c - Sigstore transparency entry: 2582532037
- Sigstore integration time:
-
Permalink:
khwanlabs/khwan-crewai@60c8fe6a8300ded56f6155f387ba59f145850664 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/khwanlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@60c8fe6a8300ded56f6155f387ba59f145850664 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12b67c0726b550bc3b0f5ff995be7cd5dbe54f8dd8dc5606fa99bab0af451277
|
|
| MD5 |
ab8c1bfe9a86ec9736674aebeb96cfb4
|
|
| BLAKE2b-256 |
18d649353af70267267fa93d905ad64869f9faa0087b9d1305d0c26301524560
|
Provenance
The following attestation bundles were made for khwan_crewai-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on khwanlabs/khwan-crewai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khwan_crewai-0.1.0-py3-none-any.whl -
Subject digest:
12b67c0726b550bc3b0f5ff995be7cd5dbe54f8dd8dc5606fa99bab0af451277 - Sigstore transparency entry: 2582532039
- Sigstore integration time:
-
Permalink:
khwanlabs/khwan-crewai@60c8fe6a8300ded56f6155f387ba59f145850664 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/khwanlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@60c8fe6a8300ded56f6155f387ba59f145850664 -
Trigger Event:
release
-
Statement type: