Skip to content

refactor(sandbox): use SDK runtime helpers#106

Merged
Mukil Loganathan (langchain-infra) merged 8 commits into
mainfrom
mukil/sandbox-use-sdk-runtime
May 6, 2026
Merged

refactor(sandbox): use SDK runtime helpers#106
Mukil Loganathan (langchain-infra) merged 8 commits into
mainfrom
mukil/sandbox-use-sdk-runtime

Conversation

@langchain-infra
Copy link
Copy Markdown
Contributor

@langchain-infra Mukil Loganathan (langchain-infra) commented May 6, 2026

Refactors sandbox runtime paths to use Go SDK helpers instead of carrying duplicate CLI implementations for command execution, console WebSockets, and tunneling.

What changed

  • Passes explicit CLI profiles to the SDK with langsmith.WithProfile, so profile OAuth refresh stays in the SDK path.
  • Routes langsmith sandbox exec through Sandboxes.Boxes.Run.
  • Routes SSH setup file writes and command probes through SDK helpers.
  • Routes langsmith sandbox console through SDK StartCommand with PTY controls instead of direct websocket/header handling.
  • Uses SDK tunnel helpers for local TCP listeners and stdio tunnel bridging.
  • Removes the duplicated CLI tunnel package, direct yamux dependency, sandbox auth header helper, and dataplane websocket URL helpers.

Dependency

  • Uses released github.com/langchain-ai/langsmith-go v0.9.3.

Test plan

  • go test ./...
  • prod smoke with --profile prod: create sandbox, run uname -a, run python3 --version, delete sandbox
  • prod interactive console e2e with --profile prod: create sandbox, run sandbox console, send echo CONSOLE_E2E_OK, python3 --version, pwd, exit, delete sandbox

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@langchain-infra Mukil Loganathan (langchain-infra) changed the title refactor(sandbox): use SDK tunnel helpers refactor(sandbox): use SDK runtime helpers May 6, 2026
@langchain-infra Mukil Loganathan (langchain-infra) merged commit 3d3feb3 into main May 6, 2026
10 of 11 checks passed
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 13 additional findings in Devin Review.

Open in Devin Review

Comment on lines +85 to 89
handle, err = client.SDK.Sandboxes.Boxes.StartCommandWithCallbacks(ctx, name, params, callbacks)
close(handleReady)
if err != nil {
return fmt.Errorf("starting console: %w", err)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nil handle dereference if SDK callback fires after failed StartCommandWithCallbacks

In sandbox_console.go, close(handleReady) is called unconditionally after StartCommandWithCallbacks returns, before the error check. If StartCommandWithCallbacks returns an error, handle is nil. Any OnSSHAgentData callback goroutine waiting on <-handleReady would unblock and call agent.HandleData(nil, channelID, data). When a.sock != "" (i.e., --forward-ssh-agent was requested), HandleData at sandbox_console.go:182 starts readResponses(nil, ...), which calls handle.SendSSHAgentData(...) and handle.CloseSSHAgentChannel(...) on a nil pointer, causing a panic.

Suggested change
handle, err = client.SDK.Sandboxes.Boxes.StartCommandWithCallbacks(ctx, name, params, callbacks)
close(handleReady)
if err != nil {
return fmt.Errorf("starting console: %w", err)
}
handle, err = client.SDK.Sandboxes.Boxes.StartCommandWithCallbacks(ctx, name, params, callbacks)
if err != nil {
close(handleReady)
return fmt.Errorf("starting console: %w", err)
}
close(handleReady)
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants