$npx -y skills add togethercomputer/skills --skill together-sandboxesRemote Python execution in managed sandboxes on Together AI with stateful sessions, file uploads, data analysis, chart generation, and notebook-like runs via the Sandboxes API. Reach for it whenever the user wants managed remote Python execution instead of local execution, raw cl
| 1 | # Together Sandboxes |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use Together Sandboxes when the user wants to execute Python remotely in a managed sandbox. |
| 6 | |
| 7 | Typical fits: |
| 8 | |
| 9 | - stateful Python sessions |
| 10 | - data analysis and chart generation |
| 11 | - agent-generated code execution |
| 12 | - file uploads into a remote runtime |
| 13 | |
| 14 | ## When This Skill Wins |
| 15 | |
| 16 | - The user wants remote execution rather than local shell execution |
| 17 | - Session state needs to persist across multiple calls |
| 18 | - The result may include display outputs such as charts |
| 19 | - A lightweight managed runtime is enough; no custom infra is required |
| 20 | |
| 21 | ## Hand Off To Another Skill |
| 22 | |
| 23 | - Use `together-gpu-clusters` for full infrastructure control or larger distributed jobs |
| 24 | - Use `together-dedicated-containers` for custom containerized runtime logic |
| 25 | - Use `together-chat-completions` if the user only wants generated code, not executed code |
| 26 | |
| 27 | ## Quick Routing |
| 28 | |
| 29 | - **Remote execution with session reuse** |
| 30 | - Start with [scripts/execute_with_session.py](scripts/execute_with_session.py) or [scripts/execute_with_session.ts](scripts/execute_with_session.ts) |
| 31 | - **Response schema and session listing** |
| 32 | - Read [references/api-reference.md](references/api-reference.md) |
| 33 | - **MCP-style access for agent workflows** |
| 34 | - Read [references/api-reference.md](references/api-reference.md) |
| 35 | |
| 36 | ## Workflow |
| 37 | |
| 38 | 1. Decide whether the task needs code execution or only code generation. |
| 39 | 2. Start a session with `client.code_interpreter.execute()`. |
| 40 | 3. Reuse `session_id` when the workflow depends on prior state. |
| 41 | 4. Inspect `stdout`, `stderr`, structured outputs, and display outputs separately. |
| 42 | 5. List sessions only when the user needs operational visibility or cleanup. |
| 43 | |
| 44 | ## High-Signal Rules |
| 45 | |
| 46 | - Python scripts require the Together v2 SDK (`together>=2.0.0`). If the user is on an older version, they must upgrade first: `uv pip install --upgrade "together>=2.0.0"`. |
| 47 | - Treat `session_id` as part of the workflow state. |
| 48 | - Inspect `response.errors` before assuming a run succeeded. |
| 49 | - `plt.show()` with the Agg backend does not reliably produce `display_data` outputs. To retrieve charts, save the figure to a `BytesIO` buffer with `fig.savefig()`, base64-encode it, and print the encoded string to stdout. Parse it from the `stdout` output on the client side. See the chart example in [scripts/execute_with_session.py](scripts/execute_with_session.py). |
| 50 | - Use this skill when the user benefits from remote stateful execution, not just because Python is involved. |
| 51 | - If the task outgrows the sandbox model, hand off to GPU clusters or dedicated containers. |
| 52 | |
| 53 | ## Resource Map |
| 54 | |
| 55 | - **API reference**: [references/api-reference.md](references/api-reference.md) |
| 56 | - **Alternative access patterns**: [references/api-reference.md](references/api-reference.md) |
| 57 | - **Python workflow**: [scripts/execute_with_session.py](scripts/execute_with_session.py) |
| 58 | - **TypeScript workflow**: [scripts/execute_with_session.ts](scripts/execute_with_session.ts) |
| 59 | |
| 60 | ## Official Docs |
| 61 | |
| 62 | - [Together Sandboxes](https://docs.together.ai/docs/together-code-interpreter) |
| 63 | - [Sandboxes API](https://docs.together.ai/reference/tci-execute) |