Skip to content

fix(app-conversations): reinstall git credential helpers after a sandbox resume (OHE-3896) - #1201

Merged
hieptl merged 1 commit into
mainfrom
hiep/ohe-3896-reinstall-git-credential-helpers-on-resume
Nov 5, 2026
Merged

hieptl merged 1 commit into
mainfrom
hiep/ohe-3896-reinstall-git-credential-helpers-on-resume

Conversation

@hieptl

@hieptl hieptl commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

A private marketplace registered with auto-load is cloned twice. The app server clones it with an authenticated URL for /api/skills, which yields skills only. Sub-agents and hooks come from the clone the SDK does inside the sandbox from the bare registered_marketplaces source, and that clone authenticates only through the git credential helper installed in the sandbox's global git config at conversation start (#1064).

The helper, its git config and the exchange JWTs it reads live under $HOME. On Kubernetes and runtime-api sandboxes that directory is container-local: pause deletes the pod and resume creates a new one on the same volumes (/workspace, /var/openhands), so they are gone. The JWTs would have expired after 12 hours anyway. The SDK plugin cache under ~/.openhands/cache/plugins is gone too, and the agent server rehydrates the conversation and re-fetches every marketplace on the first message after a resume. That clone has no credentials, so the marketplace's sub-agents and hooks disappear while its skills survive in the persisted state. Idle conversations are paused routinely, so this is the normal path for a customer whose plugin relies on sub-agents and hooks (OHE-3896).

The post-resume task restored only the git identity and the Codex credential bindings.

Summary

  • On resume, mint fresh per-provider (and Azure DevOps) exchange JWTs for the sandbox's owner and run the existing helper installs against the resumed sandbox, from the same post-resume task that restores the git identity. The owner's service is built from a SandboxUserContext, as the webhook router does.
  • Register the fresh JWTs for output masking in every conversation the sandbox hosts through the agent server's POST /api/conversations/{id}/secrets, reusing the catalog paging the Codex rebinding already does (now a shared iter_sandbox_conversations).
  • The JWT minting is split into module-level functions so the start-time path and the resume path share it; the start-time behaviour is unchanged.

Issue Number

Linear OHE-3896.

How to Test

uv run pytest tests/unit/app_server/test_sandbox_resume_git_config.py \
  tests/unit/app_server/test_live_status_app_conversation_service.py \
  tests/unit/app_server/test_codex_credential_binding.py
# 368 passed, 1 skipped

uv run pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --files \
  openhands/app_server/app_conversation/codex_credential_binding.py \
  openhands/app_server/app_conversation/live_status_app_conversation_service.py \
  openhands/app_server/sandbox/sandbox_router.py \
  tests/unit/app_server/test_sandbox_resume_git_config.py \
  tests/unit/app_server/test_live_status_app_conversation_service.py
# ruff, ruff format and mypy pass

The five new tests fail on main and pass with this change:

  • test_post_resume_task_reinstalls_git_credentials_for_the_sandbox_owner: the task resolves the owner's context and calls the restore with the resumed sandbox and its workspace.
  • test_post_resume_task_keeps_the_identity_when_restoring_credentials_fails: a failing restore is logged; the identity restore and the Codex rebinding still happen.
  • test_restore_git_credentials_after_resume_reinstalls_the_helpers_with_fresh_jwts: one JWT per provider reaches _configure_git_credential_helpers, the Azure DevOps one reaches its own install.
  • test_restore_git_credentials_after_resume_masks_the_jwts_in_every_conversation: each conversation in the agent server's catalog receives the secrets update with the sandbox's session key.
  • test_restore_git_credentials_after_resume_leaves_the_sandbox_alone_without_a_callback_url: nothing is installed or pushed when the sandbox cannot call back.

To check on a running stack: start a conversation with a private auto-load marketplace that carries a sub-agent and a SessionStart hook, confirm delegation and the hook, then POST /api/v1/sandboxes/{id}/pause, resume, and send a message. The sub-agents and hooks should still be there, and in the sandbox git config --global --get credential.https://<host>.helper should be set again. I did not run this end to end here.

Video/Screenshots

Backend only; no UI change. Test output is in How to Test.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • The restore runs in the existing fire-and-forget post-resume task, like the git identity restore, so a message sent in the first seconds after a resume can still reach the clone before the helper is back. Awaiting the restore inside the resume endpoint would close that window at the cost of a slower resume.
  • After a later rehydrate the agent server restores a conversation's creation-time secrets, so the masked value reverts to the original JWT; the files written by that resume are still masked for the resume that wrote them. This matches the existing posture on shared sandboxes, where each conversation start overwrites the token files.
  • Separate follow-ups: the SDK release carrying software-agent-sdk#6460 (error banner for a failed marketplace load) and #6461, with the pin bump; deployed validation on Bitbucket Data Center including a pause/resume cycle.

Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-30143f7

…box resume (OHE-3896)

The per-provider git credential helpers, their global git config and the
exchange JWTs they read live under the sandbox $HOME. A paused Kubernetes
sandbox loses that directory: resume gives it a new pod on the same
volumes, and the JWTs would have expired after 12 hours anyway. The agent
server reloads auto-load marketplaces and plugins on the first message
after a resume, and without a helper a private marketplace cannot be
cloned again, so its sub-agents and hooks were silently lost while the
skills survived in the persisted state.

On resume, mint fresh exchange JWTs for the sandbox's owner, install the
helpers the way conversation start does, and register the JWTs for output
masking in every conversation the sandbox hosts, next to the git identity
restore that already runs there. The catalog paging the Codex rebinding
does is shared for that. Best effort, like the start-time setup: a failure
is logged and never blocks the identity restore.

Tests cover the owner-scoped restore from the post-resume task, a failing
restore leaving the identity restore in place, the fresh JWTs reaching
both helper installs, the masking update per conversation, and the
no-callback case.
@github-actions github-actions Bot added the type: fix A bug fix label Nov 5, 2026
@hieptl
hieptl marked this pull request as ready for review November 5, 2026 06:36
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  openhands/app_server/app_conversation
  codex_credential_binding.py 147, 166
  live_status_app_conversation_service.py 288, 319, 1808, 1832-1841
  openhands/app_server/sandbox
  sandbox_router.py 234-235, 253
Project Total  

This report was generated by python-coverage-comment-action

@tofarr tofarr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🍰

@hieptl
hieptl merged commit 36b22be into main Nov 5, 2026
24 checks passed
@hieptl
hieptl deleted the hiep/ohe-3896-reinstall-git-credential-helpers-on-resume branch November 5, 2026 13:28
@openhands-release-bot openhands-release-bot Bot added the released: 1.87.0 Shipped in 1.87.0 label Nov 5, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.87.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.87.0 Shipped in 1.87.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants