Skip to content

feat(transforms): implement code-mode transform and quickjs worker pool - #96

Open
AadarshM07 wants to merge 2 commits into
nitrocloudofficial:developfrom
AadarshM07:issue#66
Open

AadarshM07 wants to merge 2 commits into
nitrocloudofficial:developfrom
AadarshM07:issue#66

Conversation

@AadarshM07

Copy link
Copy Markdown
Collaborator

Description

Code mode enables an LLM to submit a multi-step JavaScript script that chains and filters tool calls in an isolated sandbox, executing in a single model round trip rather than individual network hops.

Key Changes

  1. Synthetic Tools Catalog (synthetic_tools.py, transform.py):

    • Exposes search, get_schema, and execute (configurable names).
    • Replaces the exposed MCP tools catalog while preserving pipeline execution for internal real tool calls.
  2. Isolated Worker Pool (worker_pool.py, guest_evaluator.py):

    • Manages a pool of isolated worker subprocesses using multiprocessing.get_context("spawn").
    • Uses embedded quickjs with memory caps (memory_limit_mb) and evaluation timeouts.
    • Recycles dead or timed-out worker slots to keep serving subsequent requests seamlessly.
  3. Destructive Guard (destructive_guard.py):

    • Treats a tool as destructive unless readOnlyHint: true or destructiveHint: false.
    • Blocks destructive tool execution inside code scripts unless allow_destructive: true is explicitly configured.
  4. Legible Errors (legible_error.py):

    • Formats evaluation errors with line locations while scrubbing host file paths and internal Python stack traces.
  5. Optional Dependency (pyproject.toml):

    • Packaged under nitrostack[code-mode].
    • Base import nitrostack continues to function without the extra installed.
  6. Type Safety:

    • Uses multiprocessing.process.BaseProcess to support context-specific SpawnProcess.
    • Safely guards awaitable tool results using inspect.isawaitable.

closes #66

@manish-wekan

Copy link
Copy Markdown
Collaborator

Lets apply the script timeout while a tool call is in progress too: a slow tool ran 513 ms past a 50 ms limit.

Revert the unrelated uv.lock revision downgrade (5 → 3). Remove the blank line at the end of the file.

~sent from claude-code

@AadarshM07 AadarshM07 linked an issue Oct 29, 2026 that may be closed by this pull request
4 tasks

This branch has not been deployed

No deployments
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.

[transforms] Sandbox interface and code-mode transform

2 participants