Repository navigation
fix(gateway): never read a gateway result whose exec transport failed - #105
Merged
Merged
Conversation
A VM provider reports an exec whose transport failed (a lost host, a dropped connection) as exit -1, with partial or no output. The gateway ignored that exit code: _get_container_id read the empty result as no container and read_trajectory parsed whatever came back, so an agent check could record a partial or empty tool-call history as real. It affects every VM provider that reports a lost transport as -1, notably modal_vm and sail_vm. - read_trajectory and _get_container_id retry a read that exited -1 and raise after three attempts. Other exit codes keep their behaviour, so a gateway with no history still reads as []. - The deploy-time gateway and sidecar log dumps go through a best-effort _log_service, so a lookup or docker logs call that fails is logged and never aborts a healthy deploy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- _log_service reports a docker logs call that exits nonzero as a "Skipping <service> logs" warning with its stderr, instead of printing its output as the service's logs; the deploy still goes on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
approved these changes
Oct 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.
Summary
A VM provider reports an exec whose transport failed (a lost host, a dropped connection) as exit
-1, with partial or no output;VmSandbox.exec_scriptalready retries on it.EnvironmentGatewayProviderignored that exit code on its in-VM reads:_get_container_idread the empty result as "no container".read_trajectoryparsed whatever stdout came back. An agent check (for exampleverify_a2a_agent_mcp) could then record a partial or empty tool-call history as the real one.This was raised in review on #83 and split out of it, because it's a gateway issue, not a Sail one.
Which providers it affects
The code is the shared gateway path for every VM-mode provider. Behaviour changes only where a lost transport comes back as
-1:modal_vm: its exec returns-1when the websocket closes without an exit frame, possibly with partial stdout. Today that partial history is parsed.sail_vm: a cut stream returns-1with no stdout. Today that reads as no container, so no history.e2b: a transport failure raises an SDK exception, so the gateway already fails loudly. Unchanged.local: execs are local subprocesses. Unchanged in practice.Changes
read_trajectoryand_get_container_idretry a read that exited-1, three attempts in all. If it keeps failing they raiseRuntimeError, rather than returning a partial history or reading as "no container". Other exit codes behave as before, so a gateway with no history yet still reads as[]._log_service. A lookup ordocker logscall that fails is logged (Skipping <service> logs: …) and never aborts a deploy whose gateway is healthy. Before this change those dumps used the lookup directly, so making it raise would have let a diagnostic stop a deploy.Testing
make unit-testgives 6722 passed, 13 skipped. New tests inenv_gateway_provider_test.py:docker logsfailure never stops a deploy, and adocker logsthat exits non-zero is reported as a warning;gateway_test.py::test_gateway_with_multi_mcp_server[sail_vm]passed against Sail in 2m12s, covering the deploy, log dumps, MCP tool calls and/step.🤖 Generated with Claude Code
The PR appears safe to merge.
Summary
The gateway retries VM reads that end with exit
-1and raises if three attempts fail. Deploy-time log dumps now warn and continue when diagnostic reads fail.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Read gateway data] --> B{Exec returned -1?} B -->|Yes| C{Attempts left?} C -->|Yes| A C -->|No| D[Raise an error] B -->|No| E[Use the result] F[Dump deploy logs] --> G{Lookup or logs failed?} G -->|Yes| H[Warn and continue] G -->|No| I[Print logs and continue]Reviews (2) · Last reviewed commit: "fix(gateway): address greptile review fi..." · Reviewed by Greptile