Moonshot Ai releases Kosong: The Llm Abstraction is a powerful layer Kimi Cli

Modern agentic applications rarely talk to one model or one tool, so how do you keep up with the agile stack when providers, models and tools keep changing every few weeks. Moonson ai's In song Addressed this issue as a background for the LLM application of the agent. Kosong combines messaging architecture, asynchronous tooling and mature chat providers so teams can build agents without hard wiring busing logic into a single APIng. And it is a powerful layer of moonshot's Kimi Cli.
What does Kosong offer?
Kosong is a Python library that sits between Agent Logic and LLM providers. As LLM Abstraction is a layer of modern agent systems and shows example code that uses a Kimi Chat provider and High Level Helper functions generate and step.
The public area of the API is kept small. At the highest level of import kosong.generate, kosong.step and types of results GenerateResult and StepResult. Support modules explain chat_provider, message, toolingagain tooling.simple. These modules include specific broadcast formats, token accounting and tool calls behind one fixed display.
ChatProvider and message model
The main connecting point is this ChatProvider Discharge. The Moonson team demonstrates the provider's use of KIMI in kosong.chat_provider.kimi. A Kimi something is started with base_url, api_key and model name, for example kimi-k2-turbo-preview. This provider is then transferred kosong.generate or kosong.step In collaboration with the program quickly, tools and message history.
Messages are represented by Message Class from kosong.message. In examples, a message is created with a role, such as "user"no content the argument. The type of content It is written as a string or list of content components, which allows the library to provide a library to trigger paid relimodals while maintaining a basic conversational model for new users.
Kosong also revealed the broadcast unit StreamedMessagePart flat out kosong.chat_provider. Provider use releases these components between generations, and the library discards them Message. Optional TokenUsage The structure tracks the tokens to be calculated in a way that contributes to providing a contribution, which is then attached to the elements of the result of logging and monitoring.
Upload, control tool and simpletoolset
Most agent stacks require tools such as search, code execution or data calls. Kosong models this tooling module. The example in the GitHub Repo describes the tool modestly CallableTool2 with the Pydantic parametric model. For example AddTool sets name, description and paramsand performance __call__ to retrieve a ToolOk valid value ToolReturnType.
Instruments registered to SimpleToolset from the kosong.tooling.simple. In the example, a SimpleToolset is established and characterized by AddTool For example using += the operator. This tool has been transferred to kosong.stepnot to enter generate. The tool is responsible for resolving new TOLT calls from the model and routing them to the appropriate Async function, while step controls the orchestita around one conversational opportunity.
generate One shot completion
This page generate A function is an entry point for the completion of a virtual conversation. He provides chat_providera system_prompta specified list of tools, which can be empty, and a history of Message things. Kimi's example shows a small usage pattern where a single user's message is forwarded as history as well tools=[].
generate supports streaming with on_message_part call back. In the GitHub Repo, the research team demonstrates this with a simple explanation output work on each printout StreamedMessagePart. After the broadcast is complete, generate returns a GenerateResult that contains an auxiliary and optional message usage Plot in Token Counts. This pattern allows applications to both display incremental output and work with a clean end-message object.
step with a tool using agents
With the tool using agents, Kosong reveals step work. Example in GIT Repo Shows kosong.step to be called by Kimi supplier, a SimpleToolset which it contains AddToola quick history with a user who teaches the model to call add a tool.
step returns a StepResult. For example print result.message then wait result.tool_results(). This method collects all the tool results generated during the step and returns them to the call. Orchestration of toolkits, including argument arguments in the Pydantic parameter model and conversion to ToolReturnType Results, are handled within Kosong so agent writers do not have to implement their own dispatch loop for each provider.
Built on demo and partnership with Kimi Cli
Kosong Ships with a demo agent that can be run in your area. GIT Readme Depositme Environment Varies KIMI_BASE_URL and KIMI_API_KEYand shows the activation command using uv run python -m kosong kimi --with-bash. This demo uses Kimi as a Chat Provider and displays a terminal agent that can call tools, including shell commands when the option with bash is enabled.
Key taken
- KOSOng is an LLM spin-off from Moonshot AI that includes a messaging architecture, an asynchronous tool and a chat provider of pluggs for agent applications.
- The library exposes a small important API,
generateFor a clear discussion as wellstepwith the tool using agents, supported by the same releaseChatProvider,Message,Tool,ToolsetandSimpleToolset. - Kosong currently ships a
KimiA chat provider that directs the moonson ai API, and explainsChatProviderAn interface so that groups can be connected back to back without changing the logic of the agent. - Tool definitions use Pydanti Parameter models as well
ToolReturnTypeThe results, which allow Kosong to handle the argument of contradiction, validation and swelling of the tools cost internallystep. - KOSONMANGOMER ROonShot's Kimi CLI, provides a basic LLM layer while Kimi Cli focuses on the Command Agent experience that can target Kimi and other backups.
Kosong looks like a pragmatic departure from Moonshot AI, separating by cleaning Agent Logic from LLM and the Bandela Tool back while keeping a small space for a small area for early developers. Focusing on everything that is open ChatProvider, Message and Toolsetgives Kimi Cli and other things a consistent way to unlock models and gain power without rewriting torchestrations. For teams building long-running agent systems, Kosong may be the right type of micro-infrastructure.
Look It's a waste and Documents. Feel free to take a look at ours GitHub page for tutorials, code and notebooks. Also, feel free to follow us Kind of stubborn and don't forget to join ours 100K + ML Subreddit and sign up Our newsletter. Wait! Do you telegraph? Now you can join us by telegraph.
Michal Sutter is a data scientist with a Master of Science in Data Science from the University of PADOVA. With a strong foundation in statistical analysis, machine learning, and data engineering, Mikhali excels at turning complex data into actionable findings.
Follow Marktechpost: Add us as a favorite source on Google.



