Skip to content

Refact: sandbox quickstart.md & add tutorial for code exec component - #14786

Merged
wangq8 merged 6 commits into
infiniflow:mainfrom
Magicbook1108:main
May 12, 2026
Merged

wangq8 merged 6 commits into
infiniflow:mainfrom
Magicbook1108:main

Conversation

@Magicbook1108

@Magicbook1108 Magicbook1108 commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Refact: sandbox quickstart.md && add tutorial for code exec component

Type of change

  • Refactoring
img_v3_0211j_dcff835b-e3bb-4c77-9bc5-3b31a983229g

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 🌈 python Pull requests that update Python code 📖 documentation Improvements or additions to documentation labels May 11, 2026
@Magicbook1108 Magicbook1108 added the ci Continue Integration label May 11, 2026
@Magicbook1108
Magicbook1108 marked this pull request as draft May 11, 2026 08:50
@Magicbook1108
Magicbook1108 marked this pull request as ready for review May 11, 2026 08:50
@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09d36681-0d27-4fa0-8805-a8a829f31563

📥 Commits

Reviewing files that changed from the base of the PR and between 026e30c and a01f5c0.

📒 Files selected for processing (1)
  • docs/guides/agent/agent_quickstarts/sandbox_quickstart.md
✅ Files skipped from review due to trivial changes (1)
  • docs/guides/agent/agent_quickstarts/sandbox_quickstart.md

📝 Walkthrough

Walkthrough

Propagates Python numerical-library thread env vars to local sandbox child processes, adds commented thread-limiting options to docker/.env, expands the sandbox quickstart with provider and executor-manager instructions, and adds a quickstart link in the Code operator UI.

Changes

Sandbox Configuration & Documentation

Layer / File(s) Summary
Thread Environment Variables Definition
agent/sandbox/providers/local.py
Introduces LOCAL_PYTHON_THREAD_ENV_VARS tuple containing common Python numerical-library thread env var names (OPENBLAS_NUM_THREADS, OMP_NUM_THREADS, MKL_NUM_THREADS, NUMEXPR_NUM_THREADS, BLIS_NUM_THREADS, VECLIB_MAXIMUM_THREADS).
Local Provider Environment Propagation
agent/sandbox/providers/local.py
Updates LocalProvider._build_child_env() to extend child process environment with values for variables in LOCAL_PYTHON_THREAD_ENV_VARS that exist in the parent process.
Docker Environment Configuration
docker/.env
Adds a commented "Limit native math library threads" section with optional environment-variable knobs (OpenBLAS, OpenMP, MKL, NumExpr, BLIS, VECLIB).
Sandbox Quickstart Documentation
docs/guides/agent/agent_quickstarts/sandbox_quickstart.md
Restructures quickstart guide with provider options (self_managed vs local), executor-manager image build step, updated Docker API error guidance, comprehensive environment-variables section, and reorganized RAGFlow setup steps.
UI Quickstart Navigation
web/src/pages/agent/form-sheet/next.tsx
Adds ArrowUpRight icon import, defines SandboxQuickstartUrl, and conditionally renders a ghost icon button in the Code operator form header that opens the quickstart documentation in a new tab.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14637: Introduced/modified LocalProvider previously; changes here enhance LocalProvider to propagate thread environment variables.

Poem

🐰 I hop through env and code with cheer,
Thread knobs in place so kids (and threads) steer clear,
Docs point the way, a quick link shines bright,
Sandbox humming neat and light—
A little rabbit’s tidy delight. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: refactoring sandbox quickstart documentation and adding a tutorial feature for the code execution component.
Description check ✅ Passed The description follows the required template with the problem statement and type of change clearly marked, though the explanation is brief and lacks implementation details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent/sandbox/providers/local.py`:
- Around line 245-249: Add debug-level logging that reports which thread
environment variables were forwarded in the new env propagation loop: inside the
block iterating LOCAL_PYTHON_THREAD_ENV_VARS (the loop that sets env[name] =
value) emit a logger.debug call just before returning env that summarizes the
forwarded variable names (and optionally their values or masked values) so local
execution limits can be traced; use the module logger (or
logging.getLogger(__name__)) and reference LOCAL_PYTHON_THREAD_ENV_VARS and env,
placing the log immediately before the existing return env.

In `@docs/guides/agent/agent_quickstarts/sandbox_quickstart.md`:
- Line 43: The doc mixes two working-directory assumptions for rebuilding the
executor manager ("./sandbox/executor_manager" vs "./executor_manager");
standardize to a single path (or explicitly state "run these commands from the
repository root" vs "run from the sandbox directory") and update every instance
(the rebuild instruction and the build steps around lines 65–69) so they
consistently reference the chosen location; also add a one-line note clarifying
where to run the commands if you prefer to keep both path examples.

In `@web/src/pages/agent/form-sheet/next.tsx`:
- Around line 106-121: The quickstart icon-only Button (the Button wrapping
ArrowUpRight with onClick that opens SandboxQuickstartUrl) lacks an accessible
name; add an explicit accessible label—e.g., set aria-label="Open quickstart in
new tab" or include visually-hidden text inside the Button—to provide screen
readers a meaningful name while keeping the existing onClick behavior and target
attributes; ensure the label clearly conveys the action and that nothing else in
the Button (e.g., className or type) is changed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 914e2da8-8ca6-410d-9cc3-f67616c1623f

📥 Commits

Reviewing files that changed from the base of the PR and between 292b0b8 and b4695df.

📒 Files selected for processing (4)
  • agent/sandbox/providers/local.py
  • docker/.env
  • docs/guides/agent/agent_quickstarts/sandbox_quickstart.md
  • web/src/pages/agent/form-sheet/next.tsx

Comment on lines +245 to +249
for name in LOCAL_PYTHON_THREAD_ENV_VARS:
value = os.environ.get(name)
if value is not None:
env[name] = value
return env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add debug logging for forwarded thread env vars in the new env-propagation flow.

Line 245-Line 249 introduces new runtime behavior but stays silent, which makes debugging local execution limits harder.

Proposed patch
+import logging
@@
 LOCAL_PYTHON_THREAD_ENV_VARS = (
@@
 )
+
+logger = logging.getLogger(__name__)
@@
         for name in LOCAL_PYTHON_THREAD_ENV_VARS:
             value = os.environ.get(name)
             if value is not None:
                 env[name] = value
+                logger.debug("Forwarding local sandbox thread env var: %s", name)
         return env

As per coding guidelines, **/*.py: Add logging for new flows.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for name in LOCAL_PYTHON_THREAD_ENV_VARS:
value = os.environ.get(name)
if value is not None:
env[name] = value
return env
for name in LOCAL_PYTHON_THREAD_ENV_VARS:
value = os.environ.get(name)
if value is not None:
env[name] = value
logger.debug("Forwarding local sandbox thread env var: %s", name)
return env
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent/sandbox/providers/local.py` around lines 245 - 249, Add debug-level
logging that reports which thread environment variables were forwarded in the
new env propagation loop: inside the block iterating
LOCAL_PYTHON_THREAD_ENV_VARS (the loop that sets env[name] = value) emit a
logger.debug call just before returning env that summarizes the forwarded
variable names (and optionally their values or masked values) so local execution
limits can be traced; use the module logger (or logging.getLogger(__name__)) and
reference LOCAL_PYTHON_THREAD_ENV_VARS and env, placing the log immediately
before the existing return env.

Comment on lines +106 to +121
<Button
variant="ghost"
size="icon"
className="ml-1 inline-flex size-5 !p-0 align-middle bg-transparent"
type="button"
onClick={(e) => {
e.stopPropagation();
window.open(
SandboxQuickstartUrl,
'_blank',
'noopener,noreferrer',
);
}}
>
<ArrowUpRight className="size-4 cursor-pointer text-text-secondary" />
</Button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add an accessible name to the icon-only quickstart button.

At Line 106-Line 121, screen readers won’t get a meaningful label for this control.

Proposed patch
                 {operatorName === Operator.Code && (
                   <Button
                     variant="ghost"
                     size="icon"
                     className="ml-1 inline-flex size-5 !p-0 align-middle bg-transparent"
                     type="button"
+                    aria-label="Open sandbox quickstart guide"
+                    title="Open sandbox quickstart guide"
                     onClick={(e) => {
                       e.stopPropagation();
                       window.open(
                         SandboxQuickstartUrl,
                         '_blank',
                         'noopener,noreferrer',
                       );
                     }}
                   >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
variant="ghost"
size="icon"
className="ml-1 inline-flex size-5 !p-0 align-middle bg-transparent"
type="button"
onClick={(e) => {
e.stopPropagation();
window.open(
SandboxQuickstartUrl,
'_blank',
'noopener,noreferrer',
);
}}
>
<ArrowUpRight className="size-4 cursor-pointer text-text-secondary" />
</Button>
<Button
variant="ghost"
size="icon"
className="ml-1 inline-flex size-5 !p-0 align-middle bg-transparent"
type="button"
aria-label="Open sandbox quickstart guide"
title="Open sandbox quickstart guide"
onClick={(e) => {
e.stopPropagation();
window.open(
SandboxQuickstartUrl,
'_blank',
'noopener,noreferrer',
);
}}
>
<ArrowUpRight className="size-4 cursor-pointer text-text-secondary" />
</Button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/pages/agent/form-sheet/next.tsx` around lines 106 - 121, The
quickstart icon-only Button (the Button wrapping ArrowUpRight with onClick that
opens SandboxQuickstartUrl) lacks an accessible name; add an explicit accessible
label—e.g., set aria-label="Open quickstart in new tab" or include
visually-hidden text inside the Button—to provide screen readers a meaningful
name while keeping the existing onClick behavior and target attributes; ensure
the label clearly conveys the action and that nothing else in the Button (e.g.,
className or type) is changed.

@codecov

codecov Bot commented May 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (08bb53b) to head (a01f5c0).
⚠️ Report is 38 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14786   +/-   ##
=======================================
  Coverage   94.16%   94.16%           
=======================================
  Files          10       10           
  Lines         703      703           
  Branches      112      112           
=======================================
  Hits          662      662           
  Misses         25       25           
  Partials       16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@writinwaters writinwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor nitpicking changes.


## Environment variables

The variables in `docker/.env` are grouped by scope.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest remoing this line because it is a bit off the topic.


:::tip NOTE
The error message `client version 1.43 is too old. Minimum supported API version is 1.44` indicates that your executor manager image's built-in Docker CLI version is lower than `29.1.0` required by the Docker daemon in use. To solve this issue, pull the latest `infiniflow/sandbox-executor-manager:latest` from Docker Hub or rebuild it in `./sandbox/executor_manager`.
The error message `client version 1.43 is too old. Minimum supported API version is 1.44` indicates that your executor manager image's built-in Docker CLI version is lower than `29.1.0` required by the Docker daemon in use. Rebuild the executor manager in `./sandbox/executor_manager` if you encounter this error in standalone mode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove "in standalone mode" and then move this note to under Option1: Build from source.

:::

## Build Docker base images
## Prepare Docker images

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think removing "sandbox base images" from the section title could be confusing. How do you think?

- Set `SANDBOX_ENABLED=1`.
- Set `SANDBOX_PROVIDER_TYPE=self_managed` or `SANDBOX_PROVIDER_TYPE=local`.
- For `self_managed`, include `sandbox` in `COMPOSE_PROFILES`.
- For `local`, uncomment and adjust the `SANDBOX_LOCAL_*` variables.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we use numbered list here, say 2.1, 2.2, 2.3?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not very necessary

Magicbook1108 and others added 5 commits May 11, 2026 19:09
Clarified error message guidance for Docker CLI version.
Updated section title from 'Prepare Docker images' to 'Build Docker base images' for clarity.
@wangq8
wangq8 merged commit f85e18a into infiniflow:main May 12, 2026
1 check passed
Ricardo-M-L pushed a commit to Ricardo-M-L/ragflow that referenced this pull request Aug 17, 2026
…nfiniflow#14786)

### What problem does this PR solve?

Refact: sandbox quickstart.md && add tutorial for code exec component

### Type of change

- [x] Refactoring


<img width="700" alt="img_v3_0211j_dcff835b-e3bb-4c77-9bc5-3b31a983229g"
src="https://github.com/user-attachments/assets/7842fc0f-639a-458f-b164-bc81a99ce4a5"
/>

---------

Co-authored-by: writinwaters <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 📖 documentation Improvements or additions to documentation 🌈 python Pull requests that update Python code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants