Skip to content

fix - in FileSurfer & CoderAgent, make sure to replace the datetime variable in prompts at runtime and not on object creation #75

Merged
husseinmozannar merged 2 commits intomicrosoft:mainfrom
ksachdeva:fix-date-in-prompt
May 22, 2025
Merged

fix - in FileSurfer & CoderAgent, make sure to replace the datetime variable in prompts at runtime and not on object creation #75
husseinmozannar merged 2 commits intomicrosoft:mainfrom
ksachdeva:fix-date-in-prompt

Conversation

@ksachdeva
Copy link
Copy Markdown
Contributor

The agent/object may be alive for more than a day.

ksachdeva added 2 commits May 22, 2025 09:00
…ariable at runtime and not on object creation (the agent/objectmay be alive for few days)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue of using a stale datetime in prompts by dynamically computing the current date at runtime in both the FileSurfer and CoderAgent classes.

  • In FileSurfer, the static date initialization is removed and the prompt is built at runtime.
  • In CoderAgent, the system prompt is now generated at runtime to avoid outdated dates.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/magentic_ui/agents/file_surfer/_file_surfer.py Removed static datetime and now computes date in monitor_pause
src/magentic_ui/agents/_coder.py Replaced static prompt with a runtime datetime value
Comments suppressed due to low confidence (2)

src/magentic_ui/agents/file_surfer/_file_surfer.py:270

  • [nitpick] Consider extracting the repeated datetime computation (datetime.now().strftime("%Y-%m-%d")) into a helper method to reduce duplication and improve maintainability.
system_prompt_file_surfer = self.system_prompt_file_surfer_template.format(date_today=datetime.now().strftime("%Y-%m-%d"))

src/magentic_ui/agents/_coder.py:490

  • [nitpick] Consider consolidating the datetime string formatting into a common helper function to avoid redundancy between agent implementations.
system_prompt_coder = self.system_prompt_coder_template.format(date_today=datetime.now().strftime("%Y-%m-%d"))

@husseinmozannar
Copy link
Copy Markdown
Contributor

Thank you so much for this contribution! All looks good, will merge and will be included in the 0.0.4 release

@husseinmozannar husseinmozannar merged commit 54fbef4 into microsoft:main May 22, 2025
9 checks passed
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.

3 participants