openhands-agent-server 1.7.2__py3-none-any.whl → 1.7.3__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.
@@ -208,6 +208,32 @@ class ConversationService:
208
208
  )
209
209
  return conversation_info, False
210
210
 
211
+ # Dynamically register tools from client's registry
212
+ if request.tool_module_qualnames:
213
+ import importlib
214
+
215
+ for tool_name, module_qualname in request.tool_module_qualnames.items():
216
+ try:
217
+ # Import the module to trigger tool auto-registration
218
+ importlib.import_module(module_qualname)
219
+ logger.debug(
220
+ f"Tool '{tool_name}' registered via module '{module_qualname}'"
221
+ )
222
+ except ImportError as e:
223
+ logger.warning(
224
+ f"Failed to import module '{module_qualname}' for tool "
225
+ f"'{tool_name}': {e}. Tool will not be available."
226
+ )
227
+ # Continue even if some tools fail to register
228
+ # The agent will fail gracefully if it tries to use unregistered
229
+ # tools
230
+ if request.tool_module_qualnames:
231
+ logger.info(
232
+ f"Dynamically registered {len(request.tool_module_qualnames)} "
233
+ f"tools for conversation {conversation_id}: "
234
+ f"{list(request.tool_module_qualnames.keys())}"
235
+ )
236
+
211
237
  stored = StoredConversation(id=conversation_id, **request.model_dump())
212
238
  event_service = await self._start_event_service(stored)
213
239
  initial_message = request.initial_message
@@ -378,6 +404,36 @@ class ConversationService:
378
404
  "cipher": self.cipher,
379
405
  },
380
406
  )
407
+ # Dynamically register tools when resuming persisted conversations
408
+ if stored.tool_module_qualnames:
409
+ import importlib
410
+
411
+ for (
412
+ tool_name,
413
+ module_qualname,
414
+ ) in stored.tool_module_qualnames.items():
415
+ try:
416
+ # Import the module to trigger tool auto-registration
417
+ importlib.import_module(module_qualname)
418
+ logger.debug(
419
+ f"Tool '{tool_name}' registered via module "
420
+ f"'{module_qualname}' when resuming conversation "
421
+ f"{stored.id}"
422
+ )
423
+ except ImportError as e:
424
+ logger.warning(
425
+ f"Failed to import module '{module_qualname}' for "
426
+ f"tool '{tool_name}' when resuming conversation "
427
+ f"{stored.id}: {e}. Tool will not be available."
428
+ )
429
+ # Continue even if some tools fail to register
430
+ if stored.tool_module_qualnames:
431
+ logger.info(
432
+ f"Dynamically registered "
433
+ f"{len(stored.tool_module_qualnames)} tools when "
434
+ f"resuming conversation {stored.id}: "
435
+ f"{list(stored.tool_module_qualnames.keys())}"
436
+ )
381
437
  await self._start_event_service(stored)
382
438
  except Exception:
383
439
  logger.exception(
@@ -447,6 +503,9 @@ class ConversationService:
447
503
 
448
504
  try:
449
505
  await event_service.start()
506
+ # Save metadata immediately after successful start to ensure persistence
507
+ # even if the system is not shut down gracefully
508
+ await event_service.save_meta()
450
509
  except Exception:
451
510
  # Clean up the event service if startup fails
452
511
  await event_service.close()
@@ -98,6 +98,14 @@ class StartConversationRequest(BaseModel):
98
98
  default_factory=dict,
99
99
  description="Secrets available in the conversation",
100
100
  )
101
+ tool_module_qualnames: dict[str, str] = Field(
102
+ default_factory=dict,
103
+ description=(
104
+ "Mapping of tool names to their module qualnames from the client's "
105
+ "registry. These modules will be dynamically imported on the server "
106
+ "to register the tools for this conversation."
107
+ ),
108
+ )
101
109
 
102
110
 
103
111
  class StoredConversation(StartConversationRequest):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openhands-agent-server
3
- Version: 1.7.2
3
+ Version: 1.7.3
4
4
  Summary: OpenHands Agent Server - REST/WebSocket interface for OpenHands AI Agent
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: aiosqlite>=0.19
@@ -5,7 +5,7 @@ openhands/agent_server/bash_router.py,sha256=9aKNxzdKSlKoYJ3ngvdf4rjv1_iNNmpRoZk
5
5
  openhands/agent_server/bash_service.py,sha256=QgTSyQoxlk52BnZuo35xlX7u7-3xs5BvvaKU3AEva_w,14083
6
6
  openhands/agent_server/config.py,sha256=EQdoN39cOeI63zEpAQ7WyhMpo-9tHNTsLMalU0d4kHw,5479
7
7
  openhands/agent_server/conversation_router.py,sha256=lz-dnfPXrVBiGZ9GhYqfteCWJ4pq7AcnWqxsKWwCfc0,11178
8
- openhands/agent_server/conversation_service.py,sha256=T2mC3Idq5ktaDI2irXnyQlFOrezYKO3Ysvk-8TGkdAo,23994
8
+ openhands/agent_server/conversation_service.py,sha256=g_DKR9NJo5RjSnlITMxKUctwUyTN5tLp6sD8Q1N0tsM,27079
9
9
  openhands/agent_server/dependencies.py,sha256=H3zyOc8uthpXseB3E7rWNccKIj7PlyfcgCYwFvmFq4c,2629
10
10
  openhands/agent_server/desktop_router.py,sha256=OaCmevO33eUo3jTwiXBmQ3uT3ONu4-tqgBfYpZWrHSA,1349
11
11
  openhands/agent_server/desktop_service.py,sha256=iCwQJXK4DvGuBXKOQ1oko60wXkf_pYHCubOzBsd2k60,7415
@@ -16,7 +16,7 @@ openhands/agent_server/file_router.py,sha256=ysDjIKzDNbi7m95JrH6kP6BYcBhTJhTpJVM
16
16
  openhands/agent_server/git_router.py,sha256=g0cVeyJ_mUAuieZ3bbTl5Xvm94FnNwRt07iNBASiXgU,844
17
17
  openhands/agent_server/logging_config.py,sha256=DPPxIl1tUVGiui-JVSKgs73KXPFfDNX2ivGuZSkbLe4,1832
18
18
  openhands/agent_server/middleware.py,sha256=9wuAurN8TCXTCRl6ANIMoFSvHeZsYDLFXIrBH15yhQU,1117
19
- openhands/agent_server/models.py,sha256=d3Y-pJZrAU8D-qN7sjrXqP3bKNDs1T2BFYVzNE1-nhM,9381
19
+ openhands/agent_server/models.py,sha256=R3WSDIQN1burIyV4Dz05YITR9WWcC_pXgZDk-7WG6hw,9723
20
20
  openhands/agent_server/openapi.py,sha256=RJWaOnM9NjzrH-fJi3PoIBv5d0sH5z8zZTdvYzSqoFU,482
21
21
  openhands/agent_server/pub_sub.py,sha256=yPB84Wub7A2uwUWsW_grbxomWmKaWyGuo6dVNUzg1FU,2755
22
22
  openhands/agent_server/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -32,8 +32,8 @@ openhands/agent_server/docker/build.py,sha256=Egsge_yIVCeiJ_gvva6VyPeQtOp0WjZFsW
32
32
  openhands/agent_server/docker/wallpaper.svg,sha256=FR2g_b5mzz0x5EvRTKO93ASnWPagAyeS9RI3vRQBAsw,11532
33
33
  openhands/agent_server/vscode_extensions/openhands-settings/extension.js,sha256=xoCKZ6YXlzlTWnTC52HuzX0sn9s77Vma-47WgEibO88,858
34
34
  openhands/agent_server/vscode_extensions/openhands-settings/package.json,sha256=eCkuBBYEVArEjpp7c_m0H207OCLEygZhBLUEkeFNWOg,289
35
- openhands_agent_server-1.7.2.dist-info/METADATA,sha256=wEymok6mZ4fbVmWmEmeiv2YOqB-Uro2Zs99Jxz0lkh8,468
36
- openhands_agent_server-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- openhands_agent_server-1.7.2.dist-info/entry_points.txt,sha256=uLQzPhqDqe85Dy9DvPiBE2CeqkwCryggr1Ty_mq65NA,70
38
- openhands_agent_server-1.7.2.dist-info/top_level.txt,sha256=jHgVu9I0Blam8BXFgedoGKfglPF8XvW1TsJFIjcgP4E,10
39
- openhands_agent_server-1.7.2.dist-info/RECORD,,
35
+ openhands_agent_server-1.7.3.dist-info/METADATA,sha256=vmWo6337iN8ugke45vPY9Z7Lb3N44-lRwpCXkOdj7tI,468
36
+ openhands_agent_server-1.7.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ openhands_agent_server-1.7.3.dist-info/entry_points.txt,sha256=uLQzPhqDqe85Dy9DvPiBE2CeqkwCryggr1Ty_mq65NA,70
38
+ openhands_agent_server-1.7.3.dist-info/top_level.txt,sha256=jHgVu9I0Blam8BXFgedoGKfglPF8XvW1TsJFIjcgP4E,10
39
+ openhands_agent_server-1.7.3.dist-info/RECORD,,