Description
In the current implementation of Runner.java, the stateDelta provided to runAsync is merged into the session only after the pluginManager.onUserMessageCallback has been executed.
Because the stateDelta is merged into the session only after the pluginManager.onUserMessageCallback has been executed, the data available to plugins is inconsistent with the current execution call. Furthermore, because the session is a copy, any attempt to manually update the state from the outside before the callback is ineffective, as the InvocationContext is built from a stale snapshot.
Steps to Reproduce
- Call
runner.runAsync(userId, sessionId, message, config, stateDelta).
sessionService.getSession(sessionId) returns a copy of the session.
pluginManager.onUserMessageCallback(initialContext, newMessage) is triggered using this copy.
- Any
stateDelta passed in the runAsync call is missing from the initialContext.
- The
stateDelta is only applied inside appendNewMessageToSession after the plugin execution, leading to inconsistent behavior during the plugin lifecycle.
Expected Behavior
The stateDelta must be integrated into the session state before the InvocationContext is created and before any plugins are notified. This ensures that plugins operate on a consistent and up-to-date representation of the user session.
Description
In the current implementation of Runner.java, the stateDelta provided to runAsync is merged into the session only after the pluginManager.onUserMessageCallback has been executed.
Because the
stateDeltais merged into the session only after thepluginManager.onUserMessageCallbackhas been executed, the data available to plugins is inconsistent with the current execution call. Furthermore, because the session is a copy, any attempt to manually update the state from the outside before the callback is ineffective, as theInvocationContextis built from a stale snapshot.Steps to Reproduce
runner.runAsync(userId, sessionId, message, config, stateDelta).sessionService.getSession(sessionId)returns a copy of the session.pluginManager.onUserMessageCallback(initialContext, newMessage)is triggered using this copy.stateDeltapassed in therunAsynccall is missing from theinitialContext.stateDeltais only applied insideappendNewMessageToSessionafter the plugin execution, leading to inconsistent behavior during the plugin lifecycle.Expected Behavior
The
stateDeltamust be integrated into the session state before theInvocationContextis created and before any plugins are notified. This ensures that plugins operate on a consistent and up-to-date representation of the user session.