unique_toolkit 2026.30.0.dev2__py3-none-any.whl → 2026.30.0.dev4__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.
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ from collections.abc import Sequence
2
3
  from enum import StrEnum
3
4
  from typing import Annotated, Any, Generic
4
5
 
@@ -98,6 +99,16 @@ class ToolBuildConfig(BaseModel, Generic[T]):
98
99
 
99
100
  is_enabled: bool = Field(default=True)
100
101
 
102
+ config_error: str | None = Field(
103
+ default=None,
104
+ exclude=True,
105
+ description=(
106
+ "Set when this tool's stored configuration failed to resolve and was "
107
+ "demoted to a disabled BaseToolConfig fallback. None for tools that are "
108
+ "valid, including tools that are deliberately disabled."
109
+ ),
110
+ )
111
+
101
112
  @model_validator(mode="before")
102
113
  def initialize_config_based_on_tool_name(
103
114
  cls,
@@ -115,6 +126,16 @@ class ToolBuildConfig(BaseModel, Generic[T]):
115
126
  if not isinstance(value, dict):
116
127
  return value
117
128
 
129
+ # config_error must only ever be set by this validator's own demotion
130
+ # path below. Since this is a plain field on a model with
131
+ # populate_by_name + a camelCase alias generator, an externally
132
+ # supplied config_error/configError (e.g. a stray key on a stored
133
+ # payload) would otherwise pass straight through untouched on every
134
+ # non-demotion return path and make a perfectly healthy tool look
135
+ # misconfigured to collect_tool_configuration_errors.
136
+ value.pop("config_error", None)
137
+ value.pop("configError", None)
138
+
118
139
  is_mcp_tool = _is_mcp_tool_payload(value)
119
140
  mcp_configuration = value.get("configuration", {})
120
141
 
@@ -168,8 +189,23 @@ class ToolBuildConfig(BaseModel, Generic[T]):
168
189
  )
169
190
  value["is_enabled"] = False
170
191
  value["isEnabled"] = False
192
+ value["config_error"] = f"Tool '{tool_name}' has invalid configuration."
171
193
  _ensure_base_tool_config(value)
172
194
  return value
173
195
 
174
196
  value["configuration"] = config
175
197
  return value
198
+
199
+
200
+ def collect_tool_configuration_errors(
201
+ tools: Sequence["ToolBuildConfig[Any]"],
202
+ ) -> list[str]:
203
+ """Return the config_error message for every tool demoted due to an invalid config.
204
+
205
+ `initialize_config_based_on_tool_name` never raises: a tool whose stored
206
+ configuration is invalid is silently disabled with a BaseToolConfig fallback so
207
+ that one broken tool cannot take down the whole space. Callers that need to
208
+ surface these failures instead of ignoring them (e.g. to fail a chat request the
209
+ way an invalid configuration used to) can use this helper to recover the list.
210
+ """
211
+ return [tool.config_error for tool in tools if tool.config_error]
@@ -1,10 +1,16 @@
1
1
  """EventHandler for code interpreter call events — pure state accumulator.
2
2
 
3
- The event handler consumes OpenAI Responses code-interpreter events and keeps a
4
- per-``item_id`` ``(status, text)`` fingerprint to suppress duplicate
5
- progress updates; each genuine transition is published as an
6
- :class:`ActivityProgressUpdate` on the event-handler-owned
7
- :class:`TypedEventBus` (:attr:`activity_bus`).
3
+ The event handler consumes OpenAI Responses code-interpreter lifecycle events
4
+ (``in_progress`` / ``interpreting`` / ``completed``; ``delta`` and ``code.done``
5
+ carry no displayed progress and are ignored) and keeps a per-``correlation_id``
6
+ ``(status, text)`` fingerprint to suppress duplicate progress updates; each
7
+ genuine transition is published as an :class:`ActivityProgressUpdate` on the
8
+ event-handler-owned :class:`TypedEventBus` (:attr:`activity_bus`).
9
+
10
+ Each call surfaces as two correlation ids, mirroring the orchestrator's normal
11
+ tool-call display: a one-shot "Triggered Tool Calls" summary published under
12
+ ``{item_id}-triggered`` on the ``in_progress`` event, and the "Code Execution"
13
+ detail published under ``item_id`` on every lifecycle transition.
8
14
 
9
15
  All SDK I/O (``MessageLog`` create/update, ``Message`` modify) lives in
10
16
  subscribers reacting to the outer-bus :class:`ActivityProgress` event
@@ -56,8 +62,12 @@ class ResponsesCodeInterpreterEventHandler:
56
62
 
57
63
  Publishes :class:`ActivityProgressUpdate` on its own
58
64
  :class:`TypedEventBus` (accessible via :attr:`activity_bus`) for
59
- every genuine state transition, deduplicated by a per-``item_id``
60
- ``(status, text)`` fingerprint.
65
+ every genuine state transition, deduplicated by a per-``correlation_id``
66
+ ``(status, text)`` fingerprint. Lifecycle events (``in_progress`` /
67
+ ``interpreting`` / ``completed``) drive the ``item_id`` detail update;
68
+ the ``in_progress`` event additionally emits a one-shot "Triggered Tool
69
+ Calls" summary under ``{item_id}-triggered``. ``delta`` and ``code.done``
70
+ events are ignored.
61
71
  """
62
72
 
63
73
  def __init__(self) -> None:
@@ -70,35 +80,49 @@ class ResponsesCodeInterpreterEventHandler:
70
80
  return self._activity_bus
71
81
 
72
82
  async def on_code_interpreter_event(self, event: CodeInterpreterCallEvent) -> None:
73
- """Map one OpenAI CI event to an optional progress update publish."""
74
- status: ActivityStatus
75
- if isinstance(event, ResponseCodeInterpreterCallCodeDoneEvent):
76
- text_update = "Code interpreter call completed"
77
- status = "COMPLETED"
78
- elif isinstance(event, ResponseCodeInterpreterCallCompletedEvent):
79
- text_update = "Code interpreter call completed"
80
- status = "COMPLETED"
81
- elif isinstance(event, ResponseCodeInterpreterCallCodeDeltaEvent):
82
- text_update = "Code interpreter call in progress"
83
- status = "RUNNING"
84
- elif isinstance(event, ResponseCodeInterpreterCallInProgressEvent):
85
- text_update = "Code interpreter call in progress"
86
- status = "RUNNING"
87
- else: # ResponseCodeInterpreterCallInterpretingEvent
88
- text_update = "Code interpreter call interpreting"
89
- status = "RUNNING"
90
-
91
- item_id = event.item_id
92
- fingerprint = (status, text_update)
93
- if self._last_by_item.get(item_id) == fingerprint:
83
+ """Map one OpenAI CI event to its progress update publishes."""
84
+ progress = self._progress_for_event(event)
85
+ if progress is None:
94
86
  return
95
- self._last_by_item[item_id] = fingerprint
87
+ status, text_update = progress
96
88
 
89
+ if event.type == "response.code_interpreter_call.in_progress":
90
+ await self._publish_if_changed(
91
+ f"{event.item_id}-triggered",
92
+ "COMPLETED",
93
+ "**Triggered Tool Calls:**\n - Code Execution",
94
+ )
95
+ await self._publish_if_changed(event.item_id, status, text_update)
96
+
97
+ @staticmethod
98
+ def _build_code_execution_message(message: str) -> str:
99
+ return f"**Code Execution**\n {message}".strip()
100
+
101
+ def _progress_for_event(
102
+ self, event: CodeInterpreterCallEvent
103
+ ) -> tuple[ActivityStatus, str] | None:
104
+ """Decode a CI event into its ``(status, text)``, or ``None`` to ignore it."""
105
+ if event.type == "response.code_interpreter_call.completed":
106
+ return "COMPLETED", self._build_code_execution_message("")
107
+ if event.type == "response.code_interpreter_call.in_progress":
108
+ return "RUNNING", self._build_code_execution_message("Writing Code")
109
+ if event.type == "response.code_interpreter_call.interpreting":
110
+ return "RUNNING", self._build_code_execution_message("Executing Code")
111
+ return None
112
+
113
+ async def _publish_if_changed(
114
+ self, correlation_id: str, status: ActivityStatus, text: str
115
+ ) -> None:
116
+ """Publish a progress update unless its ``(status, text)`` is unchanged."""
117
+ fingerprint = (status, text)
118
+ if self._last_by_item.get(correlation_id) == fingerprint:
119
+ return
120
+ self._last_by_item[correlation_id] = fingerprint
97
121
  await self._activity_bus.publish_and_wait_async(
98
122
  ActivityProgressUpdate(
99
- correlation_id=item_id,
123
+ correlation_id=correlation_id,
100
124
  status=status,
101
- text=text_update,
125
+ text=text,
102
126
  )
103
127
  )
104
128
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: unique-toolkit
3
- Version: 2026.30.0.dev2
3
+ Version: 2026.30.0.dev4
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>
@@ -176,7 +176,7 @@ unique_toolkit/agentic/tools/a2a/tool/config.py,sha256=v4rZQU42RjUTC5Md-Cye1rUIW
176
176
  unique_toolkit/agentic/tools/a2a/tool/service.py,sha256=5jOtXSU9oggG1dVUd7PAb3hd_-MLyGnSR5_lUQvYPfA,22160
177
177
  unique_toolkit/agentic/tools/a2a/tool/test/test_service_utils.py,sha256=x4leRxnGgqD-XyXPkW2z1ekv4Ja7EStXd-24LGadPZA,24858
178
178
  unique_toolkit/agentic/tools/agent_chunks_hanlder.py,sha256=eO0g46wZOQlmWqYYVGiszRVe8K2LX-9qW30ZCdGg5eE,1943
179
- unique_toolkit/agentic/tools/config.py,sha256=g_NKV94pq6cZ8nH-C69_BNScyQ-tjRjzYE8IKKqqDag,5726
179
+ unique_toolkit/agentic/tools/config.py,sha256=AOtBn2tL1rIoPPzl1csAHLD5aetYqPL-jAqkIoSBxyE,7468
180
180
  unique_toolkit/agentic/tools/experimental/__init__.py,sha256=ArEcXHGPtMRNsDnsyo9v1fev0EZWdJ6D7NWdPEFLQKM,956
181
181
  unique_toolkit/agentic/tools/experimental/ask_user_tool/__init__.py,sha256=B8srRVw4vMLa4dZE5yoF1Bqpjlv8moh_m-dP2BVRjDc,375
182
182
  unique_toolkit/agentic/tools/experimental/ask_user_tool/config.py,sha256=z95ZaxkMvsmjVaUYWWZrvpD21-Us1KNUrMgXzpF4uo4,5923
@@ -329,7 +329,7 @@ unique_toolkit/experimental/integrations/openai/streaming/event_routing/protocol
329
329
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/protocols/chat_completions.py,sha256=BZogC4EO6BFP-enXOJ535gUB8-US9mshRhXNDCfrs_E,1522
330
330
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/protocols/responses.py,sha256=bM5qSZjJOTWQyPDUPyMasMwZ-Wu7LQKR64OcKVpUY5E,3294
331
331
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/__init__.py,sha256=-8Ey_srOpxX4B_HJhh27h4nZaNC6Y4mk5o8wSLelPwA,847
332
- unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/code_interpreter_event_handler.py,sha256=zGR8kZbwE8owrw_hSqfK0ZFBgKBXzDHY2Bk3ihnvwo8,4666
332
+ unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/code_interpreter_event_handler.py,sha256=3WFT-zuVCrTP01riJY9uuu5U8-tmFUD-XYTZYDrGx4w,6013
333
333
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/complete_with_references.py,sha256=rVcIY7CLPJUVWJrtZDZR5RLd3MnuXbsyL-FdpXoVcjQ,26126
334
334
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/completed_event_handler.py,sha256=N_ZO79XbKSHvUqQFxWsEvCc6w5kglcP4oTq-uRz5w34,1475
335
335
  unique_toolkit/experimental/integrations/openai/streaming/event_routing/responses/stream_event_router.py,sha256=hvQHDPmfYD-ZDRR5W079TFYEgQ-vhIGMNRyagiG6RzM,8280
@@ -406,6 +406,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
406
406
  unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
407
407
  unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
408
408
  unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
409
- unique_toolkit-2026.30.0.dev2.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
410
- unique_toolkit-2026.30.0.dev2.dist-info/METADATA,sha256=5dzAWd8OVSASrP4GIyR8e1NDX86GpCYYE8tzzZC4W3s,7426
411
- unique_toolkit-2026.30.0.dev2.dist-info/RECORD,,
409
+ unique_toolkit-2026.30.0.dev4.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
410
+ unique_toolkit-2026.30.0.dev4.dist-info/METADATA,sha256=4iN85BIBq_wHZenyR9KfKIvdQ9JF699LsQ_PVG3HMFY,7426
411
+ unique_toolkit-2026.30.0.dev4.dist-info/RECORD,,