Repository navigation
feat: offload base64 image payloads from agent state - #2867
Closed
guslegend0510 wants to merge 5 commits into
Closed
guslegend0510 wants to merge 5 commits into
guslegend0510 wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Collaborator
|
This PR has conflicts with the git fetch origin
git checkout codex/issue-2852-offload-base64
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
wahllllll
added a commit
to wahllllll/agentscope-java
that referenced
this pull request
Oct 10, 2026
Jackson's default StreamReadConstraints reject any single string value above 20,000,000 characters on read, while serialization imposes no cap at all. Every AgentStateStore -- JSON file, JDBC, Redis, MongoDB, OSS, COS, the Service JPA store -- persists through JsonUtils.getJsonCodec(), i.e. this codec's default ObjectMapper, and an AgentState carrying inline Base64 media (a 25 MB video is 33.5 million characters) saved successfully and then failed to load on the very next turn. Because the load happens before the model is called, every later turn of that session failed too, text-only ones included: a session bricked by its own persisted state. Configure the default ObjectMapper's JsonFactory with maxStringLength set to Integer.MAX_VALUE so the reader accepts whatever the writer emitted. Nesting depth, number length and name length keep their Jackson defaults; a caller- supplied ObjectMapper is left untouched. Strings this large only ever reach the codec from the framework's own persisted state -- model output and tool arguments are bounded far below the old limit -- so no untrusted boundary loses protection. Offloading media out of AgentState (agentscope-ai#2867) remains the right long-term answer; this restores the round-trip invariant the stores already rely on. Fixes agentscope-ai#3465
wahllllll
added a commit
to wahllllll/agentscope-java
that referenced
this pull request
Oct 10, 2026
Jackson's default StreamReadConstraints reject any single string value above 20,000,000 characters on read, while serialization imposes no cap at all. Every AgentStateStore -- JSON file, JDBC, Redis, MongoDB, OSS, COS, the Service JPA store -- persists through JsonUtils.getJsonCodec(), i.e. this codec's default ObjectMapper, and an AgentState carrying inline Base64 media (a 25 MB video is 33.5 million characters) saved successfully and then failed to load on the very next turn. Because the load happens before the model is called, every later turn of that session failed too, text-only ones included: a session bricked by its own persisted state. Configure the default ObjectMapper's JsonFactory with maxStringLength set to Integer.MAX_VALUE so the reader accepts whatever the writer emitted. Nesting depth, number length and name length keep their Jackson defaults; a caller- supplied ObjectMapper is left untouched. Strings this large only ever reach the codec from the framework's own persisted state -- model output and tool arguments are bounded far below the old limit -- so no untrusted boundary loses protection. Offloading media out of AgentState (agentscope-ai#2867) remains the right long-term answer; this restores the round-trip invariant the stores already rely on. Fixes agentscope-ai#3465
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.
AgentScope-Java Version
2.0.3-SNAPSHOT
Description
Closes #2852
Large inline base64 image payloads were stored directly in agent state, so ordinary session and history retrieval had to load and deserialize the full image data even when the caller did not need it.
This PR introduces opt-in image payload offloading for agent state:
LEANandFULLagent-state load modes so ordinary state reads can skip image payload hydration.ImageBlock, imageDataBlock, and nestedToolResultBlockcontent while preserving customMsgsubtypes.imagePayloadOffloadingEnabled(true)opt-in to keep mixed-version deployments safe; the default remains disabled.Compatibility
Existing inline base64 states remain readable. When offloading is enabled, a subsequent save migrates inline payloads to referenced payload records. Keeping the feature disabled by default prevents older nodes in rolling deployments from receiving states that contain references they cannot hydrate.
Validation
mvn spotless:applyagentscope-coretest suite: 2,329 tests, 0 failures, 0 errors, 9 skippedgit diff --checkChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)