Skip to content

fix(sdk): preserve opaque base64 tool payloads - #5227

Merged
neubig merged 5 commits into
mainfrom
fix/5224-preserve-base64-payloads
Sep 23, 2026
Merged

neubig merged 5 commits into
mainfrom
fix/5224-preserve-base64-payloads

Conversation

@neubig

@neubig neubig commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

HUMAN:
AI agent prepared this draft fix; please review the masking design and test coverage.

AGENT:

Why

Secret masking corrupts screenshot base64 and image data URLs when a tracked secret occurs inside the payload, permanently poisoning persisted tool history. Fixes #5224.

Summary

  • Add field-level masking metadata for opaque screenshot payloads and base64 data URLs.
  • Preserve masking for ordinary text and non-data image URLs.
  • Add regression tests for browser screenshots, ImageContent, MCP images, and text masking.

Issue Number

#5224

How to Test

  • uv run pytest tests/sdk/conversation/test_secret_registry_model_masking.py tests/sdk/mcp tests/tools/browser_use tests/cross/test_secret_masking_tool_payloads.py -q
  • Ruff lint, formatting, and Pyright checks pass.
  • Before the fix, the payload tests failed; after the fix, all regression tests pass.

Video/Screenshots

Not applicable; this SDK fix is covered by automated tests.

Type

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

Notes

No persisted field names or requiredness changed. Companion recovery issue #5225 remains out of scope.


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:32609da-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-32609da-python \
  ghcr.io/openhands/agent-server:32609da-python

All tags pushed for this build

ghcr.io/openhands/agent-server:32609da-golang-amd64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-golang-amd64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-golang-amd64
ghcr.io/openhands/agent-server:32609da-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:32609da-golang-arm64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-golang-arm64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-golang-arm64
ghcr.io/openhands/agent-server:32609da-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:32609da-java-amd64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-java-amd64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-java-amd64
ghcr.io/openhands/agent-server:32609da-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:32609da-java-arm64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-java-arm64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-java-arm64
ghcr.io/openhands/agent-server:32609da-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:32609da-python-amd64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-amd64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-amd64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-amd64
ghcr.io/openhands/agent-server:32609da-python-arm64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-arm64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-arm64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-arm64
ghcr.io/openhands/agent-server:32609da-python-minimal-amd64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-minimal-amd64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-minimal-amd64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:32609da-python-minimal-arm64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-minimal-arm64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-minimal-arm64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:32609da-python-slim-amd64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-slim-amd64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-slim-amd64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:32609da-python-slim-arm64
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-slim-arm64
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-slim-arm64
ghcr.io/openhands/agent-server:32609da-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:32609da-golang
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-golang
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-golang
ghcr.io/openhands/agent-server:32609da-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:32609da-java
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-java
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-java
ghcr.io/openhands/agent-server:32609da-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:32609da-python-minimal
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-minimal
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-minimal
ghcr.io/openhands/agent-server:32609da-python-node-runtime-minimal
ghcr.io/openhands/agent-server:32609da-python-slim
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python-slim
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python-slim
ghcr.io/openhands/agent-server:32609da-python-node-runtime-slim
ghcr.io/openhands/agent-server:32609da-python
ghcr.io/openhands/agent-server:32609dad484562d727e1cf78ec50d1cb73387801-python
ghcr.io/openhands/agent-server:fix-5224-preserve-base64-payloads-python
ghcr.io/openhands/agent-server:32609da-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 32609da-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 32609da-python-amd64) are also available if needed

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig
neubig marked this pull request as ready for review September 22, 2026 21:51
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/conversation
   secret_registry.py179597%153, 409, 411, 414, 423
openhands-sdk/openhands/sdk/llm
   message.py268499%402, 415–416, 424
openhands-sdk/openhands/sdk/llm/utils
   model_features.py141299%41, 318
openhands-tools/openhands/tools/browser_use
   definition.py2005971%57, 74–76, 78–81, 84–86, 88–90, 92–94, 102, 107, 123, 126–127, 182, 232, 279, 323, 370, 414, 452, 490, 533, 575, 616, 664, 714, 760, 802–804, 818–820, 822–824, 826, 828, 832–834, 842–844, 847, 852, 855–856, 872–873
TOTAL438451250971% 

@all-hands-bot

all-hands-bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ Review paused: current-head checks failed

The current head 3dcd4e1532c5 has failing checks, so no review conversation was started:

  • sdk-tests

Fix the checks above and push. The scheduled scan then starts the review on the updated head.

This is an automated check - no AI was used to generate this comment.

Co-authored-by: openhands <openhands@all-hands.dev>
@jpshackelford

Copy link
Copy Markdown
Member

Thanks for looking at this with me @neubig. Really appreciate the help!

One question I wanted to raise while comparing this to #5226, and please push back if I'm missing something. Would it be worth carrying the two opt-outs as Annotated markers rather than json_schema_extra string keys? Something along the lines of:

# openhands/sdk/utils/masking.py
class SkipSecretMasking: __slots__ = ()
class PreserveDataUrls:  __slots__ = ()
image_urls: Annotated[list[str], PreserveDataUrls()]
screenshot_data: Annotated[str | None, SkipSecretMasking()] = Field(
    default=None, description="Base64 screenshot data if available"
)

…with _mask_model reading field_info.metadata instead of field.json_schema_extra.

Three things drew me to ask:

  1. json_schema_extra={"skip_secret_masking": True} is copied into the emitted JSON Schema by design, so clients/typescript/ and downstream OpenAPI consumers would see skip_secret_masking / preserve_data_urls as advertised properties of BrowserObservation and ImageContent. Annotated metadata stays invisible to serialization. Is exposing the flag on the schema surface intentional here, or an accident of the mechanism?

  2. A typo like {"skip_secrete_masking": True} on a future field would silently do nothing — nothing type-checks the string key. A typed marker gives grep, the type checker, and the reader a symbol to hook onto. Do you see a way to guard against that with the current shape, or is the intent that reviewers catch it?

  3. Related — for the next author adding a base64-carrying tool, is grep skip_secret_masking (string) versus grep SkipSecretMasking (symbol) enough of a difference to be worth the extra class, or does the existing acp_compatible precedent in AgentContext.validate_acp_compatibility() weigh more heavily since it uses the same json_schema_extra pattern? The triage note on [Bug]: Secret masking corrupts base64 payloads (e.g. browser screenshots), permanently wedging the conversation #5224 specifically called out that precedent, so I can see the case for staying consistent — just want to make sure the schema-leak and typo points were weighed against it.

Behavior-wise this is otherwise strictly better than the sibling PR — the data: predicate keeping remote URLs still masked is the right call, and the MCP round-trip test is stronger evidence than the transitive coverage in #5226. Whatever you decide on the marker shape, happy to see this land.


This comment was posted by an AI agent (OpenHands) on behalf of @jpshackelford.

@jpshackelford jpshackelford left a comment •

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.

See comment above.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
@neubig
neubig merged commit e8b1b26 into main Sep 23, 2026
52 checks passed
@neubig
neubig deleted the fix/5224-preserve-base64-payloads branch September 23, 2026 00:56
@github-actions github-actions Bot mentioned this pull request Sep 23, 2026
5 of 7 tasks

@juanmichelini juanmichelini left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, re approving to fix

last approval by @jpshackelford was on https://github.com/OpenHands/software-agent-sdk/commit/6cf0e19d468b70eeb90ab8aca7fd732e1caf00f9, but merged head was [32609dad4](https://github.com/OpenHands/software-agent-sdk/compare/6cf0e19d468b70eeb90ab8aca7fd732e1caf00f9...32609dad484562d727e1cf78ec50d1cb73387801) — commits landed after review

#5246 (comment))

ZME7777777 pushed a commit to ZME7777777/software-agent-sdk that referenced this pull request Sep 24, 2026
Co-authored-by: openhands <openhands@all-hands.dev>
(cherry picked from commit e8b1b26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Secret masking corrupts base64 payloads (e.g. browser screenshots), permanently wedging the conversation

5 participants