Thinking Tool Use for LLMs: A Practical Guide to Building Multi-Step AI Applications

    This guide explains how modern large language models combine reasoning and tool calling in a single session, and what that means for developers. It breaks down the key design patterns behind thinking-enabled tool use, including a unified dual-mode interface, verifiable task environments, and cost control through mode routing. A practical case study shows how to ship a small click-to-pronounce application quickly, with reusable steps for caching, observability, and gradual rollout. The article also covers evaluation across quality, cost, and stability, plus common pitfalls such as vague tool descriptions, non-idempotent calls, and over-reliance on model-based validation.

    1. Background: From Reasoning to Reasoning While Acting

    Over the past year, LLM progress has concentrated on two dimensions: reasoning depth and the ability to act. In earlier product forms, these two capabilities were separate. With deep thinking mode enabled, a model would only output its reasoning and could not call external tools. With thinking disabled, it could call tools but tended to lose track of the goal in multi-step tasks. A newer generation of models merges the two paths: within a single session, a model can plan first, call tools, and then revise its plan based on the returned results, while still offering switchable pure-thinking and pure-execution modes.

    For developers, this means complex tasks no longer need to be split into a two-stage pipeline where one model thinks and another executes. Take an e-commerce customer service scenario. The traditional approach was to call a reasoning model to generate troubleshooting steps, hand those steps to a model with function-calling ability, and stitch the context together with business code in between. Now the entire loop—reading order status, identifying the anomaly type, and deciding whether to issue a refund—can happen inside one session.

    2. Key Design Patterns of Thinking Tool Use

    Unified Dual-Mode Interface

    The same set of tool descriptions (name, parameter structure, and purpose) works in both modes, so the business side does not need to maintain two prompts and two parsing logics. In practice, it helps to decouple tool registration from mode selection:

    1. TOOLS = [
    2. {"name": "query_order", "description": "Query status by order ID", "parameters": {...}},
    3. {"name": "issue_refund", "description": "Issue a refund for a given order", "parameters": {...}},
    4. ]
    5. def run(user_input, thinking=True):
    6. return client.chat(
    7. model=MODEL_ID,
    8. messages=[{"role": "user", "content": user_input}],
    9. tools=TOOLS,
    10. extra_body={"thinking": {"type": "enabled" if thinking else "disabled"}},
    11. )

    Large-Scale Verifiable Task Environments

    The capability gains come not from simply scaling parameters, but from constructing training tasks that are hard to answer yet easy to verify. Easy to verify means the result can be judged automatically by a program—for example, whether code passes unit tests, whether table values match, or whether a file structure satisfies constraints. Public industry practice typically involves thousands of interactive environments and tens of thousands of complex instructions, covering retrieval, calculation, file operations, and multi-turn tool chaining. When building your own evaluations, you can borrow this approach directly: write the validation script first, then write the task description.

    Generalization and Cost Control

    Because the same model consumes very different amounts of resources in the two modes, it is worth doing policy routing at the gateway layer. Short tasks such as intent recognition and format conversion should use non-thinking mode. Tasks that involve multi-step dependencies or require backtracking should enable thinking mode, with an upper limit on thinking length to prevent runaway cost on a single request.

    3. Case Study: Shipping a Micro App Fast with an AI Coding Tool

    In the original practice, the author started an “extreme budget” development experiment with a very low account balance. The goal was to add a click-to-read feature to a popular literacy newsletter for children, so that tapping a Chinese character or word card would play its pronunciation. A usable version was produced within hours, though the actual time exceeded expectations. Most of the cost went into repeated debugging and organizing assets rather than model calls.

    The reusable implementation path is as follows:

    1. Lock down requirements: define the input (images or pre-laid-out word cards), the output (tap to play audio), and the scope of offline availability.
    2. Choose the stack: the frontend handles tap-region detection and audio playback; the backend provides server-side speech synthesis and caching; audio files go to object storage, and a message queue smooths out task spikes.
    3. Cache first: synthesize the audio for a given character only once, name it by a hash of the text, and return the cached result on a hit, which can bring repeated calls close to zero.
    4. Observability: connect logging and monitoring with alerts, and track three core metrics—synthesis failure rate, first-character latency, and cache hit rate.
    5. Gradual rollout: open access to a small set of users first, observe real tap hotspots, and then decide whether to expand the vocabulary.

    Illustrative caching logic:

    1. def speak(text):
    2. key = hashlib.md5(text.encode()).hexdigest()
    3. if cache.exists(key):
    4. return cache.url(key)
    5. audio = tts(text)
    6. cache.put(key, audio)
    7. return cache.url(key)

    4. Evaluation and Common Pitfalls

    Evaluation should look at three lines at once: quality, cost, and stability. For quality, keep a fixed evaluation set covering math, code, general Q&A, and tool calling, and record the total tokens consumed to complete tasks, because “correct but extremely verbose” counts as a failure in production. For cost, watch the average number of calls per task and the cache hit rate. For stability, watch the validity rate of tool-call parameters and the timeout-retry strategy.

    Common pitfalls include: tool descriptions that are too vague and cause wrong calls; enabling thinking mode across the board and driving up costs; missing idempotency so that repeated calls produce side effects (such as duplicate refunds); and handing all validation logic to the model while ignoring programmatic assertions.

    5. Summary

    Folding thinking into tool calling merges reasoning and execution into one chain. Combined with the “hard to answer, easy to verify” task synthesis method, this significantly improves generalization on multi-step tasks. For developers, the real payoff comes from three things: a unified interface that lowers maintenance cost, dual-mode routing that controls budget, and caching plus observability that protect the production experience. If you are running this kind of application on Baidu AI Cloud general capabilities (such as object storage, message queue, logging, and monitoring with alerts), make validation and caching solid first, then gradually loosen the model’s capability boundaries.