Skip to content

feat(examples/strands_sglang): update to strands-sglang 0.4.2 - #2106

Merged
yitianlian merged 2 commits into
THUDM:mainfrom
Lawhy:update-strands-sglang-0.4.2-example
Jun 30, 2026
Merged

yitianlian merged 2 commits into
THUDM:mainfrom
Lawhy:update-strands-sglang-0.4.2-example

Conversation

@Lawhy

@Lawhy Lawhy commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What

Updates the examples/strands_sglang example to the latest strands-sglang 0.4.2 API.

Changes

  • 0.4.2 API migration — read the token trajectory via the new model.rollout (Rollout) tracker instead of the removed model.token_manager: initial_prompt_length for the prompt boundary, plus token_ids / loss_mask / logprobs.
  • Self-contained interpreter — the execute_python_code tool now uses an in-example subprocess_interpreter.py, keeping the example dependency-light.
  • Deps — remove the one-line requirements.txt (the only extra dependency is strands-sglang, installed directly) and refresh the README install steps.
  • Docs — fix the loss_mask / Rollout wording and add a security note that the interpreter runs code with no isolation.

NOTE: subprocess_interpreter.py runs model-generated code in a local subprocess with no isolation — it exists only for the convenience of this example. Use a sandboxed interpreter (Docker, e2b, microsandbox, ...) for anything beyond local experimentation.

Testing

  • pre-commit run --files ... (ruff, autoflake, isort, black + file checks) passes on all changed files.
  • python -m py_compile passes; the 0.4.2 model.rollout slicing was verified against the installed strands-sglang==0.4.2 + strands-agents==1.26.0.

Migrate the example to the strands-sglang 0.4.2 API:

- Read the token trajectory via the new `model.rollout` (`Rollout`) API instead
  of the removed `model.token_manager` (`initial_prompt_length`,
  `token_ids`/`loss_mask`/`logprobs`).
- Use a self-contained `subprocess_interpreter.py` for the `execute_python_code`
  tool, keeping the example dependency-light.
- Drop the one-line `requirements.txt` (the only extra dep is `strands-sglang`,
  installed directly) and refresh the README accordingly.
@Lawhy

Lawhy commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Hi @yitianlian, can you take a look when you have time? This is a simple adaption to the most recent strands-slang version.

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

LGTM

@yitianlian
yitianlian merged commit a2158f1 into THUDM:main Jun 30, 2026
40 checks passed
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