advisor tool. The lightweight executor can handle routine tool calls and consult the advisor when it encounters a difficult debugging or design problem.
Implement the client-side advisor tool
This example builds on the tool-calling workflow, usingkimi-k2.6 as the executor model and kimi-k3.1-pro as the advisor model. Set your API key in the MOONSHOT_API_KEY environment variable before running the code:
Call the advisor in your tool-calling loop
PassADVISOR_TOOL alongside your application’s existing tool definitions (business_tools) to the executor model, and dispatch each call by tool name inside the loop:
Frequently asked questions
How do I cap advisor calls and avoid triggering them too often?
How do I cap advisor calls and avoid triggering them too often?
Maintain a client-side counter to cap consultations per task, for example, by setting the limit to one or two
consult_advisor() calls per task, so the executor does not make a high-cost advisor request at every step.When the cap is reached or an advisor request fails, do not raise an exception that aborts the main loop. Instead, append a regular tool message to messages (such as "Advisor call limit reached; continue with the existing tool results") so the executor can proceed with the information it already has.Why strip the executor's reasoning_content before calling the advisor model?
Why strip the executor's reasoning_content before calling the advisor model?
The executor’s
reasoning_content preserves reasoning continuity across multi-step tool calls and must be retained unchanged in the executor’s messages list (see Thinking Models).When sending a standalone request to the advisor model, the advisor only needs the conversation history and results from completed tool calls. Stripping reasoning_content reduces input tokens for the advisor request and prevents unverified intermediate reasoning from biasing the advisor.