Skip to content

bug?: Issue with History and System Prompt Func #885

@YanSte

Description

@YanSte

Hi,

I’m encountering a bug? while trying to set history.
I’m not sure if I’m implementing it correctly, but here’s the code.

Example:

# The idea:
# Agent A - Shared History
#                 |
#                 |
#                 |
# Agent B - Shared History
#                 |
#                 |
#                 |
# Agent C - Shared History

agentA = ...(...) 
@agentA.system_prompt
def base() -> str:
    return  "A1"

result = agentA.run(..., message_history=[])
history = result.new_messages() 
# In exe the System promt is "A1" ✅

agentB = ...(...) 
@agentB.system_prompt
def base(ctx: GraphRunContext[..]) -> str:
    return  "B2"  + ctx.depsresult = agentB.run(..., message_history=history)
history = agentB.new_messages()
# In exe the System promt is "A1" --> Need to be "B2" + ctx + previous history ❌

agentC = ...(...) 
@agentC.system_prompt
def base(ctx: GraphRunContext[..]) -> str:
    return  "C3"   + ctx.depsresult = agentC.run(..., message_history=history)
history = agentC.new_messages()
# In exe the System promt is "A1" --> Need to be "C3" + ctx + previous history ❌

The issue is that a new message is being injected from the previous agent to continue the story, along with a new agent. However, the system prompt being used is from the first agent rather than the current one.

Could you take a look and let me know if I’m on the right track or if I’m missing something?
Or do I need to inject in the system prompt ?

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions