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 May 22, 2025
Conversation
…ariable at runtime and not on object creation (the agent/objectmay be alive for few days)
Contributor
There was a problem hiding this comment.
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
approved these changes
May 22, 2025
Contributor
|
Thank you so much for this contribution! All looks good, will merge and will be included in the 0.0.4 release |
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.
The agent/object may be alive for more than a day.