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

@@ -21,12 +21,12 @@ from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from deepagents import create_deep_agent
RUNTIME_SKILLS_ROOT = "/outputs/research-agent/.deepagents/skills/"
RUNTIME_SKILLS_DIR = "research-agent/.deepagents/skills/"
SYSTEM_PROMPT = """\
You are a careful research agent. Use project skills for workflow rules and
use workspace-backed tools for durable files. Prefer /workspace/outputs/ for
stable output paths.
stable output paths only when that is one of the grant write prefixes.
"""
@@ -50,7 +50,7 @@ def build_graph(ctx: Any) -> Any:
return json.dumps({"ok": not missing, "missing_indexes": missing})
backend = ctx.workspace_backend()
skill_sources = seed_runtime_skills(backend)
skill_sources = seed_runtime_skills(backend, ctx)
return create_deep_agent(
model=model,
backend=backend,
@@ -71,18 +71,29 @@ def build_graph(ctx: Any) -> Any:
)
def seed_runtime_skills(backend: Any) -> list[str]:
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 []
runtime_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_root + rel, path.read_bytes()))
if uploads:
backend.upload_files(uploads)
return [RUNTIME_SKILLS_ROOT]
return [runtime_root]
return []
```