[ci-clone] #5581: sandbox error type slug (do not merge) - #5587
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesSandbox error type resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sdks/python/agenta/sdk/agents/errors.py (1)
44-58: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winEnsure the SDK validation checks pass before committing.
Run the required commands from
sdks/python;py-run-testsis unavailable here, butruff checkstill fails onagenta/sdk/agents/errors.py:49formessage: str = None. Typemessageexplicitly asOptional[str]/str | Noneand rerun the SDK checks.Source: Coding guidelines
🧹 Nitpick comments (1)
sdks/python/oss/tests/pytest/unit/agents/test_errors.py (1)
10-18: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the complete error type, not only substrings.
These tests can pass with an incorrectly formatted slug as long as it contains
"daytona"or"local". Assert the exact expected values, includingERRORS_BASE_URL, version, namespace, and suffix, to lock down the public contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b336e4b7-2a97-48a7-818a-055a9046f8e9
📒 Files selected for processing (2)
sdks/python/agenta/sdk/agents/errors.pysdks/python/oss/tests/pytest/unit/agents/test_errors.py
| resolved_type = ( | ||
| f"{ERRORS_BASE_URL}#v0:agent:sandbox-provider-not-allowed:{sandbox}" | ||
| ) | ||
| super().__init__(code=self.code, type=resolved_type, message=resolved) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate file =="
git ls-files | rg '(^|/)agents/errors\.py$|^sdks/python/.+' || true
echo "== file outline/contents =="
if [ -f sdks/python/agenta/sdk/agents/errors.py ]; then
wc -l sdks/python/agenta/sdk/agents/errors.py
cat -n sdks/python/agenta/sdk/agents/errors.py
else
echo "file not found"
fi
echo "== related usages =="
rg -n "sandbox_provider_enabled|PROVIDER|errors\." sdks/python/agenta/sdk/agents -S || trueRepository: Agenta-AI/agenta
Length of output: 39457
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== errors unit tests =="
cat -n sdks/python/oss/tests/pytest/unit/agents/test_errors.py
echo "== handler excerpt =="
cat -n sdks/python/agenta/sdk/agents/handler.py | sed -n '65,95p'
echo "== sandbox_providers excerpt =="
cat -n sdks/python/agenta/sdk/agents/sandbox_providers.py | sed -n '1,110p'
echo "== pyproject ruff/test config =="
cat -n sdks/python/pyproject.toml | sed -n '1,220p'
echo "== deterministic behavior probe =="
python3 - <<'PY'
from pathlib import Path
import ast
errors_path = Path("sdks/python/agenta/sdk/agents/errors.py")
src = errors_path.read_text()
tree = ast.parse(src)
class Finder(ast.NodeVisitor):
def visit_Assign(self, node):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "KNOWN_SANDBOX_PROVIDERS":
self.providers = ast.literal_eval(node.value)
self.generic_visit(node)
finder = Finder()
finder.visit(tree)
def module_globals(src):
ns = {
"pathlib": __import__("pathlib"),
"os": __import__("os"),
"__name__": "__test__",
}
exec(src, ns)
return ns
from sdks.ossa.sdk.agents.errors import ERRORS_BASE_URL
print("KNOWN_SANDBOX_PROVIDERS =", finder.providers)
print("ERRORS_BASE_URL =", ERRORS_BASE_URL)
ns = module_globals({"sdks.python.agenta.sdk.agents.sandbox_providers": Path("./dummy").read_text()})
# inspect relevant source text rather than import repo code
print("sdk source contains strip().lower():", ".strip().lower()" in Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text())
print("errors source interpolates raw sandbox:", f"resolved_type = (\n f\"{{ERRORS_BASE_URL}}`#v0`:agent:sandbox-provider-not-allowed:{{sandbox}}\"" in src)
import sys
sys.path.insert(0, str(Path("sdks/python").resolve()))
# not running repo code; using source inspection only due to import safety policy
PYRepository: Agenta-AI/agenta
Length of output: 10486
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== direct provider normalizer probe =="
python3 - <<'PY'
from pathlib import Path
from ast import parse, literal_eval
p = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py")
src = p.read_text()
tree = parse(src)
known = None
for node in tree.body:
if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
pass
for node in tree.body:
if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
pass
for node in tree.body:
if isinstance(node, parse().body[0].__class__) and isinstance(node, parse().body[0].__class__):
pass
# simple extracted values from source text
for line in src.splitlines():
if "KNOWN_SANDBOX_PROVIDERS =" in line:
known = literal_eval(line.split("=", 1)[1])
print("KNOWN_SANDBOX_PROVIDERS =", known)
def sandbox_provider_enabled(provider: str):
def enabled():
return known
return provider.strip().lower() in enabled()
def error_slug(provider: str):
return f"{provider}" # placeholder for snippet interpolation variable
print("sandbox_provider_enabled(' Daytona '):", sandbox_provider_enabled(" Daytona "))
print("slot_producer_enabled_case_preserved():", sandbox_provider_enabled("Daytona") == sandbox_provider_enabled(" dayToNa ") == True)
print("generated_slug_for_DAYTONA_with_spaces:", error_slug(" Daytona "))
print("canonical_slug:", error_slug("daytona"))
PY
echo "== read-only function normalization probe =="
python3 - <<'PY'
from pathlib import Path
from ast import parse, FunctionDef, Call, Attribute, Name, Str, Constant
text = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text()
tree = parse(text)
for n in tree.body:
if isinstance(n, FunctionDef) and n.name == "sandbox_provider_enabled":
func = n
break
else:
raise SystemExit("definition not found")
for stmt in func.body:
if isinstance(stmt, Return) and isinstance(stmt.value, Compare):
print("comparison operator:", stmt.value.ops[0])
left = stmt.value.left
right = stmt.value.comparators[0]
print("left contains strip call:", isinstance(left, Call) and isinstance(left.func, Attribute) and left.func.attr == "strip")
print("left contains lower call:", isinstance(left, Call) and isinstance(left.func, Attribute) and left.func.attr == "lower")
print("right contains enabled_sandbox_providers:", any(
isinstance(m, NodeVisitor),
))
PYRepository: Agenta-AI/agenta
Length of output: 334
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
providers = Path("sdks/python/agenta/sdk/agents/sandbox_providers.py").read_text()
errors = Path("sdks/python/agenta/sdk/agents/errors.py").read_text()
print("Known providers:")
for line in providers.splitlines():
if "KNOWN_SANDBOX_PROVIDERS =" in line:
print(" ", line)
print("\nsandbox_provider_enabled normalization:")
for line in providers.splitlines():
if "def sandbox_provider_enabled" in line or "strip().lower" in line:
print(" ", line)
print("\nLocalSandboxNotAllowedError uses:")
for line in errors.splitlines():
if "LocalSandboxNotAllowedError" in line or "resolved_type" in line or "resolved = message" in line or "AGENTA_RUNNER_ENABLED" in line:
print(" ", line)
def enabled(provider: str):
# mirrors the current implementation in sandbox_providers.py
return provider.strip().lower() in ("local", "daytona")
def slug(provider: str):
# current interpolation only applies to the f-string, not to the argument
return f"https://docs.agenta.ai/errors#v0:agent:sandbox-provider-not-allowed:{provider}"
print("\nBehavioral probe:")
for value in ["daytona", " Daytona ", "Daytona", " DAYTONA "]:
print(f"{value!r}: enabled={enabled(value)}, error_type={slug(value)}")
PYRepository: Agenta-AI/agenta
Length of output: 1441
Normalize the provider before constructing the error slug.
sandbox_provider_enabled() treats inputs like " Daytona " as enabled via strip().lower(), but LocalSandboxNotAllowedError interpolates the raw sandbox value into type and message. Use the normalized provider when building the error type/message so rejections don’t branch on non-canonical slugs.
Railway Preview Environment
Updated at 2026-07-30T15:27:32.532Z |
CI clone of #5581 by @Aman-goel-04. The
build / build-imagejobs cannot access repo secrets on the fork PR, so they fail immediately there; this branch contains the exact same head commit pushed into the main repo so the full suite runs for real.Do not merge. This PR will be closed without merging once the checks settle. The real PR to review and merge is #5581.
https://claude.ai/code/session_01Qitvc9dCiunLishsJYRzbp