require a2a pack write prefix support
All checks were successful
build / build (push) Successful in 20s

This commit is contained in:
robert
2026-05-26 20:34:08 -03:00
parent 1ce66340bd
commit cd15dc3aaa
9 changed files with 64 additions and 30 deletions

View File

@@ -17,7 +17,8 @@ Use this shape for non-trivial generated agents:
DeepAgent with `create_deep_agent`.
3. Pass `backend=ctx.workspace_backend()` so DeepAgents file tools write to the
caller's durable workspace instead of LangGraph state.
4. Pass `skills=[RUNTIME_SKILLS_ROOT]` when the generated project includes
4. Seed project skills into the current grant's write prefix and pass
`skills=skill_sources or None` when the generated project includes
`skills/<skill-name>/SKILL.md`.
5. For custom subagents, include a `skills` field on each subagent definition.
The general-purpose subagent inherits main skills, but custom subagents do
@@ -47,32 +48,46 @@ before `create_deep_agent`:
```python
from pathlib import Path
from typing import Any
RUNTIME_SKILLS_ROOT = "/outputs/{{ agent_name }}/.deepagents/skills/"
RUNTIME_SKILLS_DIR = "{{ agent_name }}/.deepagents/skills/"
def _seed_runtime_skills(backend: Any) -> None:
def _runtime_skills_root(ctx: Any) -> str:
workspace = getattr(ctx, "_workspace", None)
prefixes = tuple(getattr(workspace, "write_prefixes", ()) or ())
if not prefixes:
outputs_prefix = getattr(workspace, "outputs_prefix", None)
prefixes = (outputs_prefix or "outputs/",)
prefix = str(prefixes[0]).strip("/")
return f"/{prefix}/{RUNTIME_SKILLS_DIR}" if prefix else f"/{RUNTIME_SKILLS_DIR}"
def _seed_runtime_skills(backend: Any, ctx: Any) -> list[str]:
root = Path(__file__).parent / "skills"
if not root.exists():
return
return []
runtime_skills_root = _runtime_skills_root(ctx)
uploads: list[tuple[str, bytes]] = []
for path in root.rglob("*"):
if path.is_file():
rel = path.relative_to(root).as_posix()
uploads.append((RUNTIME_SKILLS_ROOT + rel, path.read_bytes()))
uploads.append((runtime_skills_root + rel, path.read_bytes()))
if uploads:
backend.upload_files(uploads)
return [runtime_skills_root]
return []
```
Then:
```python
backend = ctx.workspace_backend()
_seed_runtime_skills(backend)
skill_sources = _seed_runtime_skills(backend, ctx)
return create_deep_agent(
model=model,
backend=backend,
skills=[RUNTIME_SKILLS_ROOT],
skills=skill_sources or None,
tools=[small_deterministic_tool],
subagents=[...],
system_prompt=SYSTEM_PROMPT,