Is there any place we can find background on why c...
# questions
a
Is there any place we can find background on why certain things were done? Such as removing terminal user input https://github.com/OpenHands/OpenHands/pull/11546
l
Yeah, I actually don’t know why this was done either. Wont this make it impossible to set environment variables, such as API keys? @freezing-spoon-14104
a
Yea, that's what we mainly use it for - passing API Keys to the environment in a safe fashion (Don't really want to pass them to the upstream LLM first via conversation)
l
(typically the motivation is written in a github issue, but this one didn’t have a github issue, not sure why)
👍 1
c
The "secrets manager" is useful for that, I thought?
l
Yeah, but you can’t add secrets mid conversation
(AFAIK)
q
Yeah its inconvenient You need to update the secrets manager and restart the conversation
c
I did, I think? On the cloud at least, but it's possible I had to pause the runtime, and restart it, not sure if it was really necessary
ah so it was necessary, thank you
a
Yea, very inconvenient - I think removing terminal access is adding extra barrier of entry for engineers.
c
I believe this was the last discussion on it, which seems to have lead to the removal: https://openhands-ai.slack.com/archives/C09FJAZSP9N/p1761658409903009
l
OK, maybe we need to reconsider this…
Or at least come up with a good way to get env vars into the agent session
a
Yea, the problem with secrets - is if I'm an engineer and I have 10 different applications I'm developing. The current secret method has environment variable conflicts - so we opt to export per conversation. Ideally we wouldn't need to export at all. Thinking through this @limited-student-10747 we contributed the Kubernetes Runtime. Wondering if we can add Kubernetes Native Secret support to that where we identify secret names (not values) per repo and pull them in if that repo is cloned thinky spin That would solve our use case
Could then lift that for non-k8s where we identify build-in secrets per repo and pull in at a conversation level
c
On this note, in agent-sdk we treat secrets per conversation, rather than at a higher level. I don't know if it's linked with the web UI per conversation too, as yet, but I believe there's a plan or intention in that direction
a
Yea, that would be awesome
c
Cc: @wooden-umbrella-84098
w
oof OK. Let's add this to the backlog. I don't think interactive terminal is necessarily the way to go, but we should be able to let you manage per-convo secrets
We don't have interaction support in v1 unfortunately, it'd be tough to add
👍 1
a
Thanks @wooden-umbrella-84098 all good! Per conversation/repository secrets would be awesome
highfive 1
l
Yeah, thanks!
w
🙌 1
❤️ 1
c
Yep, this is the same discussion I linked above 😅
w
hah thanks, missed it!
c
That's okay, Robert, we still love ya
😄 1
a
@calm-artist-7206 how does the core OpenHands pull from openhands agent-sdk? e.g. I may have resources to tackle this soon but would be great to know where to start 🙂
c
@nutritious-balloon-65098 Goal: answer Brett's last question: "how does the core OpenHands pull from openhands agent-sdk? e.g. I may have resources to tackle this soon but would be great to know where to start 🙂" We care specifically about how user sets secrets -> they start a conversation from the web UI -> is started in agent-server -> with secrets • make sure you have both OpenHands/OpenHands and OpenHands/software-agent-sdk cloned • most of the discussion here on secrets refers to the web UI in version V0 of OpenHands • meanwhile, OpenHands V1 has a different core architecture: • look at OpenHands/agent-sdk and read its readme, it's the core of V1 • in the OH/OH repo, look at app-server (and read its readme): the user interface is built as an application server using the agent-server from agent-sdk remotely (e.g. from a docker container) • (be careful: a lot of the legacy V0 is still in the repo, and we need to ignore it because we want to talk about V1 now; you can make sure any class/function you read is on the execution path of app-server, that means it's in V1) Follow the execution path / routes from the web FE, and tell us a list of classes and files/lines on the execution path. File/line should be a link to github repos, you know how to form it. (and leave spaces around the address so that we can just click) Be clear and informative. We need to understand what was implemented and what wasn't, for the user of web UI to have their secrets per conversation sent over to agent-server. And make sure you look at code/routes really in use in V1.
👀 1
n
I'm on it! can track my progress here.
c
I stole most of this text from an older agent prompt of mine, I was actually trying to reduce typing and, of course, my chance to make mistakes 😅 People have worked so much everywhere, things are still changing daily, which is a tad much for my slow brain 😊
😆 1
n
Here’s the answer to Brett’s question, focused on V1 and the secrets path from web UI → app-server → agent-server. How core OpenHands uses agent-sdk (V1) • The V1 “core” runs the agent remotely via the agent-sdk’s agent-server. The OpenHands app-server builds a StartConversationRequest (which includes per-conversation secrets) and POSTs it to agent-server. OpenHands does not “pull” code from agent-sdk; it calls its REST API. • Secrets are injected per conversation. Custom user secrets come from the user context (StaticSecret). Git provider tokens are added as either: ◦ LookupSecret: a per-conversation, short-lived JWT-backed callback to the app-server (preferred), or ◦ StaticSecret: the latest token value if the sandbox can’t reach the app-server webhook. End-to-end execution path with the files/classes actually used in V1 1. User stores secrets in the UI (storage path still uses legacy /api) • FE calls legacy /api/secrets: ◦ frontend/src/api/secrets-service.ts (GET/POST/PUT/DELETE /api/secrets) https://github.com/OpenHands/OpenHands/blob/main/frontend/src/api/secrets-service.ts#L10-L39 • Legacy server mounts /api/secrets; this is still on the live server process that also mounts the V1 router: ◦ openhands/server/app.py (includes both legacy and v1) https://github.com/OpenHands/OpenHands/blob/main/openhands/server/app.py#L83-L95 ◦ openhands/server/routes/secrets.py (CRUD) GET /api/secrets: https://github.com/OpenHands/OpenHands/blob/main/openhands/server/routes/secrets.py#L186-L220 POST /api/secrets: https://github.com/OpenHands/OpenHands/blob/main/openhands/server/routes/secrets.py#L222-L244 PUT /api/secrets/{id}: https://github.com/OpenHands/OpenHands/blob/main/openhands/server/routes/secrets.py#L246-L296 DELETE /api/secrets/{id}: https://github.com/OpenHands/OpenHands/blob/main/openhands/server/routes/secrets.py#L298-L338 ◦ FileSecretsStore → secrets.json https://github.com/OpenHands/OpenHands/blob/main/openhands/storage/secrets/file_secrets_store.py#L15-L53 2. User starts a V1 conversation (FE → app-server /api/v1 → agent-server) • FE starts V1 app-conversation: ◦ frontend/src/api/conversation-service/v1-conversation-service.api.ts (POST /api/v1/app-conversations) https://github.com/OpenHands/OpenHands/blob/main/frontend/src/api/conversation-service/v1-conversation-service.api.ts#L85-L91 • V1 routing: ◦ openhands/app_server/v1_router.py (mounts V1 routers under /api/v1) https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/v1_router.py#L12-L19 ◦ openhands/app_server/app_conversation/app_conversation_router.py (POST /api/v1/app-conversations) https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/app_conversation_router.py#L169-L187 3. App-server assembles secrets and calls agent-server • Orchestration service that builds StartConversationRequest, injects secrets, and POSTs to agent-server: ◦ openhands/app_server/app_conversation/live_status_app_conversation_service.py: POST to agent-server /api/conversations: https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/live_status_app_conversation_service.py#L217-L226 Build StartConversationRequest (includes secrets): https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/live_status_app_conversation_service.py#L454-L513 GIT_TOKEN key constant: https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/live_status_app_conversation_service.py#L76 • Custom secrets are converted to StaticSecret per conversation: ◦ openhands/app_server/user/auth_user_context.py#get_secrets: https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/user/auth_user_context.py#L70-L79 • Git provider token is set as: ◦ LookupSecret when web_url is reachable (per-conversation JWT): https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/live_status_app_conversation_service.py#L465-L480 ◦ StaticSecret fallback when not reachable: https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/app_conversation/live_status_app_conversation_service.py#L480-L487 • The LookupSecret URL points to app-server’s webhook; Docker runtime helps make it reachable from the sandbox: ◦ Docker sets OH_WEBHOOKS_0_BASE_URL and X-Session-API-Key for sandbox: https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/sandbox/docker_sandbox_service.py#L271-L287 ◦ Webhook endpoint used by LookupSecret to fetch the token: openhands/app_server/event_callback/webhook_router.py (GET /api/v1/webhooks/secrets) https://github.com/OpenHands/OpenHands/blob/main/openhands/app_server/event_callback/webhook_router.py#L155-L173 4. Agent-server (agent-sdk) runs with per-conversation secrets • StartConversationRequest (secrets: dict[str, SecretSource]): https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-agent-server/openhands/agent_server/models.py#L44-L83 • On start, EventService creates LocalConversation(secrets=...): https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-agent-server/openhands/agent_server/event_service.py#L105-L140 • Secret types: ◦ StaticSecret and LookupSecret: https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/secret_source.py#L21-L39 https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/secret_source.py#L41-L83 • How secrets are used: ◦ SecretRegistry finds secret names in a command, exports env vars, and masks outputs: https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/secret_registry.py#L62-L80 https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/secret_registry.py#L101-L125 ◦ Terminal tool exports those env vars before executing and masks outputs: https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-tools/openhands/tools/terminal/impl.py#L56-L96 https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-tools/openhands/tools/terminal/impl.py#L152-L181 5. Runtime secret updates (agent-server capability) • Agent-server endpoint to update secrets mid-run: Route: https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-agent-server/openhands/agent_server/conversation_router.py#L196-L226 Service: https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-agent-server/openhands/agent_server/event_service.py#L286-L304 What is implemented vs. what isn’t (V1) • Implemented: ◦ FE saves custom secrets via /api/secrets (legacy server) which are injected as StaticSecret per conversation. ◦ Git provider token is available per conversation as GIT_TOKEN (prefer LookupSecret with a short-lived JWT; fallback StaticSecret). ◦ Agent-server injects env vars for commands referencing secret names and masks outputs. ◦ Agent-server supports updating secrets via POST /conversations/{id}/secrets. • Not yet implemented in V1 UI: ◦ A V1 endpoint/FE action to update a running conversation’s secrets (the contract exists on agent-server, but app-server/FE aren’t calling it yet). Where to start if you want to add per-conversation secret updates in the V1 UI • Add an app-server V1 endpoint (e.g., POST /api/v1/app-conversations/{id}/secrets) that resolves requested secret names into SecretSource (StaticSecret from custom store, LookupSecret for provider tokens) and proxies to agent-server’s POST /api/conversations/{id}/secrets with X-Session-API-Key. • Add a FE mutation for “Update secrets for this conversation” (or “Apply to conversation” in Settings). • Keep existing /api/secrets CRUD for persistence; use the new endpoint to push changes to running conversations. Prereqs • Clone both repos: OpenHands/OpenHands and OpenHands/software-agent-sdk. <sub>View full conversation</sub>
a
now tldr that for me - jk 😛
😂 1
c
Yes, skimming too.. The ending is not bad...
@nutritious-balloon-65098 Give us a few easy to follow instructions to • install V1 with web UI • and agent-server in local docker • and it sends secrets to a new conversation when the user starts in web UI Note that there are two different things here: • starting with separate secrets per conversation (our goal now) • updating secrets at runtime (not in scope) Also, I don't understand clearly from your answer: are we sending NOW the secrets saved by the user in Settings/Custom Secrets to the start conversation?
👀 1
n
Summary of what I delivered • Easy steps to run V1 with web UI and agent-server in local Docker a. In OpenHands/OpenHands, run: ▪︎ make build ▪︎ make run BACKEND_HOST=0.0.0.0 BACKEND_PORT=12000 FRONTEND_HOST=0.0.0.0 FRONTEND_PORT=12001 ▪︎ This starts the V1 app-server and the web UI (V1 is enabled by default unless ENABLE_V1=0). Leave RUNTIME unset so the app-server uses Docker to start agent-server. b. Open the UI: http://localhost:12001 c. Add secrets in the web UI: Settings → Custom Secrets d. Start a new conversation from the UI. The app-server will automatically start agent-server in a Docker container and inject per-conversation secrets into the StartConversationRequest. • How secrets are sent at conversation start (separate per conversation) ◦ All “Custom Secrets” saved in Settings are included as StaticSecret in the StartConversationRequest for that specific conversation. ◦ If you pick a git provider when starting, the app-server adds GIT_TOKEN: ▪︎ Prefer LookupSecret (agent-server calls back to app-server with a short-lived, user- and provider-scoped JWT to fetch the latest token) ▪︎ Fallback StaticSecret if the container cannot reach the app-server ◦ In the conversation, secrets are only exported into the shell when the command references the secret name (e.g., echo $MY_SECRET), and outputs are masked. • Out of scope (but noted) ◦ Updating secrets at runtime: supported by agent-server (POST /conversations/{id}/secrets) but not wired into the V1 web UI today. Not required for this setup. Direct answer to your question • Yes—custom secrets saved by the user in Settings → Custom Secrets are sent now to the StartConversationRequest for every new conversation (as per-conversation StaticSecret). <sub>View full conversation</sub>
c
@nutritious-balloon-65098 OK, so: our goal is for the user to be able to specify, in web UI, • which secrets to send to this conversation • then only those are sent, not all What do you think? Think deeply and give us a couple of alternatives, and what we need to change, specially backend/server comms.
n
Summary of my answer • Current behavior (V1) ◦ When a user starts a conversation from the web UI, the app-server includes ALL custom secrets saved in Settings → Custom Secrets as per-conversation StaticSecrets, and optionally adds a GIT_TOKEN (LookupSecret with a short-lived JWT to app-server’s webhook, or StaticSecret fallback). Yes—those saved custom secrets are sent today for every new conversation. • Goal: let the user choose which secrets to send per conversation (only the selected ones are sent) ◦ Alternative A (simplest): Per-conversation selection at start ▪︎ FE: In the “Start Conversation” dialog, show a checklist of available secret names (loaded from GET /api/secrets). Add to the start request: ◦ selectedSecretNames: string[] ◦ includeGitToken: boolean ▪︎ App-server: ◦ Extend AppConversationStartRequest with selected_secret_names and include_git_token. ◦ In LiveStatusAppConversationService._build_start_conversation_request_for_user, filter custom secrets to selectedSecretNames. Conditionally add GIT_TOKEN based on include_git_token and git_provider. ◦ Back-compat: if these fields are missing, retain current behavior (send all secrets, include GIT_TOKEN when git_provider present). ▪︎ Agent-server: no changes (it already accepts secrets in StartConversationRequest). ◦ Alternative B (reusable sets): Secret “profiles” ▪︎ FE: Let users define named “Secret Sets” (lists of secret names, optional includeGitToken) under Settings; choose one when starting a conversation. ▪︎ App-server: ◦ New CRUD endpoints: /api/v1/secret-sets (per-user). ◦ Start request: secret_set_id (and optional include_git_token override). ◦ Resolve the set server-side to SecretSources and call agent-server as usual. ▪︎ Agent-server: no changes. • Backend/server comms and security (for both A and B) ◦ FE never sends secret values—only names (or a set id) and includeGitToken. ◦ App-server resolves names to SecretSources (StaticSecret or LookupSecret for GIT_TOKEN) and passes them to agent-server in StartConversationRequest. ◦ Existing JWT LookupSecret flow and X-Session-API-Key auth remain unchanged. • Recommendation ◦ Start with Alternative A to ship quickly and safely (minimal API/UI changes, no agent-server changes). Add Alternative B later if teams need reusable configurations. • Out of scope (not needed now) ◦ Runtime secret updates for an already running conversation (agent-server supports POST /conversations/{id}/secrets, but the V1 UI doesn’t expose it yet). <sub>View full conversation</sub>
a
Thoughts on making it a bit more dynamic? e.g. per repository - something like
l
Yeah, I think maybe mimicking the github design here could be good. They have org and repo
a
Yea, that would be great fantastic actually to support the same way microagents is handled currently org/repo/user