Migrate to proper secret passing using OpenHands SDK pattern #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the CVE demo from using environment variable exports to properly passing secrets using the OpenHands SDK's
conversation.update_secrets()method, following the pattern demonstrated inopenhands/software-agent-sdk/examples/01_standalone_sdk/12_custom_secrets.py.Problem
Previously, the code was trying to pass
GITHUB_TOKENto agents by exporting it as an environment variable in the workspace:This approach had several issues:
Solution
Now using the proper OpenHands SDK pattern:
Changes Made
Core Changes
BaseAgent.create_agent_conversation(): Now accepts optionalsecretsparameter and usesconversation.update_secrets()setup_git_environment(): Removed the problematic method and replaced withget_github_token()helperGITHUB_TOKENas a secretDocumentation & Examples
SECRETS_MIGRATION.md: Comprehensive documentation explaining the migrationexample_secrets_usage.py: Demonstration script showing the new patternBenefits
Testing
Files Changed
src/agents/base_agent.py: Updated conversation creation with secrets supportsrc/agents/cve_scanner.py: Updated to use new secret passing patternsrc/agents/cve_solver.py: Updated to use new secret passing patternSECRETS_MIGRATION.md: Added comprehensive migration documentationexample_secrets_usage.py: Added demonstration scriptThe agents will continue to work exactly as before from a user perspective, but now use the proper OpenHands SDK pattern for handling secrets securely.
@rbren can click here to continue refining the PR