Repository navigation
fix: restore 2.2.1 release readiness #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
65a9e38
0f3d6ea
eb6e1ba
477711b
6a4bd20
8be1d64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Validate the installable AI-Q artifact without relying on checkout metadata or | ||
| # editable imports. CI intentionally runs this against the committed HEAD. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" | ||
| TMP_ROOT="$(mktemp -d)" | ||
| SOURCE_ROOT="$TMP_ROOT/source" | ||
| WHEEL_DIR="$TMP_ROOT/wheel" | ||
| VENV_DIR="$TMP_ROOT/venv" | ||
| RUNTIME_ROOT="$TMP_ROOT/runtime" | ||
|
|
||
| cleanup() { | ||
| rm -rf -- "$TMP_ROOT" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| mkdir -p "$SOURCE_ROOT" "$WHEEL_DIR" "$RUNTIME_ROOT" | ||
| git -C "$REPO_ROOT" archive HEAD | tar -xf - -C "$SOURCE_ROOT" | ||
| if [[ -e "$SOURCE_ROOT/.git" ]]; then | ||
| echo "Release source export unexpectedly contains .git metadata" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| uv build --wheel --out-dir "$WHEEL_DIR" "$SOURCE_ROOT" | ||
| wheel_count=$(find "$WHEEL_DIR" -maxdepth 1 -type f -name 'aiq_agent-*.whl' | wc -l | tr -d ' ') | ||
| if [[ "$wheel_count" != "1" ]]; then | ||
| echo "Expected exactly one aiq-agent wheel, found $wheel_count" >&2 | ||
| exit 1 | ||
| fi | ||
| WHEEL_PATH=$(find "$WHEEL_DIR" -maxdepth 1 -type f -name 'aiq_agent-*.whl') | ||
|
|
||
| UV_PROJECT_ENVIRONMENT="$VENV_DIR" \ | ||
| uv sync --project "$SOURCE_ROOT" --frozen --group dev --no-editable --no-install-package aiq-agent | ||
| uv pip install --python "$VENV_DIR/bin/python" --no-deps --reinstall "$WHEEL_PATH" | ||
| uv pip check --python "$VENV_DIR/bin/python" | ||
|
|
||
| cp -R "$SOURCE_ROOT/configs" "$RUNTIME_ROOT/configs" | ||
| cd "$RUNTIME_ROOT" | ||
|
|
||
| "$VENV_DIR/bin/python" -I - "$SOURCE_ROOT" "$WHEEL_PATH" <<'PY' | ||
| import importlib.metadata | ||
| import sys | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
| import aiq_agent | ||
|
|
||
| source_root = Path(sys.argv[1]).resolve() | ||
| wheel_path = Path(sys.argv[2]).resolve() | ||
| expected = { | ||
| "aiq_agent/agents/chat_researcher/prompts/context_aware_intent_router.j2", | ||
| "aiq_agent/agents/chat_researcher/prompts/intent_classification.j2", | ||
| "aiq_agent/agents/clarifier/prompts/research_clarification.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/orchestrator.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/planner.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/researcher.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/source_registry.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/source_router.j2", | ||
| "aiq_agent/agents/deep_researcher/prompts/writer.j2", | ||
| "aiq_agent/agents/report_rewriter/prompts/edit.j2", | ||
| "aiq_agent/agents/shallow_researcher/prompts/researcher.j2", | ||
| "aiq_agent/agents/deep_researcher/skills/research/data-table-analysis/SKILL.md", | ||
| "aiq_agent/agents/deep_researcher/skills/research/forecast-analysis/SKILL.md", | ||
| "aiq_agent/agents/deep_researcher/skills/research/lightweight-calculation/SKILL.md", | ||
| "aiq_agent/agents/deep_researcher/skills/synthesis/long-form-report-writer/SKILL.md", | ||
| "aiq_agent/agents/deep_researcher/skills/synthesis/prediction-report-writer/SKILL.md", | ||
| "aiq_agent/agents/deep_researcher/skills/visualization/chart-generation/SKILL.md", | ||
| } | ||
|
|
||
| source_package = source_root / "src" / "aiq_agent" | ||
| actual_source = { | ||
| path.relative_to(source_root / "src").as_posix() | ||
| for path in (source_package / "agents").glob("*/prompts/*.j2") | ||
| } | ||
| actual_source.update( | ||
| path.relative_to(source_root / "src").as_posix() | ||
| for path in (source_package / "agents" / "deep_researcher" / "skills").rglob("SKILL.md") | ||
| ) | ||
| if actual_source != expected: | ||
| raise SystemExit( | ||
| "Runtime asset manifest is stale: " | ||
| f"missing={sorted(expected - actual_source)}, unexpected={sorted(actual_source - expected)}" | ||
| ) | ||
|
|
||
| for relative in expected: | ||
| source_path = source_root / "src" / relative | ||
| if source_path.stat().st_size == 0: | ||
| raise SystemExit(f"Source runtime asset is empty: {relative}") | ||
|
|
||
| with zipfile.ZipFile(wheel_path) as wheel: | ||
| wheel_entries = {entry.filename: entry.file_size for entry in wheel.infolist()} | ||
| for relative in expected: | ||
| if wheel_entries.get(relative, 0) == 0: | ||
| raise SystemExit(f"Wheel runtime asset is missing or empty: {relative}") | ||
|
|
||
| package_root = Path(aiq_agent.__file__).resolve().parent | ||
| venv_root = Path(sys.prefix).resolve() | ||
| try: | ||
| package_root.relative_to(venv_root) | ||
| except ValueError as exc: | ||
| raise SystemExit(f"aiq_agent imported outside the isolated environment: {package_root}") from exc | ||
| if source_root in package_root.parents: | ||
| raise SystemExit(f"aiq_agent imported from the source export: {package_root}") | ||
|
|
||
| for relative in expected: | ||
| installed_path = package_root / Path(relative).relative_to("aiq_agent") | ||
| if not installed_path.is_file() or installed_path.stat().st_size == 0: | ||
| raise SystemExit(f"Installed runtime asset is missing or empty: {relative}") | ||
|
|
||
| direct_url = importlib.metadata.distribution("aiq-agent").read_text("direct_url.json") or "" | ||
| if '"editable": true' in direct_url: | ||
| raise SystemExit("aiq-agent was installed editable") | ||
|
|
||
| print(f"Verified {len(expected)} non-empty runtime assets in source, wheel, and installed distribution") | ||
| print(f"Verified isolated aiq_agent import: {aiq_agent.__file__}") | ||
| PY | ||
|
|
||
| export NVIDIA_API_KEY="ci-not-a-real-key" # pragma: allowlist secret | ||
| export OPENAI_API_KEY="ci-not-a-real-key" # pragma: allowlist secret | ||
| export TAVILY_API_KEY="ci-not-a-real-key" # pragma: allowlist secret | ||
| export SERPER_API_KEY="ci-not-a-real-key" # pragma: allowlist secret | ||
| export REDIS_PASSWORD="ci-not-a-real-password" # pragma: allowlist secret | ||
| export NAT_JOB_STORE_DB_URL="sqlite+aiosqlite:///$RUNTIME_ROOT/jobs.db" | ||
| export AIQ_CHECKPOINT_DB="$RUNTIME_ROOT/checkpoints.db" | ||
| export AIQ_SUMMARY_DB="sqlite+aiosqlite:///$RUNTIME_ROOT/summaries.db" | ||
| export AIQ_CHROMA_DIR="$RUNTIME_ROOT/chroma" | ||
| export AZURE_SEARCH_ENDPOINT="https://azure-search.invalid" | ||
| export MCP_TOKEN_DB="$RUNTIME_ROOT/mcp_tokens.db" | ||
| export AIQ_OPENSHELL_POLICY_FILE="$RUNTIME_ROOT/configs/openshell/aiq-research-policy.yaml" | ||
|
|
||
| config_count=0 | ||
| while IFS= read -r config_path; do | ||
| config_count=$((config_count + 1)) | ||
| echo "Validating installed workflow: ${config_path#"$RUNTIME_ROOT/"}" | ||
| "$VENV_DIR/bin/nat" validate --config_file "$config_path" | ||
| done < <(find "$RUNTIME_ROOT/configs" -maxdepth 1 -type f -name 'config_*.yml' | sort) | ||
|
|
||
| if [[ "$config_count" -eq 0 ]]; then | ||
| echo "No shipped top-level workflow configs were discovered" >&2 | ||
| exit 1 | ||
| fi | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| echo "Validated $config_count shipped top-level workflow configs from the installed release artifact" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -238,7 +238,7 @@ version = "1.0.0" | |||||||||||||||||||||||||||||||
| description = "NAT-based custom search tool" | ||||||||||||||||||||||||||||||||
| requires-python = ">=3.11,<3.14" | ||||||||||||||||||||||||||||||||
| dependencies = [ | ||||||||||||||||||||||||||||||||
| "nvidia-nat==1.5.0", | ||||||||||||||||||||||||||||||||
| "nvidia-nat-core==1.8.0", | ||||||||||||||||||||||||||||||||
| "httpx>=0.24.0", | ||||||||||||||||||||||||||||||||
| "pydantic>=2.0.0", | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
|
|
@@ -251,7 +251,7 @@ Key points: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - The `package-dir` maps the package name to `src/` so Python can find your module. | ||||||||||||||||||||||||||||||||
| - The entry point key (`my_search_tool`) maps to the `register` module, which triggers `@register_function` at import time. | ||||||||||||||||||||||||||||||||
| - Pin `nvidia-nat` to the same version used by the main project. | ||||||||||||||||||||||||||||||||
| - Pin `nvidia-nat-core` to the same version used by the main project. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -415,9 +415,23 @@ async def _search(query: str) -> str: | |||||||||||||||||||||||||||||||
| Use the XML `<Document>` format for results that include URLs. This allows the agent's prompt to extract and cite sources: | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||||
| f'<Document href="{url}">\n<title>\n{title}\n</title>\n{content}\n</Document>' | ||||||||||||||||||||||||||||||||
| import html | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def _render_document(url: str | None, title: str | None, content: str | None) -> str: | ||||||||||||||||||||||||||||||||
|
KyleZheng1284 marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||
| safe_url = html.escape("" if url is None else url, quote=True) | ||||||||||||||||||||||||||||||||
| safe_title = html.escape("" if title is None else title) | ||||||||||||||||||||||||||||||||
| safe_content = html.escape("" if content is None else content) | ||||||||||||||||||||||||||||||||
| return f'<Document href="{safe_url}">\n<title>\n{safe_title}\n</title>\n{safe_content}\n</Document>' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| result = _render_document(url, title, content) | ||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Keep this renderer private to the independently installable plugin and preserve | ||||||||||||||||||||||||||||||||
| the fixed document shape. Escaping provider-controlled values prevents them | ||||||||||||||||||||||||||||||||
| from closing trusted tags or creating additional document elements. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+448
to
+459
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Show how callers import The helper is defined in Suggested documentation adjustment+from my_search_tool.my_client import _render_document
+
result = _render_document(url, title, content)As per path instructions, documentation examples must remain accurate across the repository layout. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ## Existing Tool Reference | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.