Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions openhands/automation/presets/plugin/sdk_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
AUTOMATION_CALLBACK_URL - completion callback endpoint (optional)
AUTOMATION_RUN_ID - run ID for the callback payload (optional)
AUTOMATION_EVENT_PAYLOAD - JSON with trigger info and event payload (optional)
AUTOMATION_MODEL - model profile name to load instead of default (optional)
AUTOMATION_MODEL - model profile name to load instead of default (optional)

Runtime-injected secrets (via conversation.update_secrets after Conversation creation):
AUTOMATION_SESSION_URL - direct URL to this conversation in the OpenHands UI
(Cloud mode only; built from conversation.id)

"""

Expand Down Expand Up @@ -337,11 +341,18 @@ def event_callback(event) -> None:
print(f" conversation created: {type(conversation).__name__}")
print(f" plugins loaded: {len(plugin_sources)}")

# Inject secrets into the conversation (as LookupSecret references)
# Inject secrets into the conversation (auto-exported as env vars in bash)
if secrets:
conversation.update_secrets(secrets)
print(f" injected {len(secrets)} secrets into conversation")

# Build session URL from conversation ID and inject as a secret so
# the agent can use $AUTOMATION_SESSION_URL in bash commands.
if not IS_LOCAL_MODE and api_url:
session_url = f"{api_url}/conversations/{conversation.id}"
conversation.update_secrets({"AUTOMATION_SESSION_URL": session_url})
print(f" session URL: {session_url}")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: This same fix must be applied to the prompt preset for consistency.

The file openhands/automation/presets/prompt/sdk_main.py has identical structure:

  • Creates a Conversation (line ~326)
  • Calls conversation.update_secrets(secrets) (line ~331)
  • But is missing the session URL injection

Apply both changes there:

  1. Add the runtime-injected secrets docstring section (lines 59-61 here)
  2. Add the session URL injection code block (lines 349-354 here)

Even though the PR review automation currently uses the plugin preset, the prompt preset will have the same bug if any automation using it tries to reference $AUTOMATION_SESSION_URL.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a14efa6 — applied the same session URL injection and docstring changes to openhands/automation/presets/prompt/sdk_main.py.

This reply was posted by an AI agent (OpenHands) on behalf of the user.


try:
print(f" sending prompt: {USER_PROMPT[:80]}...")
conversation.send_message(USER_PROMPT)
Expand Down
15 changes: 13 additions & 2 deletions openhands/automation/presets/prompt/sdk_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
AUTOMATION_CALLBACK_URL - completion callback endpoint (optional)
AUTOMATION_RUN_ID - run ID for the callback payload (optional)
AUTOMATION_EVENT_PAYLOAD - JSON with trigger info and event payload (optional)
AUTOMATION_MODEL - model profile name to load instead of default (optional)
AUTOMATION_MODEL - model profile name to load instead of default (optional)

Runtime-injected secrets (via conversation.update_secrets after Conversation creation):
AUTOMATION_SESSION_URL - direct URL to this conversation in the OpenHands UI
(Cloud mode only; built from conversation.id)

"""

Expand Down Expand Up @@ -326,11 +330,18 @@ def event_callback(event) -> None:
assert isinstance(conversation, RemoteConversation)
print(f" conversation created: {type(conversation).__name__}")

# Inject secrets into the conversation (as LookupSecret references)
# Inject secrets into the conversation (auto-exported as env vars in bash)
if secrets:
conversation.update_secrets(secrets)
print(f" injected {len(secrets)} secrets into conversation")

# Build session URL from conversation ID and inject as a secret so
# the agent can use $AUTOMATION_SESSION_URL in bash commands.
if not IS_LOCAL_MODE and api_url:
session_url = f"{api_url}/conversations/{conversation.id}"
conversation.update_secrets({"AUTOMATION_SESSION_URL": session_url})
print(f" session URL: {session_url}")

try:
print(f" sending prompt: {USER_PROMPT[:80]}...")
conversation.send_message(USER_PROMPT)
Expand Down
Loading