Teach builder to author DeepAgents skills
All checks were successful
build / build (push) Successful in 26s

This commit is contained in:
robert
2026-05-19 09:39:29 -03:00
parent e1d9eab879
commit f6c612a071
10 changed files with 857 additions and 13 deletions

View File

@@ -6,10 +6,13 @@ import unittest
from agent_builder.tools import (
_BUILDER_STATE_FILE,
_BUILDER_INTERNAL_PREFIX,
_deployment_drift_error,
_files_from_tarball,
_parse_supporting_skill_files,
_replace_workspace_files,
_render_a2a_init_template,
_render_skill_md,
_tarball_workspace_dir,
)
@@ -25,6 +28,9 @@ class TemplateInitTests(unittest.TestCase):
self.assertIn('name = "research-agent"', files["agent.py"])
self.assertIn('description = "Research helper"', files["agent.py"])
self.assertIn("LLMProvisioning.CALLER_PROVIDED", files["agent.py"])
self.assertIn("WorkspaceAccess.dynamic", files["agent.py"])
self.assertIn("RUNTIME_SKILLS_ROOT", files["agent.py"])
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"])
@@ -85,6 +91,7 @@ class TemplateInitTests(unittest.TestCase):
s3 = _FakeS3({
prefix + "agent.py": b"print('ok')\n",
prefix + _BUILDER_STATE_FILE: b'{"repo_head_sha":"abc1234"}',
prefix + _BUILDER_INTERNAL_PREFIX + "skills/x/SKILL.md": b"hidden",
})
bundle = _tarball_workspace_dir(s3, "bucket", prefix)
@@ -92,6 +99,29 @@ class TemplateInitTests(unittest.TestCase):
with tarfile.open(fileobj=io.BytesIO(bundle), mode="r:gz") as tf:
self.assertEqual(tf.getnames(), ["agent.py"])
def test_render_skill_md_creates_valid_frontmatter(self) -> None:
text = _render_skill_md(
"market-research",
"Plan market research and synthesize findings.",
"Use subagents for separate market segments.",
)
self.assertIn("name: market-research", text)
self.assertIn('description: "Plan market research', text)
self.assertIn("# market-research", text)
def test_parse_supporting_skill_files_rejects_unsafe_paths(self) -> None:
with self.assertRaises(ValueError):
_parse_supporting_skill_files('{"../secrets.txt": "bad"}')
files = _parse_supporting_skill_files(
'{"references/schema.md": "schema", "scripts/check.py": "print(1)"}'
)
self.assertEqual(
sorted(files),
["references/schema.md", "scripts/check.py"],
)
def test_files_from_tarball_rejects_unsafe_paths(self) -> None:
bundle = _tarball({"../agent.py": "bad"})