Langchain pass current timestamp to agent prompt

I have a web app which receives user input request in the controller endpoint. It then constructs and sends the message to the deepagent:

async for step in current_app.agent.astream(
    {"messages": [{"role": "user", "content": message}], "timestamp": datetime.now()},
    stream_mode="values", # Use this to stream all values in the state after each step.
    config = config, # This is needed by Checkpointer
):
    result.append(step["messages"][-1])

The problem I am facing is that since the edit_file is so unreliable ( `edit_file` crashes · Issue #728 · langchain-ai/deepagents · GitHub ), I am thinking of creating a new file with the path name ending with the request current timestamp for the app to work. How should I structure my prompt so that the agent is able to get the timestamp? Is this even possible? For example, I am thinking about the following prompt:

WORKFLOW_INSTRUCTIONS = """You are a helpful question-answering assistant. For context, The current timestamp is {timestamp}.

**Save the request**: Use write_file() to save the user's question to `/user_questions_{timestamp:%d-%m-%Y_%H-%M-%S}.md`
**Write Report**: Write final report to `/final_answer_{timestamp:%d-%m-%Y_%H-%M-%S}.md`

The timestamp has to be consistent in the full turn of the request as the agent might decide to edit the file later in the logic and the corresponding `/final_answers_{timestamp:%d-%m-%Y_%H-%M-%S}.md` has to match the timestamp.

You can write your own FILESYSTEM_SYSTEM_PROMPT and pass that to middleware.
Perhaps you can use something like this:

CUSTOM_FILESYSTEM_PROMPT = """
## Filesystem Tools: `ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`

You have access to a filesystem which you can interact with using these tools.
All file paths must start with a /.

- ls: list files in a directory (requires absolute path)
- read_file: read a file from the filesystem
- write_file: write to a file in the filesystem
  - When using `write_file`, make sure `file_path` always is `/final_answer_<current_time>`
- edit_file: edit a file in the filesystem
  - When using `edit_file`, make sure `file_path` always is `/final_answer_<current_time>`
- glob: find files matching a pattern (e.g., "**/*.py")
- grep: search for text within files

## Execute Tool: `execute`

You have access to an `execute` tool for running shell commands in a sandboxed environment.
Use this tool to run commands, scripts, tests, builds, and other shell operations.

- execute: run a shell command in the sandbox (returns output and exit code)

Current-Time: {timestamp}
"""

And then when starting the middleware, you can pass the timestamp that you get from your controller:

FilesystemMiddleware(system_prompt=CUSTOM_FILESYSTEM_PROMPT.format(timestamp))

Note: I placed Current-Timestamp at the end to ensure you benefit from prompt caching.