With Kimi K2.6βs powerful coding and agent capabilities, you can quickly build and deploy customized professional agents to independently accomplish work tasks. Here, we use the scenario of industry information organization to demonstrate the process.Documentation Index
Fetch the complete documentation index at: https://platform.kimi.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Break Down the Task
Before building an agent with Kimi K2.6, you can break down the target task, which helps with prompt engineering and tool selection, thus optimizing agent performance. In the context of industry information organization, you might encounter the following tasks:- Search
- Search for company information, latest data, news reports, etc. online
- Analysis
- Filter large amounts of collected information
- Classify and professionally analyze the information
- Integration/Output
- Present analysis results in a visually appealing way (such as csv/png/pdf)
- Generate charts
Select Tools
Tool calls give the Kimi large language model the ability to perform specific actions. The Kimi large language model can engage in conversations and answer questions, which is its βtalkingβ ability. Through tool calls, it also gains the ability to βdoβ things. With tool_calls, the Kimi large language model can help you search the internet, query databases, and even control smart home devices. β from Kimi Official DocsCurrently, Kimi K2.6 offers a series of official tools (click here for the official tool usage documentation), which can be freely integrated into your applications to fulfill various needs.
| Tool Name | Tool Description |
|---|---|
| web-search | Real-time information and internet search tool. Web search is currently charged, please see Web Search Price |
| rethink | Intelligent reasoning tool |
| random-choice | Random selection tool |
| memory | Memory storage and retrieval system tool, supporting persistent storage of conversation history and user preferences |
| excel | Excel and CSV file analysis tool |
| code_runner | Python code execution tool |
| quickjs | Quick JS engine security execution JavaScript code tool |
| date | Date and time processing tool |
| fetch | URL content extraction Markdown formatting tool |
| convert | Unit conversion tool, supporting length, mass, volume, temperature, area, time, energy, pressure, speed, and currency conversions |
| base64 | base64 encoding and decoding tool |
| mew | Random cat meowing and blessing tool |
web-search, code_runner, and rethink tools, which are responsible for searching, running code for plotting, and consolidating/analysing materials, respectively.
Automatic Tool Usage
Note that after importing these tools, Kimi K2.6 will automatically analyze the need, decide whether to use certain tools, and execute them to complete the task. There is no need to specify the tools or their usage in the System Prompt, as this may actually interfere with Kimi K2.6βs autonomous decision-making.Prompt Writing
The System prompt is an initial instruction received by the model before generating a response, and plays a critical role in determining the format, content, and style of the output. To ensure the model completes tasks at a high level, you should provide detailed and clear explanations in the prompt. The more detailed these instructions are, the less the model has to guess, and the better it will understand the task as you expect. Therefore, meticulously crafting and optimizing the system prompt is a very important preparatory step. The official Kimi documentation also provides Best Practices for Prompts.Practical Example
Here is an example of the writing process for this scenario:- Clarify the Business and User
- Just as we did in the βBreak Down the Taskβ section, separate the business flow into steps, define the user persona (such as expertise, terminology tolerance, required format and content, etc.). For the scenario, specify the modelβs βRoleβGoalβAction Priorityβ.
- Constraints and Style
- Language consistency, objectivity, no fabrication, citation standards
- To ensure data authenticity, require detailed source output, which can reduce hallucinations
- Style and structure: article formatting, chart color schemes, and formatting specifications
- You may prescribe brand color schemes, formats, etc.
- Output Structure and Templates
- Provide a fixed framework
- Define βallowed/disallowed actionsβ or βpositive/negative examplesβ, to reduce ambiguity. (For example, βDo not fabricate full URLs; instead, allow providing search keywords as an alternative.β)
- Special Scenarios / Edge Cases
- Provide handling examples for ambiguous questions or forbidden service scenarios, etc.
Usable Prompt Examples in This Scenario
Below is a prompt example ready for direct use, containing the rules and report template. You may further customize it (colors, formatting, language style, information sourcing, etc.) if needed.Getting Started with the Kimi K2.6 API
Install the OpenAI SDK
Environment Setup
Before you start, please make sure to configure your API_KEY as an environment variable:Complete Code Example
Example of Running the Program
Research and Report Writing
After launching the program, we give the following instruction to Kimi K2.6 in the terminal and wait briefly:Frequently Asked Questions (FAQ)
The case code above is just a simple trial that still needs supplementation and improvement, so you may encounter some issues when running it. Solutions to these problems can be found below (continuously updated):- code-runner cyclic invocation errors:
- Save
response.jsonand check if the format is correct. - If the format is correct, focus on the key fields. If you find
"finish_reason"is"length", it means the currentmax_tokensper dialog round is too small (the code currently sets this at 32k; you can adjust it as needed). - If itβs not a length issue, extract the
"code"content from the"arguments", i.e., the original generated code, and try running it. You can also improve code quality through prompt optimization and other means.
- Save
Evaluation and Optimization
By following the steps above, we can already use Kimi K2.6 to effectively complete industry information collation tasks. In more complex scenarios, you can further optimize Kimi K2.6βs performance in the following ways:Use Suitable Tool Calls
In addition to Kimi K2.6βs official tools, you can define and execute custom tools as needed. For example, to query US stock indices, you can design and use a corresponding tool as shown in the example below.Tool Definition
By describing our tool definitions using JSON Schema, we make it clearer and more intuitive for the Kimi K2.6 large model to understand what parameters our tool needs and the type and description of each parameter.get_us_stock_index, describing to the large model its use case and the required parameter symbol (US stock index symbol).
Tool Execution
Next, we need to implement the query function by adding the following function to the original code:Registering the Tool
Additionally, by supplementing the tool registration at the corresponding location, we enable the model to automatically call our newly defined tool: