Files
AgapHost/openai/cognee-llm/README.md
alvis b27d31b3ca openai: compose healthchecks + dependency ordering, registries, LiteLLM routing
docker-compose.yml gains healthchecks and depends_on/condition chains for the
litellm/langfuse/postgres tier so dependants wait for a genuinely ready
service instead of a started container. Also plumbs AGAP_MCP_TOKEN into the
adolf and adolf-llm containers, sourced from openai/.env (gitignored), for the
kb#180 bearer auth on the agap MCP server; shared-mcp.json consumes it via
bearerTokenEnvVar so the Kimi backbone authenticates too.

agent-registry.yaml / agent_registry.py: the version-controlled source of
truth for agent identities and trust classes -- the same ids the agap-mcp
token map resolves to (`adolf`, `claude-coder`; note `claude-code-cli` is the
runtime entry, not an agent identity).

model-registry.yaml, litellm-config.yaml, auto-router-routes.json and
provision_litellm_keys.py: model tiering, virtual-key provisioning and
auto-router routes. tei-reranker/ is the local reranker service backing
Hindsight recall.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 04:41:31 +00:00

63 lines
3.3 KiB
Markdown

# cognee-llm (:8011)
> ⚠️ **SUPERSEDED — Adolf's memory is migrating Cognee → Hindsight (2026-07-13).**
> Hindsight runs its LLM on LiteLLM `:4000` / Ollama, so this bespoke Kimi-CLI
> wrapper is being **retired**, not ported (SPIKE gate 5 already concluded the
> extraction workload shouldn't sit on the Kimi seat). This service is decommissioned
> in migration task **H4**. Plan: `agap_git/adolf/HINDSIGHT-MIGRATION.md`. The doc
> below describes the outgoing Cognee stack, kept until H4 lands.
OpenAI-compatible wrapper around the Kimi Code CLI (`@moonshot-ai/kimi-code`, home
`/root/.kimi-code`), built for Cognee's batch/structured LLM calls. **Opposite policy to
`kimi-agent`**:
- **Stateless one-shot** — fresh temp dir under `/workspace/<uuid>` per request, `kimi -p
<prompt> --output-format stream-json`, **no `-r`/`-S` resume**, dir removed after every call
(success or failure).
- **Non-streaming** — always returns a full `chat.completion` body, even if the caller sets
`stream: true`.
- **No media, no MCP** — text-only prompt built from `messages`; no image persistence, no
`.mcp.json`.
- **Structured/low-temperature intent via prompt, not a sampling param** — the CLI has no raw
temperature knob (it's an agent loop, not a completions API), so determinism/JSON-only output
is enforced with an instruction preamble prepended to the caller's system prompt.
- **Bounded concurrency** — `MAX_CONCURRENCY = 3` in `server.js`, queued beyond that.
Endpoints: `GET /v1/models` (model id `cognee-llm`), `POST /v1/chat/completions`.
Own disposable in-container `/workspace` (no host bind mount — nothing here is meant to
survive a request, let alone a container restart) + own `cognee-llm-home` volume
(`/root/.kimi-code`), same Kimi subscription as `kimi-agent`/`adolf-llm`, separate volume so
each wrapper's CLI state stays isolated.
## This IS Cognee's LLM backbone
By design, Cognee's LLM runs on the flat Kimi subscription through this wrapper — the whole
reason it exists — mirroring how `adolf-llm` backs the assistant. P4 wires cognee's
`LLM_ENDPOINT` → `http://cognee-llm:8011`, `LLM_MODEL` → `openai/cognee-llm`.
**Accepted tradeoff (SPIKE-FINDINGS gate 5).** The CLI's JSON output is clean/schema-conformant,
but it's slower than a raw API: ~5s fixed per-invocation floor + ~22-24s for a realistic
structured-extraction call, and every call is agentic. Cognify issues one call per
chunk/entity-extraction step, so large batches serialize into minutes. To protect the
single-seat subscription, `MAX_CONCURRENCY = 3` bounds concurrent spawns.
**Documented fallback (not the default):** if cognify throughput ever becomes a real problem,
route cognee's LLM to a LiteLLM model instead (`ARCHITECTURE.md` §3.3) — see the commented block
in `cognee/cognee.env`. Embeddings already run on LiteLLM's `nomic-embed` regardless (embeddings
can't go through the agentic CLI).
## Smoke test
```bash
cd /home/alvis/agap_git/openai
docker build -t cognee-llm:local ./cognee-llm
docker run --rm -d --name cognee-llm-smoke -p 18011:8011 cognee-llm:local
curl -s http://localhost:18011/v1/models
docker rm -f cognee-llm-smoke
```
A full `/v1/chat/completions` round-trip needs a `kimi login`-authed
`/root/.kimi-code` volume (shared Kimi subscription) — not present in a bare smoke container,
so that step is deferred to integration/P4 wiring.