fix(sandbox): support nested JSON and banner prefix in AgentRun MCP response#1930
Open
itxaiohanglover wants to merge 1 commit into
Open
Conversation
…esponse
parseExecPayload() assumed flat JSON format and required the text to
start with "{". AgentRun MCP server returns nested format with
exitCode/stdout/stderr inside a "result" sub-object, and may prepend
a markdown banner before the JSON payload.
- Locate first "{" to skip banner prefixes
- Check "result" sub-object for exit fields before falling back to root
- Only treat as exec result if exitCode/exit_code is present
Fixes agentscope-ai#1908
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
Author
|
The codecov/patch failure is expected for fork PRs — the fork doesn't have the CODECOV_TOKEN secret configured. The actual build passes on both ubuntu and windows. This is a known issue with fork CI, not related to the code changes. |
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
{"result":{"exitCode":...}}) inparseExecPayload(){exitCode/exit_codeis present in the resolved objectProblem
AgentRunMcpChannel.parseExecPayload()assumed flat JSON and required text to start with{. The AgentRun MCP server (protocol2025-03-26) returns:exitCode/stdout/stderrinside aresultsub-objectWhen parsing fails, the entire MCP response text (including banner) is returned as stdout, causing
glob()to treat banner lines as file paths and triggeringInvalidPathExceptionon Windows.Fixes #1908
Test Plan
{"exitCode":0,"stdout":"ok","stderr":""}still parses correctly{"result":{"exitCode":1,"stdout":"","stderr":"err"}}parses correctly### process_exec_cmd\n...\n{"exitCode":0,...}parses correctlyExecResult(0, text, "")