Context
Designing tool signatures.
Problem
Too many required parameters increases cognitive load and error potential.
Solution
Provide intelligent defaults:
- Context-aware: Use current user, time, etc.
- Common case: Default to most frequent value
- Documented: Explain what default means
- Overridable: Allow explicit override
- Context-aware: Use current user, time, etc.
- Common case: Default to most frequent value
- Documented: Explain what default means
- Overridable: Allow explicit override
Examples
Python
@tool
def search_emails(
query: str,
folder: str = "inbox", # Common case
max_results: int = 20, # Reasonable limit
include_attachments: bool = False # Performance default
) -> list[Email]:
"""Search emails. Defaults to inbox, 20 results.""" TypeScript
const searchEmails = tool({
parameters: z.object({
query: z.string(),
folder: z.string().default("inbox"),
maxResults: z.number().default(20),
includeAttachments: z.boolean().default(false)
})
}); Considerations
- Document defaults in the description
- Use context (current user) when available
- Don't default destructive options to true
- Proactively select sensible defaults during runtime. For example, in a `create_task` tool, when the upstream API requires a project ID, we can check whether the user has a default project set or only one existing project, and set its ID by default. This way, the `project_id` parameter can be optional and set to `null` in the tool interface.