openhands-sdk 1.4.0__tar.gz → 1.5.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 (171) hide show
  1. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/PKG-INFO +1 -1
  2. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/agent.py +99 -3
  3. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/system_prompt.j2 +1 -0
  4. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/agent_context.py +26 -1
  5. openhands_sdk-1.5.0/openhands/sdk/context/prompts/templates/system_message_suffix.j2 +32 -0
  6. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/conversation.py +1 -1
  7. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/conversation_stats.py +38 -1
  8. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/secret_registry.py +1 -6
  9. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/conversation_state.py +8 -0
  10. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/llm.py +20 -11
  11. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/options/responses_options.py +4 -2
  12. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/retry_mixin.py +7 -2
  13. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/telemetry.py +1 -1
  14. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/verified_models.py +13 -8
  15. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/logger/logger.py +7 -0
  16. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/definition.py +2 -2
  17. openhands_sdk-1.5.0/openhands/sdk/secret/__init__.py +19 -0
  18. openhands_sdk-1.4.0/openhands/sdk/conversation/secret_source.py → openhands_sdk-1.5.0/openhands/sdk/secret/secrets.py +6 -0
  19. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/truncate.py +1 -1
  20. openhands_sdk-1.5.0/openhands/sdk/utils/visualize.py +58 -0
  21. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands_sdk.egg-info/PKG-INFO +1 -1
  22. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands_sdk.egg-info/SOURCES.txt +4 -2
  23. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/pyproject.toml +1 -1
  24. openhands_sdk-1.4.0/openhands/sdk/context/prompts/templates/system_message_suffix.j2 +0 -16
  25. openhands_sdk-1.4.0/openhands/sdk/utils/visualize.py +0 -23
  26. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/__init__.py +0 -0
  27. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/__init__.py +0 -0
  28. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/base.py +0 -0
  29. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/in_context_learning_example.j2 +0 -0
  30. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/in_context_learning_example_suffix.j2 +0 -0
  31. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/security_policy.j2 +0 -0
  32. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/security_risk_assessment.j2 +0 -0
  33. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/system_prompt_interactive.j2 +0 -0
  34. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/system_prompt_long_horizon.j2 +0 -0
  35. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/system_prompt_planning.j2 +0 -0
  36. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/prompts/system_prompt_tech_philosophy.j2 +0 -0
  37. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/agent/utils.py +0 -0
  38. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/__init__.py +0 -0
  39. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/__init__.py +0 -0
  40. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/base.py +0 -0
  41. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/llm_summarizing_condenser.py +0 -0
  42. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/no_op_condenser.py +0 -0
  43. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/pipeline_condenser.py +0 -0
  44. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/condenser/prompts/summarizing_prompt.j2 +0 -0
  45. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/prompts/__init__.py +0 -0
  46. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/prompts/prompt.py +0 -0
  47. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/prompts/templates/ask_agent_template.j2 +0 -0
  48. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/prompts/templates/skill_knowledge_info.j2 +0 -0
  49. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/skills/__init__.py +0 -0
  50. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/skills/exceptions.py +0 -0
  51. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/skills/skill.py +0 -0
  52. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/skills/trigger.py +0 -0
  53. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/skills/types.py +0 -0
  54. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/context/view.py +0 -0
  55. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/__init__.py +0 -0
  56. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/base.py +0 -0
  57. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/event_store.py +0 -0
  58. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/events_list_base.py +0 -0
  59. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/exceptions.py +0 -0
  60. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/fifo_lock.py +0 -0
  61. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/impl/__init__.py +0 -0
  62. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/impl/local_conversation.py +0 -0
  63. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/impl/remote_conversation.py +0 -0
  64. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/persistence_const.py +0 -0
  65. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/response_utils.py +0 -0
  66. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/serialization_diff.py +0 -0
  67. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/state.py +0 -0
  68. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/stuck_detector.py +0 -0
  69. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/title_utils.py +0 -0
  70. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/types.py +0 -0
  71. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/visualizer/__init__.py +0 -0
  72. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/visualizer/base.py +0 -0
  73. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/conversation/visualizer/default.py +0 -0
  74. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/__init__.py +0 -0
  75. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/base.py +0 -0
  76. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/impl/__init__.py +0 -0
  77. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/impl/agent_finished.py +0 -0
  78. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/impl/empty_patch.py +0 -0
  79. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/critic/impl/pass_critic.py +0 -0
  80. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/__init__.py +0 -0
  81. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/base.py +0 -0
  82. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/condenser.py +0 -0
  83. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/conversation_error.py +0 -0
  84. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_completion_log.py +0 -0
  85. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_convertible/__init__.py +0 -0
  86. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_convertible/action.py +0 -0
  87. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_convertible/message.py +0 -0
  88. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_convertible/observation.py +0 -0
  89. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/llm_convertible/system.py +0 -0
  90. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/token.py +0 -0
  91. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/types.py +0 -0
  92. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/event/user_action.py +0 -0
  93. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/git/exceptions.py +0 -0
  94. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/git/git_changes.py +0 -0
  95. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/git/git_diff.py +0 -0
  96. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/git/models.py +0 -0
  97. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/git/utils.py +0 -0
  98. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/io/__init__.py +0 -0
  99. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/io/base.py +0 -0
  100. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/io/local.py +0 -0
  101. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/io/memory.py +0 -0
  102. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/__init__.py +0 -0
  103. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/exceptions/__init__.py +0 -0
  104. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/exceptions/classifier.py +0 -0
  105. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/exceptions/mapping.py +0 -0
  106. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/exceptions/types.py +0 -0
  107. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/llm_registry.py +0 -0
  108. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/llm_response.py +0 -0
  109. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/message.py +0 -0
  110. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/mixins/fn_call_converter.py +0 -0
  111. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/mixins/non_native_fc.py +0 -0
  112. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/options/__init__.py +0 -0
  113. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/options/chat_options.py +0 -0
  114. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/options/common.py +0 -0
  115. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/router/__init__.py +0 -0
  116. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/router/base.py +0 -0
  117. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/router/impl/multimodal.py +0 -0
  118. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/router/impl/random.py +0 -0
  119. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/streaming.py +0 -0
  120. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/metrics.py +0 -0
  121. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/model_features.py +0 -0
  122. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/model_info.py +0 -0
  123. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/llm/utils/unverified_models.py +0 -0
  124. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/logger/__init__.py +0 -0
  125. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/logger/rolling.py +0 -0
  126. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/__init__.py +0 -0
  127. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/client.py +0 -0
  128. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/exceptions.py +0 -0
  129. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/tool.py +0 -0
  130. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/mcp/utils.py +0 -0
  131. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/observability/__init__.py +0 -0
  132. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/observability/laminar.py +0 -0
  133. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/observability/utils.py +0 -0
  134. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/py.typed +0 -0
  135. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/security/__init__.py +0 -0
  136. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/security/analyzer.py +0 -0
  137. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/security/confirmation_policy.py +0 -0
  138. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/security/llm_analyzer.py +0 -0
  139. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/security/risk.py +0 -0
  140. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/__init__.py +0 -0
  141. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/builtins/__init__.py +0 -0
  142. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/builtins/finish.py +0 -0
  143. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/builtins/think.py +0 -0
  144. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/registry.py +0 -0
  145. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/schema.py +0 -0
  146. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/spec.py +0 -0
  147. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/tool/tool.py +0 -0
  148. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/__init__.py +0 -0
  149. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/async_executor.py +0 -0
  150. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/async_utils.py +0 -0
  151. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/cipher.py +0 -0
  152. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/command.py +0 -0
  153. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/deprecation.py +0 -0
  154. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/github.py +0 -0
  155. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/json.py +0 -0
  156. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/models.py +0 -0
  157. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/pydantic_diff.py +0 -0
  158. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/utils/pydantic_secrets.py +0 -0
  159. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/__init__.py +0 -0
  160. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/base.py +0 -0
  161. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/local.py +0 -0
  162. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/models.py +0 -0
  163. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/remote/__init__.py +0 -0
  164. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/remote/async_remote_workspace.py +0 -0
  165. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/remote/base.py +0 -0
  166. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/remote/remote_workspace_mixin.py +0 -0
  167. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands/sdk/workspace/workspace.py +0 -0
  168. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands_sdk.egg-info/dependency_links.txt +0 -0
  169. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands_sdk.egg-info/requires.txt +0 -0
  170. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/openhands_sdk.egg-info/top_level.txt +0 -0
  171. {openhands_sdk-1.4.0 → openhands_sdk-1.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openhands-sdk
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: OpenHands SDK - Core functionality for building AI agents
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: deprecation>=2.1.0
@@ -186,7 +186,7 @@ class Agent(AgentBase):
186
186
  )
187
187
  on_event(error_message)
188
188
  return
189
- except LLMContextWindowExceedError:
189
+ except LLMContextWindowExceedError as e:
190
190
  # If condenser is available and handles requests, trigger condensation
191
191
  if (
192
192
  self.condenser is not None
@@ -197,8 +197,9 @@ class Agent(AgentBase):
197
197
  )
198
198
  on_event(CondensationRequest())
199
199
  return
200
- # No condenser available; re-raise for client handling
201
- raise
200
+ # No condenser available or doesn't handle requests; log helpful warning
201
+ self._log_context_window_exceeded_warning()
202
+ raise e
202
203
 
203
204
  # LLMResponse already contains the converted message and metrics snapshot
204
205
  message: Message = llm_response.message
@@ -516,3 +517,98 @@ class Agent(AgentBase):
516
517
  ]["token_ids"],
517
518
  )
518
519
  on_event(token_event)
520
+
521
+ def _log_context_window_exceeded_warning(self) -> None:
522
+ """Log a helpful warning when context window is exceeded without a condenser."""
523
+ if self.condenser is None:
524
+ logger.warning(
525
+ "\n"
526
+ "=" * 80 + "\n"
527
+ "⚠️ CONTEXT WINDOW EXCEEDED ERROR\n"
528
+ "=" * 80 + "\n"
529
+ "\n"
530
+ "The LLM's context window has been exceeded, but no condenser is "
531
+ "configured.\n"
532
+ "\n"
533
+ "Current configuration:\n"
534
+ f" • Condenser: None\n"
535
+ f" • LLM Model: {self.llm.model}\n"
536
+ "\n"
537
+ "To prevent this error, configure a condenser to automatically "
538
+ "summarize\n"
539
+ "conversation history when it gets too long.\n"
540
+ "\n"
541
+ "Example configuration:\n"
542
+ "\n"
543
+ " from openhands.sdk import Agent, LLM\n"
544
+ " from openhands.sdk.context.condenser import "
545
+ "LLMSummarizingCondenser\n"
546
+ "\n"
547
+ " agent = Agent(\n"
548
+ " llm=LLM(model='your-model'),\n"
549
+ " condenser=LLMSummarizingCondenser(\n"
550
+ " llm=LLM(model='your-model'), # Can use same or "
551
+ "cheaper model\n"
552
+ " max_size=120, # Maximum events before condensation\n"
553
+ " keep_first=4 # Number of initial events to preserve\n"
554
+ " )\n"
555
+ " )\n"
556
+ "\n"
557
+ "For more information, see: "
558
+ "https://docs.openhands.dev/sdk/guides/context-condenser\n"
559
+ "=" * 80
560
+ )
561
+ else:
562
+ condenser_type = type(self.condenser).__name__
563
+ handles_requests = self.condenser.handles_condensation_requests()
564
+ condenser_config = self.condenser.model_dump(
565
+ exclude={"llm"}, exclude_none=True
566
+ )
567
+ condenser_llm_obj = getattr(self.condenser, "llm", None)
568
+ condenser_llm = (
569
+ condenser_llm_obj.model if condenser_llm_obj is not None else "N/A"
570
+ )
571
+
572
+ logger.warning(
573
+ "\n"
574
+ "=" * 80 + "\n"
575
+ "⚠️ CONTEXT WINDOW EXCEEDED ERROR\n"
576
+ "=" * 80 + "\n"
577
+ "\n"
578
+ "The LLM's context window has been exceeded.\n"
579
+ "\n"
580
+ "Current configuration:\n"
581
+ f" • Condenser Type: {condenser_type}\n"
582
+ f" • Handles Condensation Requests: {handles_requests}\n"
583
+ f" • Condenser LLM: {condenser_llm}\n"
584
+ f" • Agent LLM Model: {self.llm.model}\n"
585
+ f" • Condenser Config: {json.dumps(condenser_config, indent=4)}\n"
586
+ "\n"
587
+ "Your condenser is configured but does not handle condensation "
588
+ "requests\n"
589
+ "(handles_condensation_requests() returned False).\n"
590
+ "\n"
591
+ "To fix this:\n"
592
+ " 1. Use LLMSummarizingCondenser which handles condensation "
593
+ "requests, OR\n"
594
+ " 2. Implement handles_condensation_requests() in your custom "
595
+ "condenser\n"
596
+ "\n"
597
+ "Example with LLMSummarizingCondenser:\n"
598
+ "\n"
599
+ " from openhands.sdk.context.condenser import "
600
+ "LLMSummarizingCondenser\n"
601
+ "\n"
602
+ " agent = Agent(\n"
603
+ " llm=LLM(model='your-model'),\n"
604
+ " condenser=LLMSummarizingCondenser(\n"
605
+ " llm=LLM(model='your-model'),\n"
606
+ " max_size=120,\n"
607
+ " keep_first=4\n"
608
+ " )\n"
609
+ " )\n"
610
+ "\n"
611
+ "For more information, see: "
612
+ "https://docs.openhands.dev/sdk/guides/context-condenser\n"
613
+ "=" * 80
614
+ )
@@ -52,6 +52,7 @@ You are OpenHands agent, a helpful AI assistant that can interact with a compute
52
52
  * For bug fixes: Create tests to verify issues before implementing fixes
53
53
  * For new features: Consider test-driven development when appropriate
54
54
  * Do NOT write tests for documentation changes, README updates, configuration files, or other non-functionality changes
55
+ * Do not use mocks in tests unless strictly necessary and justify their use when they are used. You must always test real code paths in tests, NOT mocks.
55
56
  * If the repository lacks testing infrastructure and implementing tests would require extensive setup, consult with the user before investing time in building testing infrastructure
56
57
  * If the environment is not set up to run tests, consult with the user first before investing time to install all dependencies
57
58
  4. IMPLEMENTATION:
@@ -1,4 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  import pathlib
4
+ from collections.abc import Mapping
2
5
 
3
6
  from pydantic import BaseModel, Field, field_validator, model_validator
4
7
 
@@ -11,6 +14,7 @@ from openhands.sdk.context.skills import (
11
14
  )
12
15
  from openhands.sdk.llm import Message, TextContent
13
16
  from openhands.sdk.logger import get_logger
17
+ from openhands.sdk.secret import SecretValue
14
18
 
15
19
 
16
20
  logger = get_logger(__name__)
@@ -65,6 +69,15 @@ class AgentContext(BaseModel):
65
69
  "This allows you to get the latest skills without SDK updates."
66
70
  ),
67
71
  )
72
+ secrets: Mapping[str, SecretValue] | None = Field(
73
+ default=None,
74
+ description=(
75
+ "Dictionary mapping secret keys to values or secret sources. "
76
+ "Secrets are used for authentication and sensitive data handling. "
77
+ "Values can be either strings or SecretSource instances "
78
+ "(str | SecretSource)."
79
+ ),
80
+ )
68
81
 
69
82
  @field_validator("skills")
70
83
  @classmethod
@@ -123,6 +136,16 @@ class AgentContext(BaseModel):
123
136
  logger.warning(f"Failed to load public skills: {str(e)}")
124
137
  return self
125
138
 
139
+ def get_secret_names(self) -> list[str]:
140
+ """Get the list of secret names from the secrets field.
141
+
142
+ Returns:
143
+ List of secret names. Returns an empty list if no secrets are configured.
144
+ """
145
+ if not self.secrets:
146
+ return []
147
+ return list(self.secrets.keys())
148
+
126
149
  def get_system_message_suffix(self) -> str | None:
127
150
  """Get the system message with repo skill content and custom suffix.
128
151
 
@@ -135,13 +158,15 @@ class AgentContext(BaseModel):
135
158
  repo_skills = [s for s in self.skills if s.trigger is None]
136
159
  logger.debug(f"Triggered {len(repo_skills)} repository skills: {repo_skills}")
137
160
  # Build the workspace context information
138
- if repo_skills:
161
+ secret_names = self.get_secret_names()
162
+ if repo_skills or self.system_message_suffix or secret_names:
139
163
  # TODO(test): add a test for this rendering to make sure they work
140
164
  formatted_text = render_template(
141
165
  prompt_dir=str(PROMPT_DIR),
142
166
  template_name="system_message_suffix.j2",
143
167
  repo_skills=repo_skills,
144
168
  system_message_suffix=self.system_message_suffix or "",
169
+ secret_names=secret_names,
145
170
  ).strip()
146
171
  return formatted_text
147
172
  elif self.system_message_suffix and self.system_message_suffix.strip():
@@ -0,0 +1,32 @@
1
+ {% if repo_skills %}
2
+ <REPO_CONTEXT>
3
+ The following information has been included based on several files defined in user's repository.
4
+ Please follow them while working.
5
+
6
+ {% for agent_info in repo_skills %}
7
+ [BEGIN context from [{{ agent_info.name }}]]
8
+ {{ agent_info.content }}
9
+ [END Context]
10
+ {% endfor %}
11
+ </REPO_CONTEXT>
12
+ {% endif %}
13
+ {% if system_message_suffix %}
14
+
15
+ {{ system_message_suffix }}
16
+ {% endif %}
17
+ {% if secret_names %}
18
+ <CUSTOM_SECRETS>
19
+ ### Credential Access
20
+ * Automatic secret injection: When you reference a registered secret key in your bash command, the secret value will be automatically exported as an environment variable before your command executes.
21
+ * How to use secrets: Simply reference the secret key in your command (e.g., `echo ${GITHUB_TOKEN:0:8}` or `curl -H "Authorization: Bearer $API_KEY" https://api.example.com`). The system will detect the key name in your command text and export it as environment variable before it executes your command.
22
+ * Secret detection: The system performs case-insensitive matching to find secret keys in your command text. If a registered secret key appears anywhere in your command, its value will be made available as an environment variable.
23
+ * Security: Secret values are automatically masked in command output to prevent accidental exposure. You will see `<secret-hidden>` instead of the actual secret value in the output.
24
+ * Refreshing expired secrets: Some secrets (like GITHUB_TOKEN) may be updated periodically or expire over time. If a secret stops working (e.g., authentication failures), try using it again in a new command - the system should automatically use the refreshed value. For example, if GITHUB_TOKEN was used in a git remote URL and later expired, you can update the remote URL with the current token: `git remote set-url origin https://${GITHUB_TOKEN}@github.com/username/repo.git` to pick up the refreshed token value.
25
+ * If it still fails, report it to the user.
26
+
27
+ You have access to the following environment variables
28
+ {% for secret_name in secret_names %}
29
+ * **${{ secret_name }}**
30
+ {% endfor %}
31
+ </CUSTOM_SECRETS>
32
+ {% endif %}
@@ -3,7 +3,6 @@ from typing import TYPE_CHECKING, Self, overload
3
3
 
4
4
  from openhands.sdk.agent.base import AgentBase
5
5
  from openhands.sdk.conversation.base import BaseConversation
6
- from openhands.sdk.conversation.secret_registry import SecretValue
7
6
  from openhands.sdk.conversation.types import (
8
7
  ConversationCallbackType,
9
8
  ConversationID,
@@ -14,6 +13,7 @@ from openhands.sdk.conversation.visualizer import (
14
13
  DefaultConversationVisualizer,
15
14
  )
16
15
  from openhands.sdk.logger import get_logger
16
+ from openhands.sdk.secret import SecretValue
17
17
  from openhands.sdk.workspace import LocalWorkspace, RemoteWorkspace
18
18
 
19
19
 
@@ -1,4 +1,6 @@
1
- from pydantic import BaseModel, Field, PrivateAttr
1
+ from typing import Any
2
+
3
+ from pydantic import BaseModel, Field, PrivateAttr, model_serializer
2
4
 
3
5
  from openhands.sdk.llm.llm_registry import RegistryEvent
4
6
  from openhands.sdk.llm.utils.metrics import Metrics
@@ -18,6 +20,41 @@ class ConversationStats(BaseModel):
18
20
 
19
21
  _restored_usage_ids: set[str] = PrivateAttr(default_factory=set)
20
22
 
23
+ @model_serializer(mode="wrap")
24
+ def _serialize_with_context(self, serializer: Any, info: Any) -> dict[str, Any]:
25
+ """Serialize metrics based on context.
26
+
27
+ By default, preserves full metrics history including costs,
28
+ response_latencies, and token_usages lists for persistence.
29
+
30
+ When context={'use_snapshot': True} is passed, converts Metrics to
31
+ MetricsSnapshot format to minimize payload size for network transmission.
32
+
33
+ Args:
34
+ serializer: Pydantic's default serializer
35
+ info: Serialization info containing context
36
+
37
+ Returns:
38
+ Dictionary with metrics serialized based on context
39
+ """
40
+ # Get the default serialization
41
+ data = serializer(self)
42
+
43
+ # Check if we should use snapshot serialization
44
+ context = info.context if info else None
45
+ use_snapshot = context.get("use_snapshot", False) if context else False
46
+
47
+ if use_snapshot and "usage_to_metrics" in data:
48
+ # Replace each Metrics with its snapshot
49
+ usage_to_snapshots = {}
50
+ for usage_id, metrics in self.usage_to_metrics.items():
51
+ snapshot = metrics.get_snapshot()
52
+ usage_to_snapshots[usage_id] = snapshot.model_dump()
53
+
54
+ data["usage_to_metrics"] = usage_to_snapshots
55
+
56
+ return data
57
+
21
58
  def get_combined_metrics(self) -> Metrics:
22
59
  total_metrics = Metrics()
23
60
  for metrics in self.usage_to_metrics.values():
@@ -4,18 +4,13 @@ from collections.abc import Mapping
4
4
 
5
5
  from pydantic import Field, PrivateAttr, SecretStr
6
6
 
7
- from openhands.sdk.conversation.secret_source import (
8
- SecretSource,
9
- StaticSecret,
10
- )
11
7
  from openhands.sdk.logger import get_logger
8
+ from openhands.sdk.secret import SecretSource, SecretValue, StaticSecret
12
9
  from openhands.sdk.utils.models import OpenHandsModel
13
10
 
14
11
 
15
12
  logger = get_logger(__name__)
16
13
 
17
- SecretValue = str | SecretSource
18
-
19
14
 
20
15
  class SecretRegistry(OpenHandsModel):
21
16
  """Manages secrets and injects them into bash commands when needed.
@@ -49,6 +49,14 @@ class ConversationStateUpdateEvent(Event):
49
49
 
50
50
  @field_validator("value")
51
51
  def validate_value(cls, value, info):
52
+ # Prevent circular import
53
+ from openhands.sdk.conversation.conversation_stats import ConversationStats
54
+
55
+ # For ConversationStats, use snapshot serialization to avoid
56
+ # sending lengthy lists over WebSocket
57
+ if isinstance(value, ConversationStats):
58
+ return value.model_dump(mode="json", context={"use_snapshot": True})
59
+
52
60
  key = info.data.get("key")
53
61
  if key is None:
54
62
  # Allow value without key for flexibility
@@ -260,7 +260,7 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
260
260
  "Requires verified OpenAI organization. Only sent when explicitly set.",
261
261
  )
262
262
  enable_encrypted_reasoning: bool = Field(
263
- default=False,
263
+ default=True,
264
264
  description="If True, ask for ['reasoning.encrypted_content'] "
265
265
  "in Responses API include.",
266
266
  )
@@ -315,7 +315,9 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
315
315
  # =========================================================================
316
316
  # Internal fields (excluded from dumps)
317
317
  # =========================================================================
318
- retry_listener: SkipJsonSchema[Callable[[int, int], None] | None] = Field(
318
+ retry_listener: SkipJsonSchema[
319
+ Callable[[int, int, BaseException | None], None] | None
320
+ ] = Field(
319
321
  default=None,
320
322
  exclude=True,
321
323
  )
@@ -369,8 +371,9 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
369
371
  if model_val.startswith("openhands/"):
370
372
  model_name = model_val.removeprefix("openhands/")
371
373
  d["model"] = f"litellm_proxy/{model_name}"
372
- # Set base_url (default to the app proxy when base_url is unset)
373
- d["base_url"] = d.get("base_url", "https://llm-proxy.app.all-hands.dev/")
374
+ # Set base_url (default to the app proxy when base_url is unset or None)
375
+ # Use `or` instead of dict.get() to handle explicit None values
376
+ d["base_url"] = d.get("base_url") or "https://llm-proxy.app.all-hands.dev/"
374
377
 
375
378
  # HF doesn't support the OpenAI default value for top_p (1)
376
379
  if model_val.startswith("huggingface"):
@@ -426,6 +429,14 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
426
429
  )
427
430
  return self
428
431
 
432
+ def _retry_listener_fn(
433
+ self, attempt_number: int, num_retries: int, _err: BaseException | None
434
+ ) -> None:
435
+ if self.retry_listener is not None:
436
+ self.retry_listener(attempt_number, num_retries, _err)
437
+ if self._telemetry is not None and _err is not None:
438
+ self._telemetry.on_error(_err)
439
+
429
440
  # =========================================================================
430
441
  # Serializers
431
442
  # =========================================================================
@@ -559,7 +570,7 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
559
570
  retry_min_wait=self.retry_min_wait,
560
571
  retry_max_wait=self.retry_max_wait,
561
572
  retry_multiplier=self.retry_multiplier,
562
- retry_listener=self.retry_listener,
573
+ retry_listener=self._retry_listener_fn,
563
574
  )
564
575
  def _one_attempt(**retry_kwargs) -> ModelResponse:
565
576
  assert self._telemetry is not None
@@ -671,7 +682,6 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
671
682
  "kwargs": {k: v for k, v in call_kwargs.items()},
672
683
  "context_window": self.max_input_tokens or 0,
673
684
  }
674
- self._telemetry.on_request(log_ctx=log_ctx)
675
685
 
676
686
  # Perform call with retries
677
687
  @self.retry_decorator(
@@ -680,9 +690,11 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
680
690
  retry_min_wait=self.retry_min_wait,
681
691
  retry_max_wait=self.retry_max_wait,
682
692
  retry_multiplier=self.retry_multiplier,
683
- retry_listener=self.retry_listener,
693
+ retry_listener=self._retry_listener_fn,
684
694
  )
685
695
  def _one_attempt(**retry_kwargs) -> ResponsesAPIResponse:
696
+ assert self._telemetry is not None
697
+ self._telemetry.on_request(log_ctx=log_ctx)
686
698
  final_kwargs = {**call_kwargs, **retry_kwargs}
687
699
  with self._litellm_modify_params_ctx(self.modify_params):
688
700
  with warnings.catch_warnings():
@@ -713,7 +725,6 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
713
725
  f"Expected ResponsesAPIResponse, got {type(ret)}"
714
726
  )
715
727
  # telemetry (latency, cost). Token usage mapping we handle after.
716
- assert self._telemetry is not None
717
728
  self._telemetry.on_response(ret)
718
729
  return ret
719
730
 
@@ -982,10 +993,8 @@ class LLM(BaseModel, RetryMixin, NonNativeToolCallingMixin):
982
993
  """
983
994
  msgs = copy.deepcopy(messages)
984
995
 
985
- # Set only vision flag; skip cache_enabled and force_string_serializer
996
+ # Determine vision based on model detection
986
997
  vision_active = self.vision_is_active()
987
- for m in msgs:
988
- m.vision_enabled = vision_active
989
998
 
990
999
  # Assign system instructions as a string, collect input items
991
1000
  instructions: str | None = None
@@ -36,9 +36,11 @@ def select_responses_options(
36
36
  else:
37
37
  out.setdefault("store", False)
38
38
 
39
- # Include encrypted reasoning if stateless
39
+ # Include encrypted reasoning only when the user enables it on the LLM,
40
+ # and only for stateless calls (store=False). Respect user choice.
40
41
  include_list = list(include) if include is not None else []
41
- if not out.get("store", False):
42
+
43
+ if not out.get("store", False) and llm.enable_encrypted_reasoning:
42
44
  if "reasoning.encrypted_content" not in include_list:
43
45
  include_list.append("reasoning.encrypted_content")
44
46
  if include_list:
@@ -16,7 +16,7 @@ from openhands.sdk.logger import get_logger
16
16
  logger = get_logger(__name__)
17
17
 
18
18
  # Helpful alias for listener signature: (attempt_number, max_retries) -> None
19
- RetryListener = Callable[[int, int], None]
19
+ RetryListener = Callable[[int, int, BaseException | None], None]
20
20
 
21
21
 
22
22
  class RetryMixin:
@@ -41,7 +41,12 @@ class RetryMixin:
41
41
  self.log_retry_attempt(retry_state)
42
42
 
43
43
  if retry_listener is not None:
44
- retry_listener(retry_state.attempt_number, num_retries)
44
+ exc = (
45
+ retry_state.outcome.exception()
46
+ if retry_state.outcome is not None
47
+ else None
48
+ )
49
+ retry_listener(retry_state.attempt_number, num_retries, exc)
45
50
 
46
51
  # If there is no outcome or no exception, nothing to tweak.
47
52
  if retry_state.outcome is None:
@@ -120,7 +120,7 @@ class Telemetry(BaseModel):
120
120
 
121
121
  return self.metrics.deep_copy()
122
122
 
123
- def on_error(self, _err: Exception) -> None:
123
+ def on_error(self, _err: BaseException) -> None:
124
124
  # Stub for error tracking / counters
125
125
  return
126
126
 
@@ -2,6 +2,10 @@ VERIFIED_OPENAI_MODELS = [
2
2
  "gpt-5-codex",
3
3
  "gpt-5-2025-08-07",
4
4
  "gpt-5-mini-2025-08-07",
5
+ "gpt-5.1",
6
+ "gpt-5.1-codex",
7
+ "gpt-5.1-codex-max",
8
+ "gpt-5.1-codex-mini",
5
9
  "o4-mini",
6
10
  "gpt-4o",
7
11
  "gpt-4o-mini",
@@ -33,20 +37,21 @@ VERIFIED_MISTRAL_MODELS = [
33
37
  "devstral-small-2505",
34
38
  "devstral-small-2507",
35
39
  "devstral-medium-2507",
40
+ "devstral-2512",
41
+ "devstral-medium-2512",
36
42
  ]
37
43
 
38
44
  VERIFIED_OPENHANDS_MODELS = [
45
+ "claude-opus-4-5-20251101",
39
46
  "claude-sonnet-4-5-20250929",
47
+ "gpt-5.1-codex-max",
48
+ "gpt-5.1-codex",
49
+ "gpt-5.1",
40
50
  "gemini-3-pro-preview",
41
- "gpt-5-2025-08-07",
42
- "gpt-5-codex",
43
- "claude-haiku-4-5-20251001",
44
- "claude-opus-4-5-20251101",
51
+ "deekseek-chat",
45
52
  "kimi-k2-thinking",
46
- "gpt-5-mini-2025-08-07",
47
- "claude-opus-4-1-20250805",
48
- "devstral-small-2507",
49
- "devstral-medium-2507",
53
+ "devstral-medium-2512",
54
+ "devstral-2512",
50
55
  ]
51
56
 
52
57
 
@@ -105,7 +105,14 @@ def setup_logging(
105
105
  keep = ENV_BACKUP_COUNT if backup_count is None else backup_count
106
106
 
107
107
  root = logging.getLogger()
108
+ old_level = root.level
108
109
  root.setLevel(lvl)
110
+
111
+ # Set the level for any existing logger with the same intial level
112
+ for logger in logging.root.manager.loggerDict.values():
113
+ if isinstance(logger, logging.Logger) and logger.level == old_level:
114
+ logger.setLevel(lvl)
115
+
109
116
  # Do NOT clear existing handlers; Uvicorn installs these before importing the app.
110
117
  # Only add ours if there isn't already a comparable stream handler.
111
118
  has_stream = any(isinstance(h, logging.StreamHandler) for h in root.handlers)
@@ -13,7 +13,7 @@ from openhands.sdk.tool import (
13
13
  Observation,
14
14
  )
15
15
  from openhands.sdk.tool.schema import Action
16
- from openhands.sdk.utils.visualize import display_dict
16
+ from openhands.sdk.utils.visualize import display_json
17
17
 
18
18
 
19
19
  logger = get_logger(__name__)
@@ -97,7 +97,7 @@ class MCPToolObservation(Observation):
97
97
  # try to see if block.text is a JSON
98
98
  try:
99
99
  parsed = json.loads(block.text)
100
- text.append(display_dict(parsed))
100
+ text.append(display_json(parsed))
101
101
  continue
102
102
  except (json.JSONDecodeError, TypeError):
103
103
  text.append(block.text + "\n")
@@ -0,0 +1,19 @@
1
+ """Secret management module for handling sensitive data.
2
+
3
+ This module provides classes and types for managing secrets in OpenHands.
4
+ """
5
+
6
+ from openhands.sdk.secret.secrets import (
7
+ LookupSecret,
8
+ SecretSource,
9
+ SecretValue,
10
+ StaticSecret,
11
+ )
12
+
13
+
14
+ __all__ = [
15
+ "SecretSource",
16
+ "StaticSecret",
17
+ "LookupSecret",
18
+ "SecretValue",
19
+ ]
@@ -1,3 +1,5 @@
1
+ """Secret sources and types for handling sensitive data."""
2
+
1
3
  from abc import ABC, abstractmethod
2
4
 
3
5
  import httpx
@@ -84,3 +86,7 @@ def _is_secret_header(key: str):
84
86
  if secret in key:
85
87
  return True
86
88
  return False
89
+
90
+
91
+ # Type alias for secret values - can be a plain string or a SecretSource
92
+ SecretValue = str | SecretSource
@@ -29,7 +29,7 @@ def _save_full_content(content: str, save_dir: str, tool_prefix: str) -> str | N
29
29
  """Save full content to the specified directory and return the file path."""
30
30
 
31
31
  save_dir_path = Path(save_dir)
32
- save_dir_path.mkdir(exist_ok=True)
32
+ save_dir_path.mkdir(parents=True, exist_ok=True)
33
33
 
34
34
  # Generate hash-based filename for deduplication
35
35
  content_hash = hashlib.sha256(content.encode("utf-8")).hexdigest()[:8]
@@ -0,0 +1,58 @@
1
+ from rich.text import Text
2
+
3
+
4
+ def display_dict(d) -> Text:
5
+ """Create a Rich Text representation of a dictionary.
6
+
7
+ This function is deprecated. Use display_json instead.
8
+ """
9
+ return display_json(d)
10
+
11
+
12
+ def display_json(data) -> Text:
13
+ """Create a Rich Text representation of JSON data.
14
+
15
+ Handles dictionaries, lists, strings, numbers, booleans, and None values.
16
+ """
17
+ content = Text()
18
+
19
+ if isinstance(data, dict):
20
+ for field_name, field_value in data.items():
21
+ if field_value is None:
22
+ continue # skip None fields
23
+ content.append(f"\n {field_name}: ", style="bold")
24
+ if isinstance(field_value, str):
25
+ # Handle multiline strings with proper indentation
26
+ if "\n" in field_value:
27
+ content.append("\n")
28
+ for line in field_value.split("\n"):
29
+ content.append(f" {line}\n")
30
+ else:
31
+ content.append(f'"{field_value}"')
32
+ elif isinstance(field_value, (list, dict)):
33
+ content.append(str(field_value))
34
+ else:
35
+ content.append(str(field_value))
36
+ elif isinstance(data, list):
37
+ content.append(f"[List with {len(data)} items]\n")
38
+ for i, item in enumerate(data):
39
+ content.append(f" [{i}]: ", style="bold")
40
+ if isinstance(item, str):
41
+ content.append(f'"{item}"\n')
42
+ else:
43
+ content.append(f"{item}\n")
44
+ elif isinstance(data, str):
45
+ # Handle multiline strings with proper indentation
46
+ if "\n" in data:
47
+ content.append("String:\n")
48
+ for line in data.split("\n"):
49
+ content.append(f" {line}\n")
50
+ else:
51
+ content.append(f'"{data}"')
52
+ elif data is None:
53
+ content.append("null")
54
+ else:
55
+ # Handle numbers, booleans, and other JSON primitives
56
+ content.append(str(data))
57
+
58
+ return content