unique_toolkit 1.4.3__py3-none-any.whl → 1.4.4__py3-none-any.whl

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.
@@ -15,6 +15,7 @@ Your task is to give a brief summary (1-10 sentences) of the received assessment
15
15
  1. You must NOT in ANY case state a fact that is not stated in the given assessments.
16
16
  2. You must focus first and foremost on the failing assessments, labeled `RED` below.
17
17
  3. You must mention each agent's name when summarizing its list of assessments.
18
+ 4. You must NOT use any markdown formatting in your response as this will FAIL to render in the chat frontend.
18
19
  """.strip()
19
20
 
20
21
  with open(Path(__file__).parent / "summarization_user_message.j2", "r") as file:
@@ -27,7 +27,7 @@ logger = logging.getLogger(__name__)
27
27
 
28
28
 
29
29
  class _SubAgentToolInfo(TypedDict):
30
- assessment: list[unique_sdk.Space.Assessment] | None
30
+ assessments: list[list[unique_sdk.Space.Assessment]]
31
31
  display_name: str
32
32
 
33
33
 
@@ -53,7 +53,7 @@ class SubAgentsEvaluation(Evaluation):
53
53
  if sub_agent_tool.config.evaluation_config.display_evalution:
54
54
  sub_agent_tool.subscribe(self)
55
55
  self._assistant_id_to_tool_info[sub_agent_tool.config.assistant_id] = {
56
- "assessment": None,
56
+ "assessments": [],
57
57
  "display_name": sub_agent_tool.display_name(),
58
58
  }
59
59
 
@@ -80,47 +80,53 @@ class SubAgentsEvaluation(Evaluation):
80
80
  label_comparison_dict[ChatMessageAssessmentLabel.RED] = 0
81
81
 
82
82
  for assistant_id, tool_info in self._assistant_id_to_tool_info.items():
83
- assessments = tool_info["assessment"] or []
84
- valid_assessments = []
85
- for assessment in assessments:
86
- if (
87
- assessment["label"] is None
88
- or assessment["label"] not in ChatMessageAssessmentLabel
89
- ):
90
- logger.warning(
91
- "Unkown assistant label %s for assistant %s will be ignored",
92
- assessment["label"],
93
- assistant_id,
94
- )
95
- continue
96
- if assessment["status"] != ChatMessageAssessmentStatus.DONE:
97
- logger.warning(
98
- "Assessment %s for assistant %s is not done (status: %s) will be ignored",
99
- assessment["label"],
100
- assistant_id,
83
+ sub_agent_assessments = tool_info["assessments"] or []
84
+ for i, assessments in enumerate(sub_agent_assessments, start=1):
85
+ valid_assessments = []
86
+ for assessment in assessments:
87
+ if (
88
+ assessment["label"] is None
89
+ or assessment["label"] not in ChatMessageAssessmentLabel
90
+ ):
91
+ logger.warning(
92
+ "Unkown assistant label %s for assistant %s will be ignored",
93
+ assessment["label"],
94
+ assistant_id,
95
+ )
96
+ continue
97
+ if assessment["status"] != ChatMessageAssessmentStatus.DONE:
98
+ logger.warning(
99
+ "Assessment %s for assistant %s is not done (status: %s) will be ignored",
100
+ assessment["label"],
101
+ assistant_id,
102
+ )
103
+ continue
104
+ valid_assessments.append(assessment)
105
+
106
+ if len(valid_assessments) == 0:
107
+ logger.info(
108
+ "No valid assessment found for assistant %s", assistant_id
101
109
  )
102
110
  continue
103
- valid_assessments.append(assessment)
104
-
105
- if len(valid_assessments) == 0:
106
- logger.info("No valid assessment found for assistant %s", assistant_id)
107
- continue
108
111
 
109
- assessments = sorted(
110
- valid_assessments, key=lambda x: label_comparison_dict[x["label"]]
111
- )
112
-
113
- for assessment in assessments:
114
- value = min(
115
- value, assessment["label"], key=lambda x: label_comparison_dict[x]
112
+ assessments = sorted(
113
+ valid_assessments, key=lambda x: label_comparison_dict[x["label"]]
116
114
  )
117
115
 
118
- sub_agents_display_data.append(
119
- {
116
+ for assessment in assessments:
117
+ value = min(
118
+ value,
119
+ assessment["label"],
120
+ key=lambda x: label_comparison_dict[x],
121
+ )
122
+ data = {
120
123
  "name": tool_info["display_name"],
121
124
  "assessments": assessments,
122
125
  }
123
- )
126
+ if len(sub_agent_assessments) > 1:
127
+ data["name"] += f" {i}"
128
+
129
+ sub_agents_display_data.append(data)
124
130
 
125
131
  if len(sub_agents_display_data) == 0:
126
132
  logger.warning("No valid sub agent assessments found")
@@ -200,10 +206,10 @@ class SubAgentsEvaluation(Evaluation):
200
206
  )
201
207
  return
202
208
 
203
- self._assistant_id_to_tool_info[sub_agent_assistant_id]["assessment"] = (
209
+ self._assistant_id_to_tool_info[sub_agent_assistant_id]["assessments"].append(
204
210
  response[
205
211
  "assessment"
206
212
  ].copy() # Shallow copy as we don't modify individual assessments
207
213
  if response["assessment"] is not None
208
- else None
214
+ else []
209
215
  )
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  import re
3
- from typing import NotRequired, TypedDict, override
3
+ from typing import TypedDict, override
4
4
 
5
5
  import unique_sdk
6
6
 
@@ -30,7 +30,7 @@ class _SubAgentMessageInfo(TypedDict):
30
30
  class _SubAgentToolInfo(TypedDict):
31
31
  display_name: str
32
32
  display_config: SubAgentToolDisplayConfig
33
- response: NotRequired[_SubAgentMessageInfo]
33
+ responses: list[_SubAgentMessageInfo]
34
34
 
35
35
 
36
36
  class SubAgentResponsesPostprocessor(Postprocessor):
@@ -57,6 +57,7 @@ class SubAgentResponsesPostprocessor(Postprocessor):
57
57
  _SubAgentToolInfo(
58
58
  display_config=sub_agent_tool.config.response_display_config,
59
59
  display_name=sub_agent_tool.display_name(),
60
+ responses=[],
60
61
  )
61
62
  )
62
63
 
@@ -81,7 +82,7 @@ class SubAgentResponsesPostprocessor(Postprocessor):
81
82
  for assistant_id, tool_info in self._assistant_id_to_tool_info.items():
82
83
  display_mode = tool_info["display_config"].mode
83
84
 
84
- if "response" not in tool_info:
85
+ if len(tool_info["responses"]) == 0:
85
86
  logger.warning(
86
87
  "No response from assistant %s",
87
88
  assistant_id,
@@ -89,7 +90,7 @@ class SubAgentResponsesPostprocessor(Postprocessor):
89
90
  continue
90
91
 
91
92
  if display_mode != ResponseDisplayMode.HIDDEN:
92
- displayed[assistant_id] = tool_info["response"]
93
+ displayed[assistant_id] = tool_info["responses"]
93
94
 
94
95
  existing_refs = {
95
96
  ref.source_id: ref.sequence_number
@@ -98,33 +99,38 @@ class SubAgentResponsesPostprocessor(Postprocessor):
98
99
  _consolidate_references_in_place(displayed, existing_refs)
99
100
 
100
101
  modified = len(displayed) > 0
101
- for assistant_id, message in reversed(displayed.items()):
102
- tool_info = self._assistant_id_to_tool_info[assistant_id]
103
- display_mode = tool_info["display_config"].mode
104
- display_name = tool_info["display_name"]
105
- loop_response.message.text = (
106
- build_sub_agent_answer_display(
107
- display_name=display_name,
108
- assistant_id=assistant_id,
109
- display_mode=display_mode,
110
- answer=message["text"],
102
+ for assistant_id, messages in reversed(displayed.items()):
103
+ for i in reversed(range(len(messages))):
104
+ message = messages[i]
105
+ tool_info = self._assistant_id_to_tool_info[assistant_id]
106
+ display_mode = tool_info["display_config"].mode
107
+ display_name = tool_info["display_name"]
108
+ if len(messages) > 1:
109
+ display_name += f" {i + 1}"
110
+
111
+ loop_response.message.text = (
112
+ build_sub_agent_answer_display(
113
+ display_name=display_name,
114
+ assistant_id=assistant_id,
115
+ display_mode=display_mode,
116
+ answer=message["text"],
117
+ )
118
+ + loop_response.message.text
111
119
  )
112
- + loop_response.message.text
113
- )
114
-
115
- assert self._sub_agent_message is not None
116
120
 
117
- loop_response.message.references.extend(
118
- ContentReference(
119
- message_id=self._sub_agent_message["id"],
120
- source_id=ref["sourceId"],
121
- url=ref["url"],
122
- source=ref["source"],
123
- name=ref["name"],
124
- sequence_number=ref["sequenceNumber"],
121
+ assert self._sub_agent_message is not None
122
+
123
+ loop_response.message.references.extend(
124
+ ContentReference(
125
+ message_id=self._sub_agent_message["id"],
126
+ source_id=ref["sourceId"],
127
+ url=ref["url"],
128
+ source=ref["source"],
129
+ name=ref["name"],
130
+ sequence_number=ref["sequenceNumber"],
131
+ )
132
+ for ref in message["references"]
125
133
  )
126
- for ref in message["references"]
127
- )
128
134
 
129
135
  return modified
130
136
 
@@ -150,59 +156,58 @@ class SubAgentResponsesPostprocessor(Postprocessor):
150
156
  )
151
157
  return
152
158
 
153
- self._assistant_id_to_tool_info[sub_agent_assistant_id]["response"] = {
154
- "text": response["text"],
155
- "references": [
156
- {
157
- "name": ref["name"],
158
- "url": ref["url"],
159
- "sequenceNumber": ref["sequenceNumber"],
160
- "originalIndex": [],
161
- "sourceId": ref["sourceId"],
162
- "source": ref["source"],
163
- }
164
- for ref in response["references"] or []
165
- ],
166
- }
159
+ self._assistant_id_to_tool_info[sub_agent_assistant_id]["responses"].append(
160
+ {
161
+ "text": response["text"],
162
+ "references": [
163
+ {
164
+ "name": ref["name"],
165
+ "url": ref["url"],
166
+ "sequenceNumber": ref["sequenceNumber"],
167
+ "originalIndex": [],
168
+ "sourceId": ref["sourceId"],
169
+ "source": ref["source"],
170
+ }
171
+ for ref in response["references"] or []
172
+ ],
173
+ }
174
+ )
167
175
 
168
176
 
169
177
  def _consolidate_references_in_place(
170
- messages: dict[str, _SubAgentMessageInfo], existing_refs: dict[str, int]
178
+ messages: dict[str, list[_SubAgentMessageInfo]], existing_refs: dict[str, int]
171
179
  ) -> None:
172
180
  start_index = max(existing_refs.values(), default=0) + 1
173
181
 
174
- for assistant_id, message in messages.items():
175
- references = message["references"]
176
- if len(references) == 0 or message["text"] is None:
177
- logger.info(
178
- "Message from assistant %s does not contain any references",
179
- assistant_id,
180
- )
181
- continue
182
-
183
- references = list(sorted(references, key=lambda ref: ref["sequenceNumber"]))
184
-
185
- ref_map = {}
186
-
187
- message_new_refs = []
188
- for reference in references:
189
- source_id = reference["sourceId"]
182
+ for assistant_id, assistant_messages in messages.items():
183
+ for message in assistant_messages:
184
+ references = message["references"]
185
+ if len(references) == 0 or message["text"] is None:
186
+ logger.info(
187
+ "Message from assistant %s does not contain any references",
188
+ assistant_id,
189
+ )
190
+ continue
190
191
 
191
- if source_id not in existing_refs:
192
- message_new_refs.append(reference)
192
+ references = list(sorted(references, key=lambda ref: ref["sequenceNumber"]))
193
193
 
194
- existing_refs[source_id] = start_index
195
- start_index += 1
194
+ ref_map = {}
196
195
 
197
- reference_num = existing_refs[source_id]
198
- seq_num = reference["sequenceNumber"]
196
+ message_new_refs = []
197
+ for reference in references:
198
+ source_id = reference["sourceId"]
199
199
 
200
- ref_map[seq_num] = reference_num
200
+ if source_id not in existing_refs:
201
+ message_new_refs.append(reference)
202
+ existing_refs[source_id] = start_index
203
+ start_index += 1
201
204
 
202
- reference["sequenceNumber"] = reference_num
205
+ reference_num = existing_refs[source_id]
206
+ ref_map[reference["sequenceNumber"]] = reference_num
207
+ reference["sequenceNumber"] = reference_num
203
208
 
204
- message["text"] = _replace_references_in_text(message["text"], ref_map)
205
- message["references"] = message_new_refs
209
+ message["text"] = _replace_references_in_text(message["text"], ref_map)
210
+ message["references"] = message_new_refs
206
211
 
207
212
 
208
213
  def _replace_references_in_text_non_overlapping(
@@ -215,7 +220,7 @@ def _replace_references_in_text_non_overlapping(
215
220
 
216
221
  def _replace_references_in_text(text: str, ref_map: dict[int, int]) -> str:
217
222
  # 2 phase replacement, since the map keys and values can overlap
218
- max_ref = max(ref_map.keys(), default=0) + 1
223
+ max_ref = max(max(ref_map.keys(), default=0), max(ref_map.values(), default=0)) + 1
219
224
  unique_refs = range(max_ref, max_ref + len(ref_map))
220
225
 
221
226
  text = _replace_references_in_text_non_overlapping(
@@ -0,0 +1,248 @@
1
+ from unique_toolkit.agentic.tools.a2a.postprocessing.postprocessor import (
2
+ _replace_references_in_text,
3
+ _replace_references_in_text_non_overlapping,
4
+ )
5
+
6
+
7
+ class TestReplaceReferencesInTextNonOverlapping:
8
+ """Test cases for _replace_references_in_text_non_overlapping function."""
9
+
10
+ def test_single_reference_replacement(self):
11
+ """Test replacing a single reference."""
12
+ text = "This is a test<sup>1</sup> with one reference."
13
+ ref_map = {1: 5}
14
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
15
+ expected = "This is a test<sup>5</sup> with one reference."
16
+ assert result == expected
17
+
18
+ def test_multiple_reference_replacements(self):
19
+ """Test replacing multiple references."""
20
+ text = "First<sup>1</sup> and second<sup>2</sup> and third<sup>3</sup>."
21
+ ref_map = {1: 10, 2: 20, 3: 30}
22
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
23
+ expected = "First<sup>10</sup> and second<sup>20</sup> and third<sup>30</sup>."
24
+ assert result == expected
25
+
26
+ def test_no_references_in_text(self):
27
+ """Test with text that has no references."""
28
+ text = "This text has no references at all."
29
+ ref_map = {1: 5, 2: 10}
30
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
31
+ assert result == text
32
+
33
+ def test_empty_ref_map(self):
34
+ """Test with empty reference map."""
35
+ text = "This text has<sup>1</sup> references but empty map."
36
+ ref_map = {}
37
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
38
+ assert result == text
39
+
40
+ def test_empty_text(self):
41
+ """Test with empty text."""
42
+ text = ""
43
+ ref_map = {1: 5}
44
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
45
+ assert result == ""
46
+
47
+ def test_reference_not_in_map(self):
48
+ """Test with references in text that are not in the map."""
49
+ text = "Reference<sup>1</sup> and<sup>2</sup> and<sup>3</sup>."
50
+ ref_map = {1: 10} # Only maps reference 1
51
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
52
+ expected = "Reference<sup>10</sup> and<sup>2</sup> and<sup>3</sup>."
53
+ assert result == expected
54
+
55
+ def test_duplicate_references_in_text(self):
56
+ """Test with duplicate references in text."""
57
+ text = "First<sup>1</sup> and second<sup>1</sup> occurrence."
58
+ ref_map = {1: 99}
59
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
60
+ expected = "First<sup>99</sup> and second<sup>99</sup> occurrence."
61
+ assert result == expected
62
+
63
+ def test_adjacent_references(self):
64
+ """Test with adjacent references."""
65
+ text = "Adjacent<sup>1</sup><sup>2</sup> references."
66
+ ref_map = {1: 10, 2: 20}
67
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
68
+ expected = "Adjacent<sup>10</sup><sup>20</sup> references."
69
+ assert result == expected
70
+
71
+ def test_references_with_multi_digit_numbers(self):
72
+ """Test with multi-digit reference numbers."""
73
+ text = "Reference<sup>123</sup> and<sup>456</sup>."
74
+ ref_map = {123: 789, 456: 101112}
75
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
76
+ expected = "Reference<sup>789</sup> and<sup>101112</sup>."
77
+ assert result == expected
78
+
79
+ def test_references_at_text_boundaries(self):
80
+ """Test with references at the beginning and end of text."""
81
+ text = "<sup>1</sup>Start and end<sup>2</sup>"
82
+ ref_map = {1: 100, 2: 200}
83
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
84
+ expected = "<sup>100</sup>Start and end<sup>200</sup>"
85
+ assert result == expected
86
+
87
+ def test_malformed_references_ignored(self):
88
+ """Test that malformed references are ignored."""
89
+ text = "Good<sup>1</sup> and bad<sup>abc</sup> and<sup></sup>."
90
+ ref_map = {1: 10}
91
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
92
+ expected = "Good<sup>10</sup> and bad<sup>abc</sup> and<sup></sup>."
93
+ assert result == expected
94
+
95
+ def test_zero_reference_number(self):
96
+ """Test with zero as reference number."""
97
+ text = "Zero reference<sup>0</sup> here."
98
+ ref_map = {0: 100}
99
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
100
+ expected = "Zero reference<sup>100</sup> here."
101
+ assert result == expected
102
+
103
+ def test_negative_reference_numbers(self):
104
+ """Test with negative reference numbers (edge case)."""
105
+ text = "Negative<sup>-1</sup> reference."
106
+ ref_map = {-1: 5}
107
+ result = _replace_references_in_text_non_overlapping(text, ref_map)
108
+ expected = "Negative<sup>5</sup> reference."
109
+ assert result == expected
110
+
111
+
112
+ class TestReplaceReferencesInText:
113
+ """Test cases for _replace_references_in_text function."""
114
+
115
+ def test_non_overlapping_simple_case(self):
116
+ """Test simple non-overlapping case."""
117
+ text = "Reference<sup>1</sup> and<sup>2</sup>."
118
+ ref_map = {1: 10, 2: 20}
119
+ result = _replace_references_in_text(text, ref_map)
120
+ expected = "Reference<sup>10</sup> and<sup>20</sup>."
121
+ assert result == expected
122
+
123
+ def test_overlapping_references_case1(self):
124
+ """Test overlapping case where new reference numbers conflict with existing ones."""
125
+ text = "First<sup>1</sup> and second<sup>2</sup>."
126
+ ref_map = {1: 2, 2: 1} # Swap references
127
+ result = _replace_references_in_text(text, ref_map)
128
+ expected = "First<sup>2</sup> and second<sup>1</sup>."
129
+ assert result == expected
130
+
131
+ def test_overlapping_references_case2(self):
132
+ """Test overlapping case with chain of replacements."""
133
+ text = "Refs<sup>1</sup><sup>2</sup><sup>3</sup>."
134
+ ref_map = {1: 2, 2: 3, 3: 1} # Circular replacement
135
+ result = _replace_references_in_text(text, ref_map)
136
+ expected = "Refs<sup>2</sup><sup>3</sup><sup>1</sup>."
137
+ assert result == expected
138
+
139
+ def test_overlapping_with_higher_numbers(self):
140
+ """Test overlapping where replacement numbers are higher than originals."""
141
+ text = "Test<sup>1</sup> and<sup>2</sup>."
142
+ ref_map = {1: 3, 2: 1} # 2 -> 1, but 1 -> 3
143
+ result = _replace_references_in_text(text, ref_map)
144
+ expected = "Test<sup>3</sup> and<sup>1</sup>."
145
+ assert result == expected
146
+
147
+ def test_complex_overlapping_scenario(self):
148
+ """Test complex overlapping scenario with multiple conflicts."""
149
+ text = "A<sup>1</sup>B<sup>2</sup>C<sup>3</sup>D<sup>4</sup>."
150
+ ref_map = {1: 4, 2: 1, 3: 2, 4: 3} # Full rotation
151
+ result = _replace_references_in_text(text, ref_map)
152
+ expected = "A<sup>4</sup>B<sup>1</sup>C<sup>2</sup>D<sup>3</sup>."
153
+ assert result == expected
154
+
155
+ def test_empty_ref_map(self):
156
+ """Test with empty reference map."""
157
+ text = "Text with<sup>1</sup> references."
158
+ ref_map = {}
159
+ result = _replace_references_in_text(text, ref_map)
160
+ assert result == text
161
+
162
+ def test_empty_text(self):
163
+ """Test with empty text."""
164
+ text = ""
165
+ ref_map = {1: 2}
166
+ result = _replace_references_in_text(text, ref_map)
167
+ assert result == ""
168
+
169
+ def test_no_references_in_text(self):
170
+ """Test with text containing no references."""
171
+ text = "This text has no references."
172
+ ref_map = {1: 10, 2: 20}
173
+ result = _replace_references_in_text(text, ref_map)
174
+ assert result == text
175
+
176
+ def test_single_reference_no_overlap(self):
177
+ """Test single reference with no overlap potential."""
178
+ text = "Single<sup>5</sup> reference."
179
+ ref_map = {5: 100}
180
+ result = _replace_references_in_text(text, ref_map)
181
+ expected = "Single<sup>100</sup> reference."
182
+ assert result == expected
183
+
184
+ def test_partial_overlap(self):
185
+ """Test case where only some references have overlapping numbers."""
186
+ text = "Mix<sup>1</sup><sup>2</sup><sup>10</sup>."
187
+ ref_map = {1: 2, 2: 20, 10: 100} # Only 1->2 creates potential overlap
188
+ result = _replace_references_in_text(text, ref_map)
189
+ expected = "Mix<sup>2</sup><sup>20</sup><sup>100</sup>."
190
+ assert result == expected
191
+
192
+ def test_self_mapping(self):
193
+ """Test case where a reference maps to itself."""
194
+ text = "Self<sup>1</sup> and other<sup>2</sup>."
195
+ ref_map = {1: 1, 2: 10} # 1 maps to itself
196
+ result = _replace_references_in_text(text, ref_map)
197
+ expected = "Self<sup>1</sup> and other<sup>10</sup>."
198
+ assert result == expected
199
+
200
+ def test_duplicate_references_with_overlap(self):
201
+ """Test duplicate references in text with overlapping mappings."""
202
+ text = "Dup<sup>1</sup> and dup<sup>1</sup> and<sup>2</sup>."
203
+ ref_map = {1: 2, 2: 1} # Swap
204
+ result = _replace_references_in_text(text, ref_map)
205
+ expected = "Dup<sup>2</sup> and dup<sup>2</sup> and<sup>1</sup>."
206
+ assert result == expected
207
+
208
+ def test_large_reference_numbers(self):
209
+ """Test with large reference numbers."""
210
+ text = "Large<sup>999</sup> and<sup>1000</sup>."
211
+ ref_map = {999: 1000, 1000: 999} # Swap large numbers
212
+ result = _replace_references_in_text(text, ref_map)
213
+ expected = "Large<sup>1000</sup> and<sup>999</sup>."
214
+ assert result == expected
215
+
216
+ def test_zero_and_negative_with_overlap(self):
217
+ """Test zero and negative numbers with potential overlap."""
218
+ text = "Zero<sup>0</sup> and neg<sup>-1</sup> and pos<sup>1</sup>."
219
+ ref_map = {0: 1, -1: 0, 1: -1} # Circular with zero and negative
220
+ result = _replace_references_in_text(text, ref_map)
221
+ expected = "Zero<sup>1</sup> and neg<sup>0</sup> and pos<sup>-1</sup>."
222
+ assert result == expected
223
+
224
+ def test_max_ref_calculation_edge_case(self):
225
+ """Test edge case for max_ref calculation with empty map."""
226
+ text = "Some<sup>1</sup> text."
227
+ ref_map = {}
228
+ result = _replace_references_in_text(text, ref_map)
229
+ assert result == text
230
+
231
+ def test_phase_separation_correctness(self):
232
+ """Test that the two-phase approach correctly handles complex overlaps."""
233
+ # This test ensures the intermediate unique references don't interfere
234
+ text = "Test<sup>1</sup><sup>2</sup><sup>3</sup><sup>4</sup><sup>5</sup>."
235
+ ref_map = {1: 5, 2: 4, 3: 3, 4: 2, 5: 1} # Reverse order
236
+ result = _replace_references_in_text(text, ref_map)
237
+ expected = "Test<sup>5</sup><sup>4</sup><sup>3</sup><sup>2</sup><sup>1</sup>."
238
+ assert result == expected
239
+
240
+ def test_intermediate_collision_avoidance(self):
241
+ """Test that intermediate unique references don't collide with existing text."""
242
+ # Create a scenario where intermediate refs might collide
243
+ text = "Refs<sup>1</sup><sup>2</sup> and existing<sup>6</sup><sup>7</sup>."
244
+ ref_map = {1: 2, 2: 1} # Simple swap
245
+ result = _replace_references_in_text(text, ref_map)
246
+ expected = "Refs<sup>2</sup><sup>1</sup> and existing<sup>6</sup><sup>7</sup>."
247
+ assert result == expected
248
+ # The existing <sup>6</sup> and <sup>7</sup> should remain unchanged
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 1.4.3
3
+ Version: 1.4.4
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Cedric Klinkert
@@ -118,6 +118,9 @@ All notable changes to this project will be documented in this file.
118
118
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
119
119
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
120
120
 
121
+ ## [1.4.4] - 2025-09-30
122
+ - Fix bugs with display of sub-agent answers and evaluations when multiple sub-agent from the same assistant run concurrently.
123
+
121
124
  ## [1.4.3] - 2025-09-30
122
125
  - Fix bug with sub-agent post-processing reference numbers.
123
126
 
@@ -53,15 +53,16 @@ unique_toolkit/agentic/tools/__init__.py,sha256=-ToY9-Xiz0K7qCUydH1h1yG6n4h1hQS8
53
53
  unique_toolkit/agentic/tools/a2a/__init__.py,sha256=NdY0J33b1G4sbx6UWwNS74JVSAeEtu8u_iEXOT64Uq0,187
54
54
  unique_toolkit/agentic/tools/a2a/config.py,sha256=3Rp5myYQgPwOq-qmM0OaZDFkovXh9a1YJc8TnieN-K0,1711
55
55
  unique_toolkit/agentic/tools/a2a/evaluation/__init__.py,sha256=H9YhT22w8EadV9b-6IDqYqKQa41qcA3m6ADzmP7g6Cc,246
56
- unique_toolkit/agentic/tools/a2a/evaluation/config.py,sha256=o1Xj2H4175C1ALT8-wIfks69Xez3pgY77PFyPBYS4Hs,1692
57
- unique_toolkit/agentic/tools/a2a/evaluation/evaluator.py,sha256=V3y72yAZ5ynDnzp8V7UxMpnwa1Xyw7gvjPqfgHCeMkU,7660
56
+ unique_toolkit/agentic/tools/a2a/evaluation/config.py,sha256=Is-5AfmxeJx3YejTQehBnN_C-akqA445DlB3yfPNPtE,1803
57
+ unique_toolkit/agentic/tools/a2a/evaluation/evaluator.py,sha256=6_WjnmRwj_OFXSo_3SIoO8qC8xG5zHoF0vy9RGtk-fs,8062
58
58
  unique_toolkit/agentic/tools/a2a/evaluation/summarization_user_message.j2,sha256=acP1YqD_sCy6DT0V2EIfhQTmaUKeqpeWNJ7RGgceo8I,271
59
59
  unique_toolkit/agentic/tools/a2a/manager.py,sha256=yuuQuBrAcsT3gAWEdxf6EvRnL_iWtvaK14lRs21w5PA,1665
60
60
  unique_toolkit/agentic/tools/a2a/memory.py,sha256=4VFBzITCv5E_8YCc4iF4Y6FhzplS2C-FZaZHdeC7DyA,1028
61
61
  unique_toolkit/agentic/tools/a2a/postprocessing/__init__.py,sha256=9M5RRSO4gmQVI1gfve6MGEfVktT9WcELQFZ8Sv6xu4Y,160
62
62
  unique_toolkit/agentic/tools/a2a/postprocessing/display.py,sha256=rlBWO2M8Lr5Kx-vmvwlV-vEu33BZE4votP-TMr3-3Dw,3366
63
- unique_toolkit/agentic/tools/a2a/postprocessing/postprocessor.py,sha256=MGOQJ2bcBEv8v8mI5ZOgsv_J8hPFFLQ2RLODXzJ6eVc,7652
63
+ unique_toolkit/agentic/tools/a2a/postprocessing/postprocessor.py,sha256=-YRA9Ry-smGyDEy5WCbNBqB2jvlVITz5bX96kIIvYOA,8179
64
64
  unique_toolkit/agentic/tools/a2a/postprocessing/test/test_display.py,sha256=UVOd5tVTltngVfsdOn6cuyvG7QmRBkfgUj_SruTgmHI,15279
65
+ unique_toolkit/agentic/tools/a2a/postprocessing/test/test_postprocessor_reference_functions.py,sha256=DgMAhXGYu0dQiTBmNGAAXD0__TR7KKe4RtaPLlnDnAk,11372
65
66
  unique_toolkit/agentic/tools/a2a/schema.py,sha256=T1l5z6trtPE5nhqPzt5tvfRNDhqL_ST1Wj7_lBWJ58g,304
66
67
  unique_toolkit/agentic/tools/a2a/service.py,sha256=ySgCZZ_3APPZ8j0sz-7_1CYxfFTvGCSpu0qsUG1YShQ,7916
67
68
  unique_toolkit/agentic/tools/agent_chunks_hanlder.py,sha256=x32Dp1Z8cVW5i-XzXbaMwX2KHPcNGmqEU-FB4AV9ZGo,1909
@@ -137,7 +138,7 @@ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJ
137
138
  unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBuE9sI2o9Aajqjxg,8884
138
139
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
140
  unique_toolkit/smart_rules/compile.py,sha256=cxWjb2dxEI2HGsakKdVCkSNi7VK9mr08w5sDcFCQyWI,9553
140
- unique_toolkit-1.4.3.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
141
- unique_toolkit-1.4.3.dist-info/METADATA,sha256=kqVo0uCpxe7VLrBCbbENvk2O7lCBBA8PxNVb9J-VcQE,34161
142
- unique_toolkit-1.4.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
143
- unique_toolkit-1.4.3.dist-info/RECORD,,
141
+ unique_toolkit-1.4.4.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
142
+ unique_toolkit-1.4.4.dist-info/METADATA,sha256=lJl2z2t_r5J6gUHPisAQgBbdAf15Oh3fuR9pnric08E,34313
143
+ unique_toolkit-1.4.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
144
+ unique_toolkit-1.4.4.dist-info/RECORD,,