Use sandbox client for builder validation
All checks were successful
build / build (push) Successful in 14s
All checks were successful
build / build (push) Successful in 14s
This commit is contained in:
@@ -162,7 +162,7 @@ inline = Pricing(price_per_call_usd=0.01, compute={"runtime_seconds": 600}, tota
|
||||
self.assertIn("skills=skill_sources or None", files["deepagent-agent-design/SKILL.md"])
|
||||
self.assertIn("from a2a_pack import", files["a2apack-agent-authoring/SKILL.md"])
|
||||
self.assertIn("ctx.workspace_shell", files["a2apack-agent-authoring/SKILL.md"])
|
||||
self.assertIn("create_deep_agent", files["deepagents-implementation-patterns/SKILL.md"])
|
||||
self.assertIn("create_a2a_deep_agent", files["deepagents-implementation-patterns/SKILL.md"])
|
||||
self.assertIn('config={"recursion_limit": 500}', files["deepagents-implementation-patterns/SKILL.md"])
|
||||
self.assertIn("ctx.write_artifact", files["workspace-artifact-safety/SKILL.md"])
|
||||
self.assertIn("ctx.workspace_shell", files["workspace-artifact-safety/SKILL.md"])
|
||||
|
||||
@@ -47,7 +47,7 @@ class TemplateInitTests(unittest.TestCase):
|
||||
self.assertIn("skills=skill_sources or None", files["agent.py"])
|
||||
self.assertIn("ctx.llm", files["agent.py"])
|
||||
self.assertIn("ctx.workspace_backend()", files["agent.py"])
|
||||
self.assertIn("create_deep_agent", files["agent.py"])
|
||||
self.assertIn("create_a2a_deep_agent", files["agent.py"])
|
||||
self.assertIn("name: research-agent", files["a2a.yaml"])
|
||||
self.assertIn("entrypoint: agent:ResearchAgent", files["a2a.yaml"])
|
||||
self.assertNotIn("{{ frontend_block }}", files["a2a.yaml"])
|
||||
@@ -272,6 +272,35 @@ class TemplateInitTests(unittest.TestCase):
|
||||
|
||||
self.assertIn("manifest_json must be a JSON object", result["error"])
|
||||
|
||||
def test_test_agent_in_sandbox_uses_attached_sandbox_client(self) -> None:
|
||||
workspace = _FakeWorkspace()
|
||||
prefix = "agents/demo-agent/"
|
||||
workspace.write_bytes(prefix + "agent.py", b"print('ok')\n")
|
||||
workspace.write_bytes(prefix + "a2a.yaml", b"name: demo-agent\n")
|
||||
workspace.write_bytes(prefix + "requirements.txt", b"")
|
||||
sandbox = _FakeSandbox()
|
||||
tools = build_tools(
|
||||
ToolContext(
|
||||
bucket="bucket",
|
||||
settings=_settings(),
|
||||
workspace=workspace,
|
||||
sandbox=sandbox,
|
||||
grant_token="grant-token",
|
||||
)
|
||||
)
|
||||
test_tool = _tool_by_name(tools, "test_agent_in_sandbox")
|
||||
|
||||
_FakeAsyncClient.posts = []
|
||||
with patch("agent_builder.tools.httpx.AsyncClient", _FakeAsyncClient):
|
||||
result = json.loads(
|
||||
asyncio.run(test_tool.ainvoke({"name": "demo-agent"}))
|
||||
)
|
||||
|
||||
self.assertEqual(result["exit_code"], 0)
|
||||
self.assertEqual(len(sandbox.calls), 1)
|
||||
self.assertEqual(sandbox.calls[0]["workspace"], "bucket")
|
||||
self.assertEqual(_FakeAsyncClient.posts, [])
|
||||
|
||||
def test_cp_deploy_tarball_posts_agent_dsl(self) -> None:
|
||||
workspace = _FakeWorkspace()
|
||||
prefix = "agents/demo-agent/"
|
||||
@@ -529,6 +558,21 @@ class _FakeWorkspace:
|
||||
self.objects.pop(key, None)
|
||||
|
||||
|
||||
class _FakeExecResult:
|
||||
exit_code = 0
|
||||
stdout = "--- card ---\n{}"
|
||||
stderr = ""
|
||||
|
||||
|
||||
class _FakeSandbox:
|
||||
def __init__(self) -> None:
|
||||
self.calls: list[dict[str, object]] = []
|
||||
|
||||
async def run_shell(self, script: str, **kwargs: object) -> _FakeExecResult:
|
||||
self.calls.append({"script": script, **kwargs})
|
||||
return _FakeExecResult()
|
||||
|
||||
|
||||
def _tool_by_name(tools: list[object], name: str) -> object:
|
||||
for tool in tools:
|
||||
if getattr(tool, "name", None) == name:
|
||||
|
||||
Reference in New Issue
Block a user