akseljoonas HF Staff commited on
Commit
3ed5324
·
1 Parent(s): 6d4f619

refactor: append dynamic session context after static system prompt for cache stability

Browse files
agent/context_manager/manager.py CHANGED
@@ -115,13 +115,15 @@ class ContextManager:
115
  hf_user_info = _get_hf_username(hf_token)
116
 
117
  template = Template(template_str)
118
- return template.render(
119
  tools=tool_specs,
120
  num_tools=len(tool_specs),
121
- current_date=current_date,
122
- current_time=current_time,
123
- current_timezone=current_timezone,
124
- hf_user_info=hf_user_info,
 
 
125
  )
126
 
127
  def add_message(self, message: Message, token_count: int = None) -> None:
 
115
  hf_user_info = _get_hf_username(hf_token)
116
 
117
  template = Template(template_str)
118
+ static_prompt = template.render(
119
  tools=tool_specs,
120
  num_tools=len(tool_specs),
121
+ )
122
+ return (
123
+ f"{static_prompt}\n\n"
124
+ f"[Session context: Date={current_date}, Time={current_time}, "
125
+ f"Timezone={current_timezone}, User={hf_user_info}, "
126
+ f"Tools={len(tool_specs)}]"
127
  )
128
 
129
  def add_message(self, message: Message, token_count: int = None) -> None:
agent/prompts/system_prompt_v3.yaml CHANGED
@@ -1,9 +1,6 @@
1
  system_prompt: |
2
  You are Hugging Face Agent, an ML engineering assistant with {{ num_tools }} tools for training, fine-tuning, data processing, inference, and evaluation on the Hugging Face ecosystem.
3
 
4
- _Current Time: **{{ current_date }} {{ current_time }} ({{ current_timezone }})**_
5
- {% if hf_user_info %}_Authenticated as: **{{ hf_user_info }}**_{% endif %}
6
-
7
  Your goal is to complete what the user requested with zero errors. You are fully autonomous — research, validate, implement, and deliver results without asking for unnecessary confirmation.
8
 
9
  # Your knowledge of HF libraries is outdated
 
1
  system_prompt: |
2
  You are Hugging Face Agent, an ML engineering assistant with {{ num_tools }} tools for training, fine-tuning, data processing, inference, and evaluation on the Hugging Face ecosystem.
3
 
 
 
 
4
  Your goal is to complete what the user requested with zero errors. You are fully autonomous — research, validate, implement, and deliver results without asking for unnecessary confirmation.
5
 
6
  # Your knowledge of HF libraries is outdated