Skip to content

fix(sandbox): preserve zero exit code in E2B JSON stream - #2609

Open
ump45nose wants to merge 3 commits into
agentscope-ai:mainfrom
ump45nose:fix/e2b-json-zero-exit-code
Open

fix(sandbox): preserve zero exit code in E2B JSON stream#2609
ump45nose wants to merge 3 commits into
agentscope-ai:mainfrom
ump45nose:fix/e2b-json-zero-exit-code

Conversation

@ump45nose

Copy link
Copy Markdown

AgentScope-Java Version

2.0.1-SNAPSHOT

Description

Fixes #2603.

In E2bCodec.JSON mode, an explicit {"end":{"exitCode":0}} frame was lost twice because proto3 does not include default scalar values in getAllFields() and reports no scalar presence through hasField(). As a result, successful commands kept the missing-exit sentinel and failed.

This change:

  • attaches the JSON end event when an integer exitCode was explicitly parsed, including zero;
  • reads the proto3 default scalar from the present end event instead of checking scalar presence;
  • adds a focused regression test for a zero exit code.

Related duplicate reports: #2601, #2602.

Tested with:

mvn -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b -am -Dtest=E2bEnvdProcessClientTest -Dsurefire.failIfNoSpecifiedTests=false test

Result: 8 tests passed, including jsonCodecPreservesZeroExitCode.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All targeted tests are passing
  • Javadoc comments are complete and follow project conventions (no public API changes)
  • Related documentation has been updated (not applicable; behavior fix with regression coverage)
  • Code is ready for review

@CLAassistant

CLAassistant commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ump45nose
ump45nose marked this pull request as ready for review August 10, 2026 10:59
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...e/extensions/sandbox/e2b/E2bEnvdProcessClient.java 0.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/extensions agentscope-extensions (general) labels Aug 11, 2026

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This PR fixes a proto3 default-value bug where an exitCode of 0 was silently dropped in the E2B JSON codec path. Root cause: DynamicMessage.hasField() returns false for proto3 non-optional scalar fields set to their default value, and getAllFields() omits default-valued fields. The fix is minimal, correct, and directly addresses issue #2603. A focused regression test is included. This also benefits the proto codec path where a binary-encoded EndEvent with exit_code=0 would also be missed.

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This PR fixes a proto3 default-value bug where an exitCode of 0 was silently dropped in the E2B JSON codec path. Root cause: DynamicMessage.hasField() returns false for proto3 non-optional scalar fields set to their default value, and getAllFields() omits default-valued fields. The fix is minimal, correct, and directly addresses issue #2603. A focused regression test is included. This also benefits the proto codec path where a binary-encoded EndEvent with exit_code=0 would also be missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions agentscope-extensions (general) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2bCodec.JSON mode fails on every successful command due to proto3 default-value semantics

4 participants