Add timezone support to tool prompts for localized time context#2233
Open
gary149 wants to merge 4 commits intohuggingface:mainfrom
Open
Add timezone support to tool prompts for localized time context#2233gary149 wants to merge 4 commits intohuggingface:mainfrom
gary149 wants to merge 4 commits intohuggingface:mainfrom
Conversation
Add explicit guidance to the system prompt that instructs the model to: - Prefer direct answers over tool calls for simple tasks - Only use tools when genuinely needed - Stop making additional calls when enough info is gathered - Categorize tools (generative vs search) with specific usage rules This addresses the issue where models would make excessive tool calls for simple requests like spelling checks or prompt edits.
Replace complex categorization logic with a single clear instruction: "Only use a tool if you cannot answer without it." This follows Anthropic's recommended approach of using simple, direct instructions rather than elaborate rule systems.
mcpflow prompt adjustment
Send the user's IANA timezone from the browser (via Intl.DateTimeFormat) through the request pipeline so that the MCP tool system prompt includes the current date/time with weekday and the user's timezone location instead of just the date. https://claude.ai/code/session_01HJmFTn6PDGAJaYRwdairXi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds timezone awareness to the tool prompt generation system, allowing AI models to have access to the user's local time and timezone information when deciding whether and how to use tools.
Key Changes
buildToolPreprompt()to accept an optionaltimezoneparameter and include the user's current date/time in their local timezone, along with a timezone identifierlocalsfor downstream userunMcpFlow()to retrieve the user's timezone from locals and pass it to the tool prompt builderImplementation Details
Intl.DateTimeFormat().resolvedOptions().timeZoneand sent with each message requesthttps://claude.ai/code/session_01HJmFTn6PDGAJaYRwdairXi