openhands-agent-server 1.55.0__tar.gz → 1.56.0__tar.gz

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.
Files changed (110) hide show
  1. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/PKG-INFO +1 -1
  2. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/agent_profiles_router.py +5 -18
  3. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/api.py +36 -3
  4. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/bash_router.py +37 -4
  5. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/bash_service.py +14 -7
  6. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions/backend.py +18 -6
  7. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/config.py +23 -3
  8. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/conversation_router.py +44 -6
  9. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/conversation_service.py +197 -32
  10. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/dependencies.py +23 -1
  11. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker/Dockerfile +7 -1
  12. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/proxy.py +9 -1
  13. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/env_parser.py +12 -4
  14. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/event_service.py +105 -21
  15. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/file_router.py +26 -15
  16. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/init_router.py +36 -1
  17. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/mcp_router.py +13 -2
  18. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/models.py +15 -0
  19. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/openai/service.py +26 -6
  20. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/persistence/models.py +4 -2
  21. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/persistence/store.py +10 -2
  22. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/plugins_router.py +72 -0
  23. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/plugins_service.py +23 -0
  24. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/profiles_router.py +50 -14
  25. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/settings_router.py +9 -6
  26. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/subscriber.py +20 -8
  27. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/tool_router.py +3 -0
  28. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/vscode_service.py +9 -1
  29. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/PKG-INFO +1 -1
  30. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/pyproject.toml +1 -1
  31. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/__init__.py +0 -0
  32. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/__main__.py +0 -0
  33. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/_secret_redaction.py +0 -0
  34. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/_secrets_exposure.py +0 -0
  35. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/acp_router.py +0 -0
  36. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/auth_router.py +0 -0
  37. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions/__init__.py +0 -0
  38. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions/bridge.py +0 -0
  39. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions/installed.py +0 -0
  40. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions/manifest.py +0 -0
  41. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions_bridge_router.py +0 -0
  42. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/canvas_extensions_router.py +0 -0
  43. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/conversation_lease.py +0 -0
  44. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/conversation_registry.py +0 -0
  45. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/credential_binding.py +0 -0
  46. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker/build.py +0 -0
  47. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/__init__.py +0 -0
  48. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/mediation.py +0 -0
  49. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/provisioning.py +0 -0
  50. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/registry.py +0 -0
  51. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/routers.py +0 -0
  52. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/docker_runtime/storage.py +0 -0
  53. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/event_router.py +0 -0
  54. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/git_provider_service.py +0 -0
  55. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/git_router.py +0 -0
  56. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/hooks_router.py +0 -0
  57. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/hooks_service.py +0 -0
  58. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/launch.py +0 -0
  59. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/llm_router.py +0 -0
  60. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/local_secret_resolver.py +0 -0
  61. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/local_storage.py +0 -0
  62. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/logging_config.py +0 -0
  63. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/managed_llm_key.py +0 -0
  64. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/mcp_oauth_store.py +0 -0
  65. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/meta_profiles_router.py +0 -0
  66. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/middleware.py +0 -0
  67. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/openai/__init__.py +0 -0
  68. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/openai/models.py +0 -0
  69. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/openai/router.py +0 -0
  70. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/openapi.py +0 -0
  71. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/persistence/__init__.py +0 -0
  72. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/provider_connections_router.py +0 -0
  73. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/pub_sub.py +0 -0
  74. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/py.typed +0 -0
  75. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/runtime_router.py +0 -0
  76. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/server_details_router.py +0 -0
  77. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/session_protocol.py +0 -0
  78. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/session_socket.py +0 -0
  79. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/skills_router.py +0 -0
  80. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/skills_service.py +0 -0
  81. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/sockets.py +0 -0
  82. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/storage/__init__.py +0 -0
  83. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/storage/model.py +0 -0
  84. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/storage/reclaimer.py +0 -0
  85. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/storage/selectors.py +0 -0
  86. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/storage/trash.py +0 -0
  87. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/sub_agents_router.py +0 -0
  88. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/__init__.py +0 -0
  89. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/factory.py +0 -0
  90. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/http_exporter.py +0 -0
  91. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/models.py +0 -0
  92. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/policy.py +0 -0
  93. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/posthog_exporter.py +0 -0
  94. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/sanitizer.py +0 -0
  95. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/service.py +0 -0
  96. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry/sink.py +0 -0
  97. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/telemetry_types.py +0 -0
  98. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/tool_preload_service.py +0 -0
  99. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/utils.py +0 -0
  100. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/vscode_extensions/openhands-settings/extension.js +0 -0
  101. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/vscode_extensions/openhands-settings/package.json +0 -0
  102. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/vscode_router.py +0 -0
  103. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/workspace_router.py +0 -0
  104. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands/agent_server/workspaces_router.py +0 -0
  105. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/SOURCES.txt +0 -0
  106. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/dependency_links.txt +0 -0
  107. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/entry_points.txt +0 -0
  108. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/requires.txt +0 -0
  109. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/openhands_agent_server.egg-info/top_level.txt +0 -0
  110. {openhands_agent_server-1.55.0 → openhands_agent_server-1.56.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openhands-agent-server
3
- Version: 1.55.0
3
+ Version: 1.56.0
4
4
  Summary: OpenHands Agent Server - REST/WebSocket interface for OpenHands AI Agent
5
5
  Project-URL: Source, https://github.com/OpenHands/software-agent-sdk
6
6
  Project-URL: Homepage, https://github.com/OpenHands/software-agent-sdk
@@ -47,6 +47,8 @@ from openhands.sdk.profiles import (
47
47
  ACPAgentProfile,
48
48
  AgentProfile,
49
49
  AgentProfileDiagnostics,
50
+ AgentProfileInfo,
51
+ AgentProfileListResponse,
50
52
  AgentProfileStore,
51
53
  OpenHandsAgentProfile,
52
54
  ProfileLimitExceeded,
@@ -73,22 +75,6 @@ ProfileName = Annotated[
73
75
  ProfileId = Annotated[str, Path(min_length=1, max_length=128)]
74
76
 
75
77
 
76
- class AgentProfileInfo(BaseModel):
77
- """Summary projection of a stored profile (no secret instantiation)."""
78
-
79
- id: str | None = None
80
- name: str
81
- agent_kind: str = "openhands"
82
- revision: int | None = None
83
- llm_profile_ref: str | None = None
84
- mcp_server_refs: list[str] | None = None
85
-
86
-
87
- class AgentProfileListResponse(BaseModel):
88
- profiles: list[AgentProfileInfo]
89
- active_agent_profile_id: str | None = None
90
-
91
-
92
78
  class AgentProfileDetailResponse(BaseModel):
93
79
  name: str
94
80
  profile: dict[str, Any]
@@ -179,8 +165,9 @@ def _seed_default_llm_profile(llm: LLM, cipher: Cipher | None) -> str:
179
165
  unusable ``default`` "ghost" profile (#4031), so we skip the save and leave
180
166
  ``llm_profile_ref="default"`` as a soft/dangling ref — the canvas
181
167
  "LLM not configured" banner and the legible launch-time error already cover
182
- that state, and materialize/dry-run reports it as ``dangling_llm_profile_ref``
183
- rather than raising.
168
+ that state, and materialize reports it rather than raising: ``valid`` false,
169
+ ``llm_profile_resolved`` false and an ``errors`` entry
170
+ ``"LLM profile 'default' not found"``.
184
171
 
185
172
  Existence is checked via ``load()``, not ``list()``: the store resolves a
186
173
  name straight to a filesystem path, so on a case-insensitive filesystem
@@ -33,10 +33,15 @@ from openhands.agent_server.canvas_extensions_bridge_router import (
33
33
  )
34
34
  from openhands.agent_server.canvas_extensions_router import canvas_extensions_router
35
35
  from openhands.agent_server.config import (
36
+ V1_SESSION_API_KEY_ENV,
36
37
  Config,
38
+ export_session_api_key,
37
39
  get_default_config,
38
40
  )
39
- from openhands.agent_server.conversation_lease import _is_pid_alive
41
+ from openhands.agent_server.conversation_lease import (
42
+ ConversationOwnershipLostError,
43
+ _is_pid_alive,
44
+ )
40
45
  from openhands.agent_server.conversation_registry import (
41
46
  create_conversation_registry,
42
47
  )
@@ -45,8 +50,8 @@ from openhands.agent_server.conversation_router import (
45
50
  conversation_router,
46
51
  )
47
52
  from openhands.agent_server.conversation_service import (
53
+ ConversationService,
48
54
  CredentialBindingActivationRequired,
49
- get_default_conversation_service,
50
55
  )
51
56
  from openhands.agent_server.credential_binding import (
52
57
  router as credential_binding_router,
@@ -258,6 +263,7 @@ def _cleanup_stale_tmux_sessions() -> None:
258
263
  @asynccontextmanager
259
264
  async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
260
265
  original_tmux_tmpdir = os.environ.get("TMUX_TMPDIR")
266
+ original_session_api_key = os.environ.get(V1_SESSION_API_KEY_ENV)
261
267
  tmux_tmpdir, tmux_tmpdir_was_defaulted, tmux_tmpdir_was_created = (
262
268
  _ensure_server_tmux_tmpdir()
263
269
  )
@@ -369,7 +375,13 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
369
375
 
370
376
  # Non-deferred (legacy) path: build and enter the conversation
371
377
  # service as part of the lifespan, exactly as before.
372
- service = get_default_conversation_service()
378
+ #
379
+ # A key that came from the config file is visible only in ``config``;
380
+ # in-process callers of this server read it from the environment.
381
+ export_session_api_key(config)
382
+ # Not get_default_conversation_service(): it rebuilds config from OH_*
383
+ # env, ignoring the config passed to create_app().
384
+ service = ConversationService.get_instance(config)
373
385
  mark_initialization_complete()
374
386
  logger.info("Server initialization complete - ready to serve requests")
375
387
 
@@ -428,6 +440,11 @@ async def api_lifespan(api: FastAPI) -> AsyncIterator[None]:
428
440
  os.environ.pop("TMUX_TMPDIR", None)
429
441
  else:
430
442
  os.environ["TMUX_TMPDIR"] = original_tmux_tmpdir
443
+ if os.environ.get(V1_SESSION_API_KEY_ENV) != original_session_api_key:
444
+ if original_session_api_key is None:
445
+ os.environ.pop(V1_SESSION_API_KEY_ENV, None)
446
+ else:
447
+ os.environ[V1_SESSION_API_KEY_ENV] = original_session_api_key
431
448
  if tmux_tmpdir_was_created:
432
449
  # Only the per-server directory this process created; a
433
450
  # user-provided TMUX_TMPDIR is never removed.
@@ -694,6 +711,22 @@ def _add_exception_handlers(api: FastAPI) -> None:
694
711
  ) -> JSONResponse:
695
712
  return JSONResponse(status_code=429, content={"detail": str(exc)})
696
713
 
714
+ @api.exception_handler(ConversationOwnershipLostError)
715
+ async def _ownership_lost_handler(
716
+ _request: Request, _exc: ConversationOwnershipLostError
717
+ ) -> JSONResponse:
718
+ # Another server instance took over this conversation's lease, so the
719
+ # guarded write was refused: a conflict, not a server fault.
720
+ return JSONResponse(
721
+ status_code=409,
722
+ content={
723
+ "detail": (
724
+ "Conversation is owned by another agent server instance; "
725
+ "the write was refused"
726
+ )
727
+ },
728
+ )
729
+
697
730
  @api.exception_handler(CredentialBindingActivationRequired)
698
731
  async def _credential_binding_activation_required_handler(
699
732
  _request: Request,
@@ -3,7 +3,7 @@
3
3
  import logging
4
4
  from datetime import datetime
5
5
  from pathlib import Path
6
- from typing import Annotated, Literal, cast
6
+ from typing import Annotated, Literal
7
7
  from uuid import UUID
8
8
 
9
9
  from fastapi import (
@@ -119,9 +119,42 @@ async def execute_bash_command(
119
119
  _validate_cwd(request, bash_event_service)
120
120
  command, task = await bash_event_service.start_bash_command(request)
121
121
  await task
122
- page = await bash_event_service.search_bash_events(command_id__eq=command.id)
123
- result = cast(BashOutput, page.items[-1])
124
- return result
122
+ return await _collect_bash_output(bash_event_service, command.id)
123
+
124
+
125
+ async def _collect_bash_output(
126
+ bash_event_service: BashEventService, command_id: UUID
127
+ ) -> BashOutput:
128
+ """Join every stored output chunk of a finished command into one result.
129
+
130
+ Output over ``MAX_CONTENT_CHAR_LENGTH`` is stored as several ``BashOutput``
131
+ events and only the final one carries the exit code, so read all pages
132
+ instead of returning the last event of the first page.
133
+ """
134
+ outputs: list[BashOutput] = []
135
+ page_id: str | None = None
136
+ while True:
137
+ page = await bash_event_service.search_bash_events(
138
+ kind__eq="BashOutput", command_id__eq=command_id, page_id=page_id
139
+ )
140
+ outputs.extend(item for item in page.items if isinstance(item, BashOutput))
141
+ page_id = page.next_page_id
142
+ if not page_id:
143
+ break
144
+ if not outputs:
145
+ return BashOutput(command_id=command_id, exit_code=-1)
146
+ # Search returns timestamp order; a stable sort keeps it for equal orders.
147
+ outputs.sort(key=lambda output: output.order)
148
+ final = outputs[-1]
149
+ stdout = "".join(output.stdout for output in outputs if output.stdout)
150
+ stderr = "".join(output.stderr for output in outputs if output.stderr)
151
+ return final.model_copy(
152
+ update={
153
+ "exit_code": -1 if final.exit_code is None else final.exit_code,
154
+ "stdout": stdout or None,
155
+ "stderr": stderr or None,
156
+ }
157
+ )
125
158
 
126
159
 
127
160
  @bash_router.delete("/bash_events")
@@ -4,7 +4,7 @@ import json
4
4
  import os
5
5
  import signal
6
6
  from dataclasses import dataclass, field
7
- from datetime import datetime, timedelta
7
+ from datetime import UTC, datetime, timedelta
8
8
  from pathlib import Path
9
9
  from uuid import UUID
10
10
 
@@ -72,6 +72,10 @@ class BashEventService:
72
72
  # Include microseconds so filename-based ordering reflects emission
73
73
  # order for sub-second bursts (e.g. fast `yes`-style floods that
74
74
  # emit several BashOutput chunks in the same wall-clock second).
75
+ # File names hold UTC times, so convert aware datetimes (e.g. a
76
+ # ``+02:00`` search bound) to UTC first; naive ones are taken as UTC.
77
+ if timestamp.tzinfo is not None:
78
+ timestamp = timestamp.astimezone(UTC)
75
79
  return timestamp.strftime("%Y%m%d%H%M%S%f")
76
80
 
77
81
  def _get_event_filename(self, event: BashEventBase) -> str:
@@ -229,13 +233,13 @@ class BashEventService:
229
233
  start_index = i
230
234
  break
231
235
 
232
- page_slice = matched[start_index : start_index + limit]
233
- next_page_id = None
234
- if start_index + limit < len(matched):
235
- next_page_id = matched[start_index + limit]
236
-
236
+ # Filter before counting toward ``limit``: slicing file names first let
237
+ # ``order__gt`` empty a page while ``next_page_id`` was still set.
238
+ # The cursor is the next event that passes the filter, so a page is
239
+ # never followed by an empty one.
237
240
  page_events: list[BashEventBase] = []
238
- for name in page_slice:
241
+ next_page_id = None
242
+ for name in matched[start_index:]:
239
243
  event = self._load_event_from_file(self.bash_events_dir / name)
240
244
  if event is None:
241
245
  continue
@@ -244,6 +248,9 @@ class BashEventService:
244
248
  event_order = getattr(event, "order", None)
245
249
  if event_order is not None and event_order <= order__gt:
246
250
  continue
251
+ if len(page_events) >= limit:
252
+ next_page_id = name
253
+ break
247
254
  page_events.append(event)
248
255
 
249
256
  return BashEventPage(items=page_events, next_page_id=next_page_id)
@@ -1,6 +1,7 @@
1
1
  """Owned lifecycle for optional Canvas App backend subprocesses."""
2
2
 
3
3
  import asyncio
4
+ import gzip
4
5
  import hashlib
5
6
  import os
6
7
  import platform
@@ -12,6 +13,7 @@ import tempfile
12
13
  import time
13
14
  import urllib.error
14
15
  import urllib.request
16
+ import zlib
15
17
  from collections import deque
16
18
  from pathlib import Path, PurePosixPath
17
19
  from typing import Final, Literal
@@ -404,12 +406,22 @@ class CanvasExtensionBackendManager:
404
406
  )
405
407
  )
406
408
  try:
407
- await asyncio.to_thread(
408
- self._extract_archive,
409
- archive,
410
- temporary,
411
- artifact.strip_components,
412
- )
409
+ try:
410
+ await asyncio.to_thread(
411
+ self._extract_archive,
412
+ archive,
413
+ temporary,
414
+ artifact.strip_components,
415
+ )
416
+ except (
417
+ tarfile.TarError,
418
+ gzip.BadGzipFile,
419
+ EOFError,
420
+ zlib.error,
421
+ ) as exc:
422
+ raise ValueError(
423
+ "backend artifact is not a valid gzip tar archive"
424
+ ) from exc
413
425
  try:
414
426
  os.replace(temporary, artifact_dir)
415
427
  except OSError:
@@ -204,8 +204,11 @@ class TelemetrySpec(BaseModel):
204
204
  default=None,
205
205
  description=(
206
206
  "Key used to pseudonymize conversation identifiers. Falls back to "
207
- "a per-process random salt, which keeps pseudonyms stable within a "
208
- "run but unlinkable across runs."
207
+ "the server's secret key (OH_SECRET_KEY, which defaults to the "
208
+ "first session API key), so pseudonyms stay stable and linkable "
209
+ "across restarts until that key changes. Only when there is no "
210
+ "secret key either is a random key generated per process, which "
211
+ "makes pseudonyms unlinkable across runs."
209
212
  ),
210
213
  )
211
214
  max_queue_size: int = Field(
@@ -561,6 +564,22 @@ def _read_config_file(path: Path) -> dict[str, Any]:
561
564
  return data
562
565
 
563
566
 
567
+ def export_session_api_key(config: Config) -> None:
568
+ """Publish the server's first session key to the process environment.
569
+
570
+ In-process callers of this server read the key from the environment:
571
+ the ``start_child_conversation`` tool and the managed LLM key refresh look
572
+ at ``OH_SESSION_API_KEYS_0`` / ``SESSION_API_KEY``, which is the contract
573
+ the Docker and remote runtimes meet by setting one of them before the
574
+ server boots. A key delivered through a config file or ``POST /api/init``
575
+ exists only in :class:`Config` until it is exported here. The effective
576
+ key always wins, so a dormant process that booted with one key and was
577
+ initialized with another ends up with the one it authenticates with.
578
+ """
579
+ if config.session_api_keys:
580
+ os.environ[V1_SESSION_API_KEY_ENV] = config.session_api_keys[0]
581
+
582
+
564
583
  def load_config(config_path: Path | None = None) -> Config:
565
584
  """Load agent-server config from JSON file and environment variables.
566
585
 
@@ -578,7 +597,8 @@ def load_config(config_path: Path | None = None) -> Config:
578
597
  if env_data is MISSING:
579
598
  data = file_data
580
599
  else:
581
- data = merge(file_data, env_data)
600
+ # An explicit environment null (OH_<FIELD>_IS_NONE=1) clears a file value.
601
+ data = merge(file_data, env_data, none_overrides=True)
582
602
 
583
603
  if not data:
584
604
  return Config()
@@ -26,6 +26,7 @@ from openhands.agent_server.conversation_registry import ConversationRegistry
26
26
  from openhands.agent_server.conversation_service import (
27
27
  ConversationService,
28
28
  InvalidParentConversation,
29
+ UnavailableAgentTool,
29
30
  )
30
31
  from openhands.agent_server.dependencies import get_conversation_service
31
32
  from openhands.agent_server.launch import launch_http_exception
@@ -43,6 +44,8 @@ from openhands.agent_server.models import (
43
44
  NavigateConversationRequest,
44
45
  SetConfirmationPolicyRequest,
45
46
  SetSecurityAnalyzerRequest,
47
+ StartChildConversationRequest,
48
+ StartChildConversationResponse,
46
49
  StartConversationRequest,
47
50
  StartGoalRequest,
48
51
  Success,
@@ -283,13 +286,12 @@ async def get_conversation_agent_final_response(
283
286
  @conversation_router.get("")
284
287
  async def batch_get_conversations(
285
288
  request: Request,
286
- ids: Annotated[list[UUID], Query()],
289
+ ids: Annotated[list[UUID], Query(max_length=99)],
287
290
  include_skills: Annotated[bool, Query(title=INCLUDE_SKILLS_PARAM_TITLE)] = False,
288
291
  conversation_service: ConversationService = Depends(get_conversation_service),
289
292
  ) -> list[ConversationInfo | None]:
290
- """Get a batch of conversations given their ids, returning null for
291
- any missing item"""
292
- assert len(ids) < 100
293
+ """Get a batch of up to 99 conversations given their ids, returning null
294
+ for any missing item"""
293
295
  conversations = await conversation_service.batch_get_conversations(ids)
294
296
  conversations = [
295
297
  _with_runtime_info(request, conversation) if conversation is not None else None
@@ -345,7 +347,7 @@ async def start_conversation(
345
347
  raise HTTPException(
346
348
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(e)
347
349
  ) from e
348
- except InvalidParentConversation as e:
350
+ except (InvalidParentConversation, UnavailableAgentTool) as e:
349
351
  raise HTTPException(
350
352
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(e)
351
353
  ) from e
@@ -759,7 +761,7 @@ async def ask_agent(
759
761
  """Ask the agent a simple question without affecting conversation state."""
760
762
  response = await conversation_service.ask_agent(conversation_id, request.question)
761
763
  if response is None:
762
- raise HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)
764
+ raise HTTPException(status.HTTP_404_NOT_FOUND, detail="Conversation not found")
763
765
  return AskAgentResponse(response=response)
764
766
 
765
767
 
@@ -826,6 +828,42 @@ async def fork_conversation(
826
828
  return info
827
829
 
828
830
 
831
+ @conversation_router.post(
832
+ "/{conversation_id}/children",
833
+ responses={
834
+ 201: {"description": "Child conversation created"},
835
+ 404: {"description": "Parent conversation not found"},
836
+ 429: {"description": "Server conversation run capacity is full"},
837
+ },
838
+ status_code=status.HTTP_201_CREATED,
839
+ )
840
+ async def start_child_conversation(
841
+ conversation_id: UUID,
842
+ request: Annotated[StartChildConversationRequest, Body()],
843
+ conversation_service: ConversationService = Depends(get_conversation_service),
844
+ ) -> StartChildConversationResponse:
845
+ """Start a child conversation of ``conversation_id`` on this server.
846
+
847
+ The child inherits the parent's configuration and workspace (optionally
848
+ isolated in a git worktree), is linked via ``parent_conversation_id`` and
849
+ receives ``task`` as its first user message. This is the default launcher
850
+ behind the ``start_child_conversation`` tool.
851
+ """
852
+ try:
853
+ result = await conversation_service.start_child_conversation(
854
+ conversation_id, request
855
+ )
856
+ except ValueError as exc:
857
+ raise HTTPException(
858
+ status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(exc)
859
+ ) from exc
860
+ if result is None:
861
+ raise HTTPException(
862
+ status.HTTP_404_NOT_FOUND, detail="Parent conversation not found"
863
+ )
864
+ return result
865
+
866
+
829
867
  @conversation_router.post(
830
868
  "/{conversation_id}/navigate",
831
869
  responses={