@f5-sales-demo/pi-agent-core 22.11.0 → 22.12.0

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/agent-loop.ts +26 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/pi-agent-core",
4
- "version": "22.11.0",
4
+ "version": "22.12.0",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -35,8 +35,8 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@f5-sales-demo/pi-ai": "22.11.0",
39
- "@f5-sales-demo/pi-utils": "22.11.0"
38
+ "@f5-sales-demo/pi-ai": "22.12.0",
39
+ "@f5-sales-demo/pi-utils": "22.12.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@sinclair/typebox": "0.34.52",
package/src/agent-loop.ts CHANGED
@@ -25,6 +25,28 @@ import type {
25
25
  } from "./types";
26
26
  import { getToolExecutionKind } from "./types";
27
27
 
28
+ function isStructuredInputReply(message: import("@f5-sales-demo/pi-ai").Message): boolean {
29
+ if (message.role !== "user") return false;
30
+ const text =
31
+ typeof message.content === "string"
32
+ ? message.content
33
+ : message.content
34
+ .filter(part => part.type === "text")
35
+ .map(part => part.text)
36
+ .join("\n");
37
+ try {
38
+ const reply = JSON.parse(text);
39
+ return (
40
+ reply?.type === "user_input_reply" &&
41
+ typeof reply.itemId === "string" &&
42
+ typeof reply.questionId === "string" &&
43
+ typeof reply.answer === "string"
44
+ );
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
28
50
  /**
29
51
  * Start an agent loop with a new prompt message.
30
52
  * The prompt is added to the context and events are emitted for it.
@@ -401,7 +423,10 @@ async function runLoop(
401
423
  take: () => config.getSteeringMessages!(),
402
424
  toProvider: async messages => {
403
425
  const converted = await config.convertToLlm(messages);
404
- if (converted.some(message => message.role !== "user")) return undefined;
426
+ // Correlated question replies must enter at a model boundary. They
427
+ // resolve an existing item, rather than steering its in-flight text.
428
+ if (converted.some(message => message.role !== "user" || isStructuredInputReply(message)))
429
+ return undefined;
405
430
  return converted as import("@f5-sales-demo/pi-ai").UserMessage[];
406
431
  },
407
432
  })