Prompt Design and Tool-Calling Practices for Enterprise Main Agents
This article examines how to design system prompts for a main agent that coordinates multiple tools in enterprise environments. It covers role and goal definition, a four-step reasoning loop, query classification, planning, execution feedback, sub-agent dispatch rules, delegation instructions, answer formatting, internal tool usage, parallel tool calls, core operating rules, and rollout recommendations. Readers gain practical prompt patterns for improving tool selection accuracy, traceability, and compliance in complex enterprise workflows.
1. Why Prompt Design for the Main Agent Matters
As large model applications move from single-turn Q&A to multi-tool collaboration, the system prompt is no longer just a role description. It becomes a set of orchestration rules. The main agent is responsible for understanding user intent, decomposing tasks, selecting tools, and consolidating results. Clear prompts significantly improve system stability on complex tasks. When prompts are vague, common problems include repeated calls to the same tool, sub-tasks overwriting each other’s results, and forced conclusions when information is insufficient.
Enterprise scenarios add another layer of constraints. Internal systems such as knowledge bases, ticketing, approvals, and data queries usually involve permissions and auditing. Call order and parameters must be traceable. Therefore, prompts need to address efficiency, accuracy, and compliance at the same time.
2. Role and Goals of the Main Agent
The main agent’s goals can be summarized in three points:
- Accurately understand the real need behind the user’s question.
- Obtain sufficient evidence with the fewest tool calls.
- Produce verifiable conclusions in a consistent format.
The role definition should include capability boundaries. For example, it can state: “Answer internal enterprise questions only based on content returned by tools, and explain the gap when evidence is insufficient.” This type of statement constrains model behavior better than “You are a professional assistant” because it specifies what the model should do under uncertainty.
3. The Four-Step Reasoning Loop
The main agent’s request handling process can be divided into four steps: assessment and decomposition, query category determination, plan creation, and execution and feedback. The output of each step should serve as the input to the next, making the entire process inspectable.
3.1 Assessment and Decomposition
After receiving a request, the main agent first determines whether the question can be answered directly. If it involves real-time data, internal documents, or multi-step operations, it needs to be decomposed into sub-questions. Decomposition should follow two principles: the input and output of each sub-question are clear, and dependencies between sub-questions are explicitly stated.
Example: A user asks, “What were the top three categories by return rate in the East China region last quarter, and why?” This can be decomposed into three steps:
- Query return details for each category in the East China region last quarter.
- Calculate return rates and rank them.
- Retrieve return reason records for the top three categories.
The third step depends on the results of the first two steps and must be executed serially.
3.2 Query Category Determination
The category determines the subsequent processing path. Common categories include:
- Fact lookup: The answer is in a single data source and can be obtained with one retrieval.
- Analysis and computation: Multiple data sources are needed, and aggregation or reasoning is required.
- Operational request: The request changes system state, such as submission, modification, or approval.
- Chit-chat or general knowledge: No tool call is needed.
Operational requests must be marked separately and require user confirmation before execution. This is the most direct way to reduce the risk of unintended operations.
3.3 Plan Creation Based on Category
A plan should include the goal, required tools, call order, completion criteria for each step, and a fallback strategy for failures. The plan does not need to be lengthy, but it must be checkable item by item.
plan = {"category": "analysis","steps": [{"id": 1, "tool": "data_query", "goal": "Get regional return details", "done_when": "returned row count is greater than 0"},{"id": 2, "tool": "compute", "depends_on": [1], "goal": "Calculate return rates and rank them"},{"id": 3, "tool": "kb_search", "depends_on": [2], "goal": "Retrieve category return reasons"}],"on_failure": "Return the completed portion and explain the missing items"}
3.4 Execution and Feedback
After each tool call returns, the main agent should check the result. If the result is empty, malformed, or clearly inconsistent with expectations, it should first correct the parameters or switch to an alternative source before deciding whether to continue. When consecutive failures reach a configured threshold, it should stop calling tools and explain the situation to the user. This prevents the model from repeatedly probing based on incorrect results, wasting quota, and producing misleading conclusions.
4. Rules for Deciding the Number of Sub-Agents
Multiple sub-agents can improve parallelism, but they also increase coordination cost and context overhead. To decide whether to dispatch sub-agents and how many to dispatch, consider three dimensions:
- Whether sub-tasks are independent. Independent tasks are suitable for parallel dispatch. Tasks with dependencies should be executed serially or merged.
- The context size of a single sub-task. If a sub-task requires more material than a reasonable single context can hold, it should be split out and handled separately.
- The complexity of result consolidation. The more sub-agents there are, the more complex the main agent’s merge logic becomes, and the higher the probability of errors.
A practical principle is: do not dispatch sub-agents for simple queries; for tasks requiring two or three independent data sources, dispatch the same number of sub-agents; beyond that scale, first check whether the task decomposition is too granular.
5. Writing Delegation Instructions
When dispatching a sub-task, the instruction should include five elements: task goal, input context, constraints such as time range and data definitions, output format, and completion criteria. If any item is missing, the sub-agent may make its own assumptions, making the results difficult to merge.
task: Calculate the return rate by category for the East China region in Q3 2026scope: Use only the sales data table; exclude test ordersoutput: JSON with fields category, return_rate, sample_sizedone_when: Cover all active categories, and each category has a sample size of at least 100
The more specific the constraints in the instruction, the easier it is to merge the sub-agent’s output directly. In contrast, expressions such as “help me check the return situation” make it impossible to unify the definitions and granularity of the results.
6. Answer Format Constraints
The answer format should serve the reader. A common approach is to give the conclusion first, then the evidence, and finally list data sources and uncovered scope. Internal enterprise questions especially need source annotations so users can trace and verify the information.
Format rules can specify the following:
- The number of decimal places and units for numerical values.
- Conditions for using tables and lists, for example, using a table only when comparing more than three dimensions.
- How to phrase insufficient evidence, for example, “The available materials do not include this information.”
- Do not present speculation as fact.
7. Guidance for Using Internal Enterprise Tools
Internal tools usually come with permission, quota, and audit requirements. The prompt should clearly state the following four points:
- Applicable and inapplicable scenarios. Specify what each tool is good at and what it should not be used for, to avoid selecting the wrong tool.
- Parameter sources. Key fields such as order IDs and employee IDs must come from user input or prior tool returns. Guessing is prohibited.
- Sensitive data handling. Fields such as phone numbers and ID numbers should be masked according to rules, and only masked content should be returned.
- Write operation flow. Any modification-type call must first show the proposed change and execute only after user confirmation.
The quality of tool descriptions directly affects selection accuracy. Each tool description can include its name, purpose, input parameters, return structure, and usage limits.
tool: order_lookuppurpose: Query order status by order IDinputs: order_id (string, required)returns: status, updated_atlimits: Read-only; modifications are not supported; returns at most one record per call
8. Parallel Tool Calls
When multiple tool calls have no dependencies, they can be initiated at the same time to reduce total waiting time. The prompt should specify which cases can be parallelized, which must be serialized, and the maximum concurrency.
The criterion is straightforward: if call B needs the return value of call A, the two must be serialized; otherwise, they can be parallelized. After parallel results return, the main agent needs to merge them in plan order and check whether any branch failed. If a branch fails, the missing part should be marked rather than silently ignored.
9. Core Rules
- Answer only based on verifiable information, and clearly state when information is insufficient.
- Write operations must be confirmed by the user before execution.
- Check parameter completeness before calling a tool, and do not guess key fields.
- Avoid repeated calls with the same parameters.
- Mask sensitive information according to rules before output.
- On failure, explain the completed portion and the missing portion.
- Follow a consistent output format and annotate data sources.
10. Implementation Recommendations
- First validate the prompt with a set of representative questions. Record tool selection error rates, parameter error rates, and repeated call counts, then gradually expand coverage.
- Prompts need version management. Every change should include corresponding test cases for regression comparison.
- Compliance requirements should not rely on prompts alone. Permission checks, audit logs, and write-operation approvals should be implemented at the system layer. The prompt is only responsible for guiding the model to follow these processes.
