@andreswagner/node-red-contrib-wxo-agent 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,10 +90,20 @@ module.exports = function(RED) {
90
90
  }
91
91
 
92
92
  // Determine thread ID (for multi-turn conversations)
93
- // Note: threadId in full request object takes precedence
93
+ // Accept explicit "true" values only for forcing new sessions.
94
+ const forceNewSession = msg.wxo_new_session === true ||
95
+ msg.wxo_new_session === 'true' ||
96
+ msg.wxo_new_session === 1 ||
97
+ msg.wxo_new_session === '1';
94
98
  let threadId = null;
95
- if (!msg.wxo_new_session && msg.topic) {
96
- threadId = msg.topic;
99
+ if (!forceNewSession) {
100
+ // Full request object takes precedence over msg.topic if provided.
101
+ if (typeof requestPayload === 'object' && requestPayload !== null) {
102
+ threadId = requestPayload.thread_id || requestPayload.threadId || null;
103
+ }
104
+ if (!threadId && typeof msg.topic === 'string' && msg.topic.trim() !== '') {
105
+ threadId = msg.topic.trim();
106
+ }
97
107
  }
98
108
 
99
109
  node.status({ fill: 'blue', shape: 'dot', text: 'calling agent...' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreswagner/node-red-contrib-wxo-agent",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Node-RED node for invoking IBM watsonx Orchestrate agents",
5
5
  "keywords": [
6
6
  "node-red",