Skip to content

Runner.runAsync applies stateDelta too late, causing missing(outdated) context in onUserMessageCallback #1099

@anastasiiapeleshok-festcloud

Description

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

  1. Call runner.runAsync(userId, sessionId, message, config, stateDelta).
  2. sessionService.getSession(sessionId) returns a copy of the session.
  3. pluginManager.onUserMessageCallback(initialContext, newMessage) is triggered using this copy.
  4. Any stateDelta passed in the runAsync call is missing from the initialContext.
  5. 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.

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