feat(sandbox): add encode_base64 opt-in to read_file tool with backward-compatible default#79
Draft
feat(sandbox): add encode_base64 opt-in to read_file tool with backward-compatible default#79
Conversation
- Modified read_file in CodeInterpreterToolSet to encode file content
as base64 by default; response includes 'encoding' field ('base64' or 'raw')
- Added optional 'raw' parameter (default False): when True, returns
plain text content unchanged
- Handles both str and bytes content from the underlying API
- Added unit tests covering base64 default, roundtrip, bytes input,
raw=True, and raw=False equivalence to default
- mypy type check passed (324 files, no issues)
Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/410c37c7-b485-46a3-806d-026c8d397150
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/410c37c7-b485-46a3-806d-026c8d397150 Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
OhYee
April 8, 2026 06:31
View session
Member
|
@copilot 如果要保持向前兼容,是否应该默认原文,传入 base64 后使用 base64? |
…se64 opt-in
- Default behavior now returns plain text (backward compatible with
callers that expected raw content from the original read_file)
- New encode_base64=True parameter opts into base64 encoding for
binary file support
- Response always includes 'encoding' field ('raw' or 'base64')
- Updated unit tests to reflect new API
Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/c48cff08-0e34-425e-a6e6-aafbaee14a00
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Contributor
Author
已按此思路调整(commit
# 默认:原文(向前兼容)
result = toolset.read_file(path="/tmp/notes.txt")
# {"path": "...", "content": "hello world", "encoding": "raw"}
# 按需开启 base64(适合二进制文件)
result = toolset.read_file(path="/tmp/output.bin", encode_base64=True)
# {"path": "...", "content": "aGVsbG8=", "encoding": "base64"} |
Copilot
AI
changed the title
feat(sandbox): add base64 encoding to read_file tool with raw passthrough option
feat(sandbox): add encode_base64 opt-in to read_file tool with backward-compatible default
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
read_fileinCodeInterpreterToolSetlacked a way to safely handle binary files, as it only returned raw text with no encoding control.Changes
CodeInterpreterToolSet.read_file: default behavior returns plain text unchanged (backward compatible); response now includes anencodingfield ("raw"or"base64")encode_base64: bool = Falseparameter — setTrueto receive base64-encoded content, useful for binary filesstrandbytesfrom the underlying API when encodingExample