unique_toolkit 2026.44.0.dev5__py3-none-any.whl → 2026.44.0.dev6__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.
- unique_toolkit/agentic/history_manager/context_overflow.py +3 -8
- unique_toolkit/agentic/history_manager/history_manager.py +6 -1
- unique_toolkit/agentic/history_manager/loop_token_reducer.py +1 -5
- unique_toolkit/language_model/provider_token_count.py +1 -6
- {unique_toolkit-2026.44.0.dev5.dist-info → unique_toolkit-2026.44.0.dev6.dist-info}/METADATA +1 -1
- {unique_toolkit-2026.44.0.dev5.dist-info → unique_toolkit-2026.44.0.dev6.dist-info}/RECORD +7 -7
- {unique_toolkit-2026.44.0.dev5.dist-info → unique_toolkit-2026.44.0.dev6.dist-info}/WHEEL +0 -0
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
"""Keep agent-loop prompts inside the provider's context window.
|
|
2
|
-
|
|
3
|
-
The local reducer estimates tokens with an OpenAI tokenizer, which can undercount
|
|
4
|
-
other providers by 2x or more. ``ContextOverflowGuard`` verifies near-limit
|
|
5
|
-
payloads with the provider's own counter before the LLM call and recovers when the
|
|
6
|
-
provider still rejects a prompt as too long.
|
|
7
|
-
"""
|
|
1
|
+
"""Keep agent-loop prompts inside the provider's context window, verified by the provider's own token counter."""
|
|
8
2
|
|
|
9
3
|
from __future__ import annotations
|
|
10
4
|
|
|
@@ -225,7 +219,8 @@ class ContextOverflowGuard:
|
|
|
225
219
|
raise
|
|
226
220
|
self._logger.warning(
|
|
227
221
|
"LLM call still exceeded the context window. Retrying with the "
|
|
228
|
-
"latest tool call results withheld."
|
|
222
|
+
"latest tool call results withheld.",
|
|
223
|
+
exc_info=retry_exc,
|
|
229
224
|
)
|
|
230
225
|
await recompose()
|
|
231
226
|
return await run_iteration()
|
|
@@ -237,7 +237,8 @@ class HistoryManager:
|
|
|
237
237
|
|
|
238
238
|
The withheld results' chunks are dropped from the reference manager. They
|
|
239
239
|
are the newest chunks, so source numbers of earlier results stay valid.
|
|
240
|
-
Returns the number of withheld results
|
|
240
|
+
Returns the number of newly withheld results; results that already hold
|
|
241
|
+
*notice* are not counted.
|
|
241
242
|
"""
|
|
242
243
|
batch_start: int | None = None
|
|
243
244
|
for index in range(len(self._loop_history) - 1, -1, -1):
|
|
@@ -256,12 +257,16 @@ class HistoryManager:
|
|
|
256
257
|
message = self._loop_history[index]
|
|
257
258
|
if not isinstance(message, LanguageModelToolMessage):
|
|
258
259
|
continue
|
|
260
|
+
if message.content == notice:
|
|
261
|
+
continue
|
|
259
262
|
self._loop_history[index] = LanguageModelToolMessage(
|
|
260
263
|
content=notice,
|
|
261
264
|
tool_call_id=message.tool_call_id,
|
|
262
265
|
name=message.name,
|
|
263
266
|
)
|
|
264
267
|
withheld_tool_call_ids.append(message.tool_call_id)
|
|
268
|
+
if not withheld_tool_call_ids:
|
|
269
|
+
return 0
|
|
265
270
|
|
|
266
271
|
withheld_chunks = {
|
|
267
272
|
id(chunk)
|
|
@@ -140,11 +140,7 @@ class LoopTokenReducer:
|
|
|
140
140
|
return self._last_token_count
|
|
141
141
|
|
|
142
142
|
def tighten_effective_token_limit(self, factor: float) -> None:
|
|
143
|
-
"""Shrink the input-token budget for the rest of the run.
|
|
144
|
-
|
|
145
|
-
Used after the provider rejected a payload this reducer counted as within
|
|
146
|
-
budget, i.e. the encoder underestimates the model's real token count.
|
|
147
|
-
"""
|
|
143
|
+
"""Shrink the input-token budget for the rest of the run after the provider counted more tokens than the local encoder."""
|
|
148
144
|
previous_limit = self._effective_token_limit
|
|
149
145
|
self._effective_token_limit = int(previous_limit * factor)
|
|
150
146
|
self._logger.warning(
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
Agent-loop messages are in OpenAI chat format. The endpoint expects the Anthropic
|
|
4
|
-
Messages format, so system messages, tool calls, tool results and images are
|
|
5
|
-
converted before counting.
|
|
6
|
-
"""
|
|
1
|
+
"""Convert OpenAI chat payloads to request bodies for LiteLLM's Anthropic-compatible ``count_tokens`` endpoint."""
|
|
7
2
|
|
|
8
3
|
from __future__ import annotations
|
|
9
4
|
|
{unique_toolkit-2026.44.0.dev5.dist-info → unique_toolkit-2026.44.0.dev6.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: unique-toolkit
|
|
3
|
-
Version: 2026.44.0.
|
|
3
|
+
Version: 2026.44.0.dev6
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Cedric Klinkert, Martin Fadler, Sadique Sheik, Fabian Schläpfer, Pascal Hauri, Ejiroghene Oki-Peter, Rami Azouz, Ricardo Visini, Sanzio Monti
|
|
6
6
|
Author-email: Cedric Klinkert <cedric.klinkert@unique.ch>, Martin Fadler <martin.fadler@unique.ch>, Sadique Sheik <sadique@unique.ch>, Fabian Schläpfer <fabian@unique.ch>, Pascal Hauri <pascal@unique.ch>, Ejiroghene Oki-Peter <oki-peter.ejiroghene@unique.ai>, Rami Azouz <rami.ext@unique.ch>, Ricardo Visini <ricardo.visini@unique.ch>, Sanzio Monti <sanzio.monti@unique.ai>
|
|
@@ -113,10 +113,10 @@ unique_toolkit/agentic/evaluation/tests/test_prompt_loaders.py,sha256=zBREdlKf5t
|
|
|
113
113
|
unique_toolkit/agentic/evaluation/utils.py,sha256=HmyPaDV8wdW-_gOjjW-wDaMKgdrsP5-SHP7OqTmGI_A,264
|
|
114
114
|
unique_toolkit/agentic/feature_flags/__init__.py,sha256=fBR9FaLrc9e8sdYDe1LwP9aNJt5aLLtAq3nIphVWkIk,191
|
|
115
115
|
unique_toolkit/agentic/feature_flags/feature_flags.py,sha256=LlFfcgGV4lRQ_mgOGsbZzjKeTXxjCCOl7agCxvJUhvQ,7133
|
|
116
|
-
unique_toolkit/agentic/history_manager/context_overflow.py,sha256=
|
|
116
|
+
unique_toolkit/agentic/history_manager/context_overflow.py,sha256=N5g8bHUHcRz7gey3cCX-xwK7DJkp_O-3IthMnGsIvcE,9472
|
|
117
117
|
unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha256=bJH5RiLM__fg-i_ycact--9xtV5A321xe_cktT__bzA,26284
|
|
118
|
-
unique_toolkit/agentic/history_manager/history_manager.py,sha256=
|
|
119
|
-
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=
|
|
118
|
+
unique_toolkit/agentic/history_manager/history_manager.py,sha256=JM57S-Cou_vzDR3eM52gYRjgu-lhVUDoYyVGE7pgIYY,19078
|
|
119
|
+
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=yLxBPF6gkzpBTL5aOzPgQ61bsZd2kOOxeNrGBEdWTEg,31350
|
|
120
120
|
unique_toolkit/agentic/history_manager/settings.py,sha256=Lrx3a8yXeU0MXrWlV6RZSHsgYWF9Zrs8LyR96OpqQ_k,1216
|
|
121
121
|
unique_toolkit/agentic/history_manager/utils.py,sha256=DiBip8xtah3I9-G-_Ul3OjlYKunrXR-5RJtzREHWV_0,6579
|
|
122
122
|
unique_toolkit/agentic/loop_runner/__init__.py,sha256=bhwOIloPn2MZyCw60FkHy330twCCRovg3bgye9OjZRE,1496
|
|
@@ -402,7 +402,7 @@ unique_toolkit/language_model/infos.py,sha256=_fbEwGA9AjBm7TF1FTsihtKzi4SybTwVN7
|
|
|
402
402
|
unique_toolkit/language_model/invocation_stats.py,sha256=CQbpUz394IsVd8eNTB1gPSMt5f0UXmkN1amNsqtAW6U,5857
|
|
403
403
|
unique_toolkit/language_model/model_costs.py,sha256=ShuDAzMew1fUkJ3tzPgU5Zqjp6ivUZaG97BFh93tEn4,6358
|
|
404
404
|
unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
|
|
405
|
-
unique_toolkit/language_model/provider_token_count.py,sha256=
|
|
405
|
+
unique_toolkit/language_model/provider_token_count.py,sha256=mS597Mvrc7EsAc9iJSmASIEwvETSPLtIEsWxusPrQVc,5337
|
|
406
406
|
unique_toolkit/language_model/reference.py,sha256=T3wr2jP_uRg5wKVIbKqLbxJlcgxfbZQGq3XdjbQ2kSo,6984
|
|
407
407
|
unique_toolkit/language_model/schemas.py,sha256=o8zGkfoYayO1gL85G-ulV3Akp_BwjgEWGGUb89j1OgU,35440
|
|
408
408
|
unique_toolkit/language_model/service.py,sha256=lgpzWhqxLBOeFacCafQi4e7BqAxJbOlr8GnCYcKeTdM,13274
|
|
@@ -428,6 +428,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
|
|
|
428
428
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
429
429
|
unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
|
|
430
430
|
unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
|
|
431
|
-
unique_toolkit-2026.44.0.
|
|
432
|
-
unique_toolkit-2026.44.0.
|
|
433
|
-
unique_toolkit-2026.44.0.
|
|
431
|
+
unique_toolkit-2026.44.0.dev6.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
432
|
+
unique_toolkit-2026.44.0.dev6.dist-info/METADATA,sha256=MgerP-ba0WqiuVpuL_IbEho3hmwCGjgnQWMp6ESf8TI,7821
|
|
433
|
+
unique_toolkit-2026.44.0.dev6.dist-info/RECORD,,
|
|
File without changes
|