Repository navigation
feat!: restore full tool results and parsed load_artifact (re-applies #27) - #32
Closed
benclarkeio wants to merge 1 commit into
Closed
benclarkeio wants to merge 1 commit into
benclarkeio wants to merge 1 commit into
Conversation
…27) #29's squash ended with a commit that put back the 2.x result formats, so 2.1.0 and main lost #27. Re-apply #27's diff on top of main, keeping the typed stubs, catalog return types and MCP result envelope from #28/#29. - Drop the 50,000-byte large-result threshold and its `{"tool_result_artifact", "note"}` substitute: the code always gets the real tool result, which is still saved as an artifact - Save tool results with the same JSON-safe conversion as the RPC reply (`_json.json_safe`), so a saved result reloads as the value the code got - `load_artifact` returns parsed JSON, a `str` for other text, or `{"mime_type", "bytes"}` for binary, instead of `{"kind", "data", "mime_type"}`; text is encoded and decoded with the mime type's charset, defaulting to UTF-8 - `RemoteBackend` refuses a frame over `max_message_size` before sending it, so an oversized tool reply reaches the code as an error instead of closing the sandbox connection - Drop the `ToolResultArtifact` pointer #29 added to wrapped tools' stub and catalog return types, and the description's large-result sentence - Restore #27's tests and update the README and docstrings BREAKING CHANGE: `load_artifact` returns the content itself rather than `{"kind", "data", "mime_type"}`. Large tool results are returned in full instead of as a `tool_result_artifact` pointer. `DEFAULT_LARGE_RESULT_THRESHOLD` and the `large_result_threshold` parameter of `ToolResultArtifactTool` and `wrap_tool_result_as_artifact` are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013TYQ7F1kLDzPsAwBRC5KV1
Contributor
Author
|
Superseded by #33, which ships the same behaviour as opt-in options with the 2.x defaults kept, so it releases as 2.2.0 instead of 3.0.0. Please do not merge this PR; it can be closed. Generated by Claude Code |
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.
Summary
#27 (
ed4626d) changed what tool calls andload_artifactgive the code, but neither 2.1.0 normaincontains it. #29 (a238bfd) was squash-merged five hours after #27, and its last commit, "fix: preserve Code Mode 2.x result contracts", put back the 2.x formats so that 2.1.0 could ship as a minor release. #27's PR also told release-please to record it as achore:, so the 2.1.0 changelog doesn't mention it.git diff ed4626d a238bfdshows the revert.So production still swaps any tool result over 50 KB for a
{"tool_result_artifact", "note"}pointer, andload_artifactstill returns raw JSON text that the model then parses by hand.This PR re-applies #27 on top of
mainas a breaking change, so release-please cuts 3.0.0.What's restored
Tool results: the code always gets the real result. Results are still saved as artifacts so later turns can reload them. The 50,000-byte threshold and its pointer are gone.
_json.json_safe), so a dataclass or Pydantic result reloads as the value the code received.load_artifactreturns the content itself:application/json,*+json): the parsed valuestr{"mime_type": str, "bytes": <base64 str>}Text is encoded and decoded with the mime type's
charset, with UTF-8 as the default. JSON that fails to parse comes back as astr.Remote sandbox:
RemoteBackendrefuses a frame overmax_message_sizebefore sending it. An oversized tool reply reaches the code as an error, and the sandbox stays connected.feat!: return full tool results and artifact content to the code #27's README text, docstrings and tests.
What's kept from #28 and #29
TypedDictreturn types in the catalog, escaped docstrings, the names-tier hint to read a function's stub, and the tool description's sentence on what is saved and how to load it.structuredContenttyped from the tool'soutputSchema, as feat: show return types in the catalog and point the names tier at stubs #29 left it. feat: type stub return values and escape docstrings #28's change to returnstructuredContentalone was undone by the same feat: show return types in the catalog and point the names tier at stubs #29 commit. It isn't part of feat!: return full tool results and artifact content to the code #27, so this PR leaves it out.How the conflicts were resolved
I applied
git diff dcb15ab ed4626dtomainwith a 3-way merge and resolved the rest by hand._artifact_tools.pyandruntime/remote.pyapplied cleanly and now matched4626d.tool_result_artifacts.py: feat!: return full tool results and artifact content to the code #27's version, without itsstructured_resultimport, which feat: show return types in the catalog and point the names tier at stubs #29 removed frommcp_results.py. Onmainthe code gets the full MCP result, so the artifact saves that, and reloading it still gives what the code got._json.pywas already onmain; only its docstring differed.tool.py: feat!: return full tool results and artifact content to the code #27's wording forsave_tool_results_as_artifacts. I also removed "Large tool results return atool_result_artifactpointer" from the tool description that feat: show return types in the catalog and point the names tier at stubs #29 added.tools/stubs.py: removed the| ToolResultArtifactthat feat: show return types in the catalog and point the names tier at stubs #29 added to every wrapped tool's return type, since that pointer can no longer be returned.README.md: feat!: return full tool results and artifact content to the code #27's text, and feat: show return types in the catalog and point the names tier at stubs #29's mentions of the pointer and the size limit are removed.Breaking changes
load_artifactno longer returns{"kind", "data", "mime_type"}.tool_result_artifactpointer.DEFAULT_LARGE_RESULT_THRESHOLDis removed, along with thelarge_result_thresholdparameter ofToolResultArtifactToolandwrap_tool_result_as_artifact.| ToolResultArtifact.Sandbox and release
ToolResultFrameandPROTOCOL_VERSIONare unchanged, and nothing undersandbox-wheel/changes. The size check runs on the host. The sandbox's WebSocket limit is 256 MiB, the same as the defaultRemoteBackend.max_message_size.__about__.pyfiles together throughextra-files. On release,release-please.ymlbuilds and publishes bothadk-code-modeandadk-code-mode-sandboxto PyPI, then the base image. Both will be 3.0.0.What the agent-run pin bump needs
agent-run doesn't pass anything this PR removes. It never uses
large_result_threshold,DEFAULT_LARGE_RESULT_THRESHOLDorwrap_tool_result_as_artifact, and doesn't readload_artifact's old shape. What it does use is unchanged:ExecuteCodeTool(tools=, backend=, timeout_seconds=, on_artifacts_saved=),RemoteBackend(url=, token=, connect_timeout=, start_attempts=, start_retry_delay_seconds=, start_retry_jitter_seconds=), and theTOOL_RESULT_*metadata keys.adk-code-mode==2.1.0to==3.0.0inpyproject.toml, in bothdependenciesand the dev group'sadk-code-mode[docker], then runuv lock.cloudbuild.sandbox.yamlreads the sandbox version fromuv.lock, so the sandbox image moves toadk-code-mode-sandbox==3.0.0with it. Deploy the host and the sandbox together.load_artifactcome back as{"mime_type", "bytes"}, astror parsed JSON. Agent instructions kept outside the repo that tell the model to read["data"]orjson.loadsa loaded artifact should be updated.Tests
make cipasses locally:ruff,mypyandpytest(256 passed). The 3 Docker-marked tests didn't run because no Docker daemon was available.Generated by Claude Code