Version: 0.5.0 for all components
Hey,
I am not sure whether this is a bug or itended behavior and I am not using the SystemPrompInputProcessor correctly.
I need to add system prompts dynamically to an agent, depending on from which tenant the request comes from. Thus I create the instructions dynamically and feed them into the SystemPrompInputProcessor when creating the agent like this:
return new Agent(
platform: $this->platform,
model: $this->modelName,
inputProcessors: [
$this->agentProcessor, // Register tools with platform
new SystemPromptInputProcessor($instruction, $this->toolbox), // Add custom prompt + tool descriptions
],
outputProcessors: [
$this->agentProcessor, // Execute tool calls
],
name: 'tenant_agent',
);
What I expected was that the SystemPromptInputProcessor adds the system prompt to the message bag if there is none present when processing the input (keeping the same message bag) and passing this on.
However, due to the fact that the message bag gets cloned by the call $input->setMessageBag($messages->withSystemMessage(Message::forSystem($message))); in line 88 in the SystemPrompInputProcessor (this eventually calls withoutSystemMessage in the MessageBag), the message bag object that I passed to agent->call() is not being modified by the other processors. In particular the AgentProcessor adds the toolcall messages into the cloned message bag object, making it impossible for me to retrieve these messages.
Expected: SystemPromptInputProcessor processes the message bag and passes it on, without cloning
Actual: SystemPromptInputProcessor clones the message bag and passes on the cloned bag
As I said, maybe this is itended behavior and I am not using the SystemInputProcessor correctly. I would appreciate some feedback on the issue and a recommendation on how to do this otherwise :)
Thanks!
Version: 0.5.0 for all components
Hey,
I am not sure whether this is a bug or itended behavior and I am not using the
SystemPrompInputProcessorcorrectly.I need to add system prompts dynamically to an agent, depending on from which tenant the request comes from. Thus I create the instructions dynamically and feed them into the
SystemPrompInputProcessorwhen creating the agent like this:What I expected was that the
SystemPromptInputProcessoradds the system prompt to the message bag if there is none present when processing the input (keeping the same message bag) and passing this on.However, due to the fact that the message bag gets cloned by the call
$input->setMessageBag($messages->withSystemMessage(Message::forSystem($message)));in line 88 in theSystemPrompInputProcessor(this eventually callswithoutSystemMessagein theMessageBag), the message bag object that I passed toagent->call()is not being modified by the other processors. In particular the AgentProcessor adds the toolcall messages into the cloned message bag object, making it impossible for me to retrieve these messages.Expected:
SystemPromptInputProcessorprocesses the message bag and passes it on, without cloningActual:
SystemPromptInputProcessorclones the message bag and passes on the cloned bagAs I said, maybe this is itended behavior and I am not using the SystemInputProcessor correctly. I would appreciate some feedback on the issue and a recommendation on how to do this otherwise :)
Thanks!