Moonshot AI recently released Kosong, a LLM abstraction layer for agent applications, designed to address the maintainability issues of technical stacks when interacting with multiple models and tools. Kosong helps teams avoid hardcoding business logic into a single API by providing a unified message structure, asynchronous tool orchestration, and pluggable chat providers, thereby simplifying the process of building agents. It is the core driving layer of Kimi CLI and provides strong support.

Kosong is a Python library that sits between agent logic and LLM providers. Its public API remains minimal, requiring users to only import necessary modules and types. The modules provided by Kosong define streaming formats, token counting, and encapsulation of tool calls, enabling developers to more easily manage agent applications.
In Kosong, the core integration point is ChatProvider. The Moonshot team demonstrated the provider implementation of Kimi, allowing developers to easily initialize and interact with system prompts, tools, and message history. Messages are represented by the `Messages` class, which supports rich multimodal payloads, ensuring a friendly experience for new users.
Kosong also includes a tool module that facilitates the use of features such as search, code execution, or database calls. Developers can implement tool calls and management by defining tool classes and registering them to a simple toolset. The library provides two main functions: `generate` for single-chat completion, and `step` for agent use of tools. These functions help teams better control tool calls and simplify the process of parameter parsing and result handling.
Notably, Kosong includes a built-in demo agent that runs locally, making it easy for developers to test and showcase features. By setting environment variables and using the command line to start, users can experience the powerful capabilities of Kimi as a chat provider.
Kosong provides the underlying LLM abstraction layer for Moonshot's Kimi CLI, ensuring the flexibility and scalability of agent applications, allowing developers to focus on business logic without worrying about the complexity of the underlying implementation.
github:https://github.com/MoonshotAI/kosong
Key Points:
🌟 Kosong is an LLM abstraction layer released by Moonshot AI, aimed at simplifying the development and maintenance of agent applications.
🔧 It provides a unified message structure and tool orchestration, supporting integration with multiple chat providers.
💻 The built-in demo agent function allows developers to quickly get started and test the powerful capabilities of Kimi CLI.
