moonkoog

moonkoog — a MoonBit port of JetBrains Koog (1.1.1): a type-safe agent-orchestration framework. The prompt/message model, LLM client contract, tool registry with a JSON-schema descriptor model, and the AIAgent tool-calling loop (Koog's singleRunStrategy), built to compose with the moon-heke full-stack suite.

koog
agent
llm
tool-calling
moonbit
moon add Lfan-ke/moonkoog@0.2.0
Download zip
Author
Version
0.2.0
License
Apache-2.0
Last updated
11 days ago
Downloads
5

Dependencies

README

#moonkoog

A MoonBit port of JetBrains Koog — a type-safe agent-orchestration framework.

Check and Test License

Koog is a Kotlin framework for building LLM agents: a prompt/message model, an LLM-client contract, a tool registry, and an AIAgent that drives the tool-calling loop. moonkoog transcribes it to MoonBit feature by feature, anchored to Koog's 1.1.1 release. Where Kotlin leans on reflection (deriving a tool's JSON schema from its argument type via kotlinx.serialization + a TypeToken), MoonBit has none, so a tool states its schema through an explicit descriptor — the same approach moonapi and moonctl take. It is part of the moon-heke full-stack suite and composes with it: an agent serves over moonapi/mooncat, streams tokens over moonasgi SSE, and checkpoints to moonorm.

#What works today

The core loop, end to end. An AIAgent sends a prompt with the tools it may call, runs whatever tools the model asks for, feeds the results back, and repeats until the model answers in plain text — Koog's singleRunStrategy, bounded by maxIterations.

// A tool: name + JSON-schema descriptor, and a body that runs on decoded args.
struct Add {}
impl @tools.Tool for Add with descriptor(_) {
{
name: "add",
description: "add two integers a and b",
required_parameters: [
{ name: "a", description: "first", ptype: @tools.TInteger },
{ name: "b", description: "second", ptype: @tools.TInteger },
],
optional_parameters: [],
}
}
impl @tools.Tool for Add with execute_raw(_, args) { /* a + b */ ... }

// An agent over any LLM client (a scripted MockClient in tests; the real
// DeepSeek/OpenAI-compatible client rides moonllm — see the roadmap).
let agent = @agent.AIAgent::new(
client,
model=@llm.deepseek_v4_flash,
tool_registry=@tools.ToolRegistry::new().add(Add::{}),
)
let answer = agent.run("what is 2 + 3?") // -> the model's final text

#The chain

Koog concernKoog module (1.1.1)moonkoog
Message / Prompt / PromptBuilderprompt-modelprompt/
LLModel / LLMProvider / LLMCapabilityprompt-llmllm/
Tool / ToolDescriptor / ToolRegistryagents-toolstools/
LLMClient contract, AIAgent, singleRunStrategyprompt-executor-clients, agents-coreagent/

The LLM client is a pub(open) trait — bring your own. A scripted MockClient ships for deterministic tests; the real transport reuses DC-Z-lab/moonllm (native moonbitlang/async + TLS + SSE + tool-calling) behind moonkoog's own client interface.

#Roadmap

Transcription tracks Koog 1.1.1 module by module. Landed: the prompt model, the model catalog, the tool/registry model, and the AIAgent tool-calling loop. Next: the strategy-graph DSL (nodes/edges/subgraphs/parallel), structured output, streaming, multi-provider executors, memory and persistence, features, and the a2a / rag / MCP layers — plus the moon-heke integration (serving, checkpointing).

#Build

$ moon check --target all --deny-warn $ moon test --target all # pure packages on every backend; the agent loop on native

#License

Apache-2.0.