fix: drop past-memory directive and placeholder from agent prompts when memory is empty (#572)
This commit is contained in:
5 files changed
+51
-16
No files matched your search
@@ -20,8 +20,12 @@ def create_trader(llm, memory):
|
||||
if past_memories:
|
||||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
else:
|
||||
past_memory_str = "No past memories found."
|
||||
|
||||
memory_instruction = (
|
||||
f" Apply lessons from past decisions to strengthen your analysis. Here are reflections from similar situations you traded in and the lessons learned: {past_memory_str.strip()}"
|
||||
if past_memories
|
||||
else ""
|
||||
)
|
||||
|
||||
context = {
|
||||
"role": "user",
|
||||
@@ -31,7 +35,7 @@ def create_trader(llm, memory):
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"""You are a trading agent analyzing market data to make investment decisions. Based on your analysis, provide a specific recommendation to buy, sell, or hold. End with a firm decision and always conclude your response with 'FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**' to confirm your recommendation. Apply lessons from past decisions to strengthen your analysis. Here are reflections from similar situations you traded in and the lessons learned: {past_memory_str}""",
|
||||
"content": f"You are a trading agent analyzing market data to make investment decisions. Based on your analysis, provide a specific recommendation to buy, sell, or hold. End with a firm decision and always conclude your response with 'FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**' to confirm your recommendation.{memory_instruction}",
|
||||
},
|
||||
context,
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user