Repository navigation
Conversation
ohadporat-vast
pushed a commit
to ohadporat-vast/aiq-research-assistant
that referenced
this pull request
Nov 13, 2025
…nnect_v141 Remove collection name from prompting since we no longer require it
KyleZheng1284
referenced
this pull request
in KyleZheng1284/aiq-research-assistant-kyle-fork
Mar 3, 2026
add a blocklist of non search tools to prevent llm URLs to leak into …
5 of 8 tasks
5 tasks done
KyleZheng1284
added a commit
that referenced
this pull request
Jul 1, 2026
…ime (#280) ## Overview This PR introduces a provider-neutral, fail-closed sandbox runtime for executing agent-generated code securely, alongside a durable artifact runtime that harvests generated files (such as charts and CSVs). These captured artifacts are now seamlessly rendered inline across all system surfaces, including the Web UI, PDF exports, Markdown reports, and the CLI. ## Proposed Changes ### Sandbox Runtime (src/aiq_agent/agents/deep_researcher/sandbox/) - base.py: Introduced a thin SandboxProvider Abstract Base Class (ABC). Providers only need to implement execute and capabilities. The base class handles lazy single-flight session creation, a serialization lock, idempotency-gated retries, and close() / terminate() lifecycles. - registry.py: Added a config-driven provider dispatch system utilizing aiq.sandbox_providers entry-point discovery to support out-of-tree custom providers. - capabilities.py: Implemented declared guarantees and a verify_capabilities fail-closed gate that explicitly refuses execution if a required security guarantee (e.g., network policy) is unsupported by the active provider. - config.py: Created SandboxConfig containing nested providers.<name>, normalized network policies (blocked | allowlist | open), artifact_capture settings, and a legacy flat-Modal backward-compatibility shim. - providers/modal.py & providers/openshell.py: Built two self-registering out-of-the-box providers to support both cloud (Modal) and on-premise (OpenShell) deployments. ### Artifact Manager (sandbox/artifacts/) - manager.py: Implemented the host-side harvest pipeline featuring path-traversal confinement, extension allowlists, file size caps, MIME-from-bytes/spoof rejection, user quotas, and SVG sanitization before executing a sha256 hash and store-then-emit action. - store.py / models.py / manifest.py: Established a pluggable SqlArtifactStore tied to the shared job database supporting BLOB storage and deduplication, defined the Artifact metadata record, and enforced the manifest.json schema. ### Report Post-Processing - resolve_report_references: Translates user-facing filenames into durable, unique system IDs. - ensure_inline_artifacts_embedded: Acts as a safety net ensuring that ## Figures are correctly embedded within report payloads. - append_artifact_index: Automatically appends a comprehensive ## Generated Artifacts index section to the end of the report. ### Backend Core (src/aiq_agent/agents/deep_researcher/) - agent.py: Connected the artifact harvest, resolve, and indexing pipelines directly into run() (offloaded via asyncio.to_thread) and configured the system to accept sandbox-produced files as valid, grounded outputs. - deepagents_runtime.py: Encapsulates the provider lifecycle, builds the ArtifactManager, exposes workdir and artifact_dir paths, and templates specialized skills directly to the active workspace directory. - custom_middleware.py: Integrated ArtifactHarvestMiddleware to automatically trigger file harvesting immediately following each execution step. - prompts/*.j2: Injected sandbox_artifact_dir context into agent prompts and strictly instructed models to embed figures using the markdown structure: . ### Backend API (frontends/aiq_api) - routes/jobs.py: Exposed auth-scoped endpoints GET .../artifacts and GET .../artifacts/{id}/content, added opt-in submit-path concurrency caps, and introduced artifact retention policies. - jobs/runner.py & jobs/access.py: Managed terminal-path final file harvesting alongside active-job tracking and counting metrics. ### Frontend & UI UI - MarkdownRenderer: Implemented a custom urlTransform to preserve the custom artifact:// protocol scheme and introduced a dedicated img renderer to map assets to the backend content endpoint. Centralized logic into artifact-url.ts as the single source of truth. - ReportTab / ExportFooter / store.ts: Enabled job ID resolution via selectResolvedDeepResearchJobId, ensuring access to assets survives even after a background job completes. - app/api/jobs/async/[...path]/route.ts: Configured a pure binary passthrough stream for artifact contents to bypass unnecessary JSON parsing of raw file bytes. - pages/api/generate-pdf.ts & lib/pdf/ReactPdfDocument.tsx: Implemented server-side data-URI inlining and block-figure image rendering for PDFs (supporting paragraphs, list items, and explicit widths). - hooks/use-download-pdf.ts: Properly threads active job IDs downstream to the PDF generation route. ### Skill & CLI Interface - skills/aiq-research/scripts/aiq.py: Added a --out-dir DIR flag to report commands to export completely portable report.md bundles accompanied by an artifacts/ folder with asset links rewritten to local relative paths. Added a separate --download-dir flag to the artifacts command. ### OpenShell Setup - scripts/setup_openshell.sh, configs/openshell/*, & configs/config_openshell.yml: Added a turnkey, one-command on-premise setup workflow including an environment-free file-transfer shim toggled via AIQ_OPENSHELL_ADAPTER_FILE_TRANSFER. ### Documentation - sandbox/README.md & docs/.../sandbox.md: Outlines overall architecture, provider authoring guidelines, supported rendering surfaces, and core troubleshooting workflows. Verification & Testing - Backend Unit & Integration Tests - Passed successfully via pytest: Bash ``` pytest tests/aiq_agent/agents/deep_researcher/sandbox/ \ tests/aiq_agent/agents/deep_researcher/test_agent.py \ tests/aiq_agent/jobs/test_runner.py -q ``` <!-- List the exact commands, workflows, screenshots, or manual checks used. --> - [x] I ran the relevant local checks or explained why they are not applicable. - [x] I added or updated tests for behavior changes. - [x] I updated documentation for user-facing or contributor-facing changes. - [x] I confirmed this PR does not include secrets, credentials, or internal-only data. - [x] I certify this contribution under the Developer Certificate of Origin (DCO) and signed my commits with `git commit -s` or an equivalent sign-off. #### Where should reviewers start? `sandbox/base.py` + `sandbox/registry.py` (the provider contract), then `sandbox/artifacts/manager.py` (the harvest/validation pipeline) and agent.py::run() (post-processing order), then frontends/ui/.../MarkdownRenderer/artifact-url.ts + the img/urlTransform for the rendering edge. #### Related Issues Dependencies / Install note - The OpenShell path depends on the langchain-nvidia-openshell adapter with the argv file-transfer fix ([pastorsj/langchain-nvidia#1](pastorsj/langchain-nvidia#1), which targets Sam's adapter PR [langchain-ai/langchain-nvidia#303](langchain-ai/langchain-nvidia#303)). - Until #1 is merged into #303 (and #303 published to PyPI), the adapter must be installed from the fork branch — not PyPI. Install via the git spec (or LANGCHAIN_NVIDIA_REPO override that scripts/setup_openshell.sh honors): ``` uv pip install --force-reinstall --no-deps \ 'git+https://github.com/KyleZheng1284/langchain-nvidia.git@fix/openshell-argv-file-transfer#subdirectory=libs/openshell' ``` Without that fix, OpenShell upload_files/download_files fail (the gateway strips OPENSHELL_* env), surfaced as a misleading permission_denied. Modal is unaffected. #### Action items to defer in follow up PR - Productionize the experimental OpenShell integration by providing a physically isolated sandbox per job and verifying the effective network, filesystem, and process policy before execution. - Consolidate provider configuration, preserve artifacts on failure and cancellation, align artifact events with the UI, make artifact deduplication and quota accounting concurrency-safe, enforce PDF auth parity, and pin the OpenShell setup to reproducible dependencies. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added durable artifact support for deep research jobs, including artifact content endpoints and job-scoped artifact rendering across the UI, markdown, and PDF exports (with embedded image support). * Added a sandbox-as-a-service workflow for deep research with OpenShell-backed sandbox provisioning (config, policy, and demo image) and a local setup script. * Added a sandbox concurrency cost guard for async job submissions and a “Sandbox” badge for sandboxed tool calls. * **Bug Fixes** * Improved safety for artifact image handling (sanitization, MIME/spoof resistance, and safer filenames) and better report recovery when writer output is missing. * **Documentation** * Updated sandbox architecture docs and deep-research skill/export guidance. * **Tests** * Added coverage for sandbox concurrency, sandbox runtime/provider compliance, and artifact harvesting/export behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Kyle Zheng <kyzheng@nvidia.com> Co-authored-by: Chantal D Gama Rose <cdgamarose@nvidia.com>
copy-pr-bot Bot
pushed a commit
that referenced
this pull request
Aug 19, 2026
Add uploaded filenames and stub summary to Summary Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch adds a streamlit UI that can be used with the AI-Q Research Assistant backend. The streamlit UI can be run locally or a Docker image can be configured and run via additions to the docker-compose file.
While the demo UI is designed to work out of the box, it is released only as a container without source code. This UI is intended to be less polished, but available as source code to be customized or extended.