Browse Source

fix: enforce EventPrompt payload singleton

Problem: dual_agent could serialize a generated-signature custom prompt alongside the managed EventPrompt.\n\nRisk: filtering relies on the conservative established EventPrompt signature so ordinary custom prompts retain their order.
zhenyu.hu 2 weeks ago
parent
commit
781361cb2b
2 changed files with 7 additions and 8 deletions
  1. 5 6
      src/agent_lab/presentation/static/app.js
  2. 2 2
      tests/test_websocket_api.py

+ 5 - 6
src/agent_lab/presentation/static/app.js

@@ -730,12 +730,11 @@ function buildCustomPromptItems() {
 
 function collectSystemPrompts() {
   const promptItems = buildPromptItems();
-  const serializablePrompts = toolInvocationMode.value === "chat_agent_tools"
-    ? promptItems.filter((item) => (
-      item.prompt_kind !== "event_agent_system"
-      && !isGeneratedEventPromptContent(item.content)
-    ))
-    : promptItems;
+  const serializablePrompts = promptItems.filter((item) => (
+    item.prompt_kind === "event_agent_system"
+      ? toolInvocationMode.value === "dual_agent"
+      : !isGeneratedEventPromptContent(item.content)
+  ));
   return serializablePrompts
     .map((item) => item.content)
     .filter(Boolean);

+ 2 - 2
tests/test_websocket_api.py

@@ -2371,7 +2371,7 @@ console.log(JSON.stringify({
     ]
 
 
-def test_static_event_prompt_is_excluded_from_chat_agent_tools_payload():
+def test_static_event_prompt_payload_singleton_depends_on_tool_mode():
     js = Path("src/agent_lab/presentation/static/app.js").read_text()
     generated = "\n".join(
         [
@@ -2435,7 +2435,7 @@ console.log(JSON.stringify({ chatAgentTools, dualAgent }));
     )
 
     assert result["chatAgentTools"] == ["ordinary custom"]
-    assert result["dualAgent"] == ["ordinary custom", generated, generated]
+    assert result["dualAgent"] == ["ordinary custom", generated]
 
 
 def test_static_tool_mode_disables_only_event_agent_model_settings_group():