AI Chat (`ai_chat`)
AI Chat (ai_chat)
Section titled “AI Chat (ai_chat)”Send a chat turn to an LLM (Ollama, Anthropic, Google Gemini, or any OpenAI-compatible endpoint) that has access to a restricted set of cks-mcp tools, scoped to a single session.
The LLM can call tools (query_subgraph, evolve_knowledge, …); the
handler executes them server‑side and feeds results back to the LLM
until it produces a final text reply or the iteration cap is hit.
{ "method": "tools/call", "params": { "name": "ai_chat", "arguments": { "session_id": "s1", "prompt": "Summarise the objects in this session." } }}Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
session_id |
yes | Session to scope the chat turn to. Every tool call’s session‑shaped argument is pinned to this value. |
messages |
no | Full conversation so far (Anthropic Messages API shape). If omitted, prompt is used to start a fresh conversation. |
prompt |
no | Shortcut for a new conversation with a single user message. Ignored if messages is non‑empty. |
Response
Section titled “Response”{ "reply": "The session contains 5 objects: ...", "tool_calls": [ { "name": "query_subgraph", "arguments": { "session_id": "s1" }, "result": { "nodes": [...] }, "is_error": false } ], "messages": [ ... ]}messages is the full updated history; pass it back as‑is on the next
turn — the tool is stateless between calls.
Security
Section titled “Security”- Tools that manage the server/runtime itself (
migrate_storage,start_agent, …) are denylisted and can never be called by the LLM. - Every session‑shaped argument is overwritten with the caller’s
session_id— the LLM cannot target a different session.
Limitations
Section titled “Limitations”- Supports tool-calling against Ollama (local, no API key),
Anthropic, Google Gemini (native
generateContent, sothoughtSignatureround-trips correctly on function-calling turns), and any OpenAI-compatible endpoint (OpenAI, Groq, DeepSeek, Together, LM Studio, vLLM, …), all routed through the sharedLLMClient. - Provider is selected via
CKS_LLM_PROVIDER(auto/ollama/anthropic/google/openai_compatible).autoonly ever picks Ollama (if reachable) or Anthropic (ifANTHROPIC_API_KEYis set) —googleandopenai_compatiblemust be selected explicitly, since their model/key/base-URL combination can’t be guessed safely. - Google requires
CKS_GOOGLE_API_KEY(orGOOGLE_API_KEYas a fallback) and reads the model fromCKS_GOOGLE_MODEL(defaultgemini-2.5-flash). - Maximum 8 tool‑calling iterations per turn.