Skip to main content

Deploy Kimi as a Governed AI Agent

· 4 min read
sa_1d15a3d8c7aaabd0aaa3a5492759daba

Deploy Kimi (Moonshot AI) as a governed production agent on SchemaBounce — 128K–2M context, approval gates, persistent memory, and audit trails. Use Kimi for long-document reasoning and agentic coding, with a runtime that keeps it reliable after handoff.

Deploy Kimi as a Governed AI Agent​

Kimi K2 from Moonshot AI is an open-weight agentic model with 128K–256K context (up to 2M via API) optimized for tool use and coding. Running Kimi alone gives you the model — SchemaBounce gives you the governed harness around it: persistent memory, human-in-the-loop approvals, workspace-scoped data, CDC connectivity, and signed execution receipts. You bring your Kimi API key; SchemaBounce handles hosting, memory, and governance.

If you are already building with Kimi's API (platform.kimi.ai), SchemaBounce replaces the glue code you'd otherwise write for state, approvals, and observability.

Why Kimi + SchemaBounce​

CapabilityKimi API aloneKimi on SchemaBounce
Context window128K (K2), 2M (Kimi long-context API)Same — passed through to model
Memory across runsYou build it (Redis/DB)ADL memory with vector search built-in
Tool approvalsNone — tools execute immediatelyHuman approval gates before external writes
Audit trailYour logsSigned receipts per action
Data freshnessPoll or webhookReal-time CDC from Postgres, MySQL, HubSpot, Salesforce
Multi-agentOrchestrate yourselfDelegation via ADL messages, parent/child receipts
IntegrationsBuild each one100+ MCP servers (GitHub, Stripe, Slack, HubSpot, etc.)

Kimi's strength is long-context reasoning and agentic tool use. SchemaBounce's strength is making that reasoning safe in production.

How It Works​

[Your Kimi Agent Code] → [SchemaBounce ADL] → [Model Provider]
↕ memory/graph/records ↕ approval gate
[CDC Pipelines] [Human Reviewer] → [MCP Tools] → [External Systems]
  1. Agent calls Kimi via your API key (stored workspace-scoped, never shared across tenants).
  2. Agent reads/writes structured records, vector memory, and graph edges in its isolated ADL namespace.
  3. Actions that mutate external systems queue for human approval.
  4. Approved actions execute and produce a signed receipt.

Code: Kimi Agent with ADL Memory and Approvals​

# kimi_governed_agent.py — Kimi K2 on SchemaBounce with memory + approval gate
import os
from openai import OpenAI

# Kimi uses OpenAI-compatible API
client = OpenAI(
api_key=os.environ["KIMI_API_KEY"],
base_url="https://api.moonshot.cn/v1"
)

from schemabounce import ADL, approval_gate

adl = ADL(namespace="kimi-agent")
SYSTEM = """You are a RevOps agent with access to CRM records and long-document context.
Propose CRM updates but never apply them without approval."""

def run_turn(user_msg: str):
memories = adl.memory.search(user_msg, limit=5)
context = "\n".join(m["text"] for m in memories)
account = adl.records.get("companies", "acct_123")
messages = [
{"role": "system", "content": SYSTEM},
{"role": "system", "content": f"Memory:\n{context}\n\nAccount:\n{account}"},
{"role": "user", "content": user_msg},
]
resp = client.chat.completions.create(
model="kimi-k2-0711-preview",
messages=messages,
tools=[{
"type": "function",
"function": {
"name": "propose_crm_update",
"description": "Propose a CRM field update for human approval",
"parameters": {
"type": "object",
"properties": {
"entity": {"type": "string"},
"field": {"type": "string"},
"value": {"type": "string"},
"reason": {"type": "string"}
},
"required": ["entity", "field", "value", "reason"]
}
}
}],
tool_choice="auto",
)
msg = resp.choices[0].message
if msg.tool_calls:
for tc in msg.tool_calls:
receipt = approval_gate.submit(action=tc.function.name, params=tc.function.arguments, adl_namespace=adl.namespace)
adl.memory.add(f"Proposed: {tc.function.arguments} (receipt {receipt.id})")
print(f"Queued for approval: {receipt.id}")
else:
adl.memory.add(f"User: {user_msg}\nAssistant: {msg.content}")
print(msg.content)

run_turn("Review the last 3 call transcripts and propose next steps for Acme Corp.")

When to Choose Kimi​

  • Long documents & transcripts: Use Kimi's 128K–2M window to analyze contracts, call recordings, or codebases in one pass.
  • Agentic coding: K2 is optimized for multi-step tool use and repo-level edits.
  • APAC latency & pricing: Moonshot's China/US endpoints can reduce latency for APAC users vs. US-only providers.

Production Checklist for Kimi Agents​

  • Pin model to an immutable version tag
  • Store KIMI_API_KEY in workspace secrets (not in code)
  • Enable ADL memory TTL and decay policies per namespace
  • Require approval for all write tool calls; allow read without gate
  • Verify receipts (receipt_id) in compliance exports
  • Connect CDC to source of truth (Postgres/HubSpot) so agent never reasons on stale data

FAQ​

Does SchemaBounce host Kimi's weights? No — you call Moonshot's API with your own key. SchemaBounce hosts the agent runtime, memory, approvals, and data layer around the call.

What context length can I use? Whatever your Kimi plan supports (128K for K2, up to 2M on the long-context endpoint).

Can I swap Kimi for another model later? Yes — change model and base_url, no data migration needed.


Ready to run Kimi in production? Request a Production Readiness Report →