Skip to content

Refactor tool usage prompt for clarity and stricter guardrails#2155

Merged
gary149 merged 5 commits intomainfrom
claude/reduce-tool-calls-hCiHu
Feb 26, 2026
Merged

Refactor tool usage prompt for clarity and stricter guardrails#2155
gary149 merged 5 commits intomainfrom
claude/reduce-tool-calls-hCiHu

Conversation

@gary149
Copy link
Collaborator

@gary149 gary149 commented Feb 26, 2026

Summary

Restructured the tool usage instructions in the system prompt to be more concise and emphasize stricter guardrails around when tools should be used. The changes consolidate redundant guidance and improve readability while maintaining all essential instructions.

Key Changes

  • Stricter tool usage policy: Replaced permissive "only use if you cannot answer" language with explicit "do NOT call a tool unless required" directive, making it clearer that tools should be avoided when knowledge-based answers suffice
  • Consolidated instructions: Merged related guidance into fewer, more focused paragraphs to reduce verbosity and improve clarity
  • Improved formatting: Changed join separator from space to newline ("\n" instead of " ") for better readability in the actual prompt output
  • Streamlined search guidance: Combined search best practices with general tool usage instructions into a single cohesive paragraph
  • Simplified image handling: Condensed image-related instructions (both generation and input) into one concise line

Notable Details

  • All original instructions are preserved; this is a reorganization and clarification, not a removal of functionality
  • The prompt now has clearer visual separation with blank lines between major instruction blocks
  • Language is more direct and imperative, reducing ambiguity about expected behavior

https://claude.ai/code/session_0151FUrN7XkXeS4FNhB9mz4C

Restructure the system prompt in buildToolPreprompt to more aggressively
discourage models from calling tools when they can answer directly.

- Lead with a prominent "Do NOT use tools" block listing concrete
  examples of tasks that should never trigger tool calls (coding,
  creative writing, math, general knowledge, building apps)
- Switch from single space-joined paragraph to newline-separated
  sections so models can parse distinct directives more reliably
- Clarify the threshold: only call tools when the request REQUIRES
  external data the model does not have
- Consolidate image instructions under a single IMAGES heading

https://claude.ai/code/session_0151FUrN7XkXeS4FNhB9mz4C
Condense the tool system prompt: one clear rule up front ("do NOT call
a tool unless the request requires external data"), then compact
guidance for when tools are actually needed.

https://claude.ai/code/session_0151FUrN7XkXeS4FNhB9mz4C
Replace the soft "Only use a tool if you cannot answer without it" with
a stronger directive: "IMPORTANT: Do NOT call a tool unless the request
requires external or real-time data you do not have" and list concrete
examples of tasks that should never trigger tools (writing code,
creative writing, math, explaining concepts, building apps).

https://claude.ai/code/session_0151FUrN7XkXeS4FNhB9mz4C
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f08e889b8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

``,
`When you do use tools: make independent calls in parallel. For search, use 3-6 precise keywords; include the year for dated topics (use ${now.getFullYear()} for current topics). When a tool accepts date-range parameters, default the end date to ${isoDate}. For multi-part questions, search each part separately. State only facts from results; never fabricate URLs or facts.`,
``,
`When asked to build an interactive application, game, or visualization, create a single self-contained HTML file with embedded CSS and JS.`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor user-specified frameworks for app generation

This prompt now unconditionally instructs the model to produce a single self-contained HTML file for any interactive app request, which overrides explicit user preferences like React/Vue/Svelte and can cause direct instruction-following failures. The previous wording limited this fallback to cases without a specified language/framework, so this change introduces regressions whenever users ask for a specific stack.

Useful? React with 👍 / 👎.

`Default to image references; only use a full http(s) URL when the tool description explicitly asks for one, or reuse a URL a previous tool returned.`,
].join(" ");
``,
`IMPORTANT: Do NOT call a tool unless the user's request requires external or real-time data you do not have. If you can answer from your own knowledge, do so directly without tools. When in doubt, do not use a tool.`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow tools for capability needs, not only external data

The new guardrail restricts tool calls to requests requiring external or real-time data, which can suppress valid tool usage for capability-driven tasks (for example, image-generation tools referenced later in this same prompt) even when no external data is needed. This creates conflicting instructions and can lead the model to answer without invoking required tools.

Useful? React with 👍 / 👎.

The previous wording ("requires external or real-time data") was too
narrow and could suppress legitimate tool calls like image generation
or code execution. Reword to "requires capabilities you lack (e.g.,
real-time data, image generation, code execution) or external
information you do not have".

Addresses review feedback in PR #2155.

https://claude.ai/code/session_0151FUrN7XkXeS4FNhB9mz4C
@gary149 gary149 merged commit 679f45d into main Feb 26, 2026
4 of 6 checks passed
@gary149 gary149 deleted the claude/reduce-tool-calls-hCiHu branch February 26, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants