Repository navigation
Description
Summary
mcp__trinity__deploy_local_agent (POST /api/agents/deploy-local) — the archive-based deploy path used by the /trinity:onboard skill from the abilityai/abilities marketplace — is unreliable when the agent has no GitHub repository. Deployments either fail outright or succeed but produce empty agents (container starts with no template files, no CLAUDE.md, no skills).
Root cause
In src/backend/services/agent_service/deploy.py (the templates_dir writability probe at the "Copy to templates directory" step), the writability check on /agent-configs/templates always fails because that mount is bind-mounted read-only in both docker-compose.yml and docker-compose.prod.yml:
- ./config/agent-templates:/agent-configs/templates:roThe probe catches the OSError and falls back to:
templates_dir = Path("./config/agent-templates")./config/agent-templates is relative to the backend container's WORKDIR (/app) — it resolves to /app/config/agent-templates/<version-name>, which is not host-mapped. The extracted template lives only inside the backend container filesystem.
When create_agent_internal (in src/backend/services/agent_service/crud.py, elif config.template.startswith("local:") branches around the template_volume setup) then tries to bind-mount the template into the new agent container, it does two things, both broken:
- Checks
if template_path_in_backend.exists()against/agent-configs/templates/<name>— the read-only mount where the template was not written. Existence returnsFalse, sotemplate_volumestaysNoneand the new agent container is created without the template mounted at/template→ empty workspace, "empty agents" failure mode. - If the directory happens to exist (race / stale state), the bind source path is computed from
HOST_TEMPLATES_PATH(${PWD}/config/agent-templates/<name>), which doesn't exist on the host → Docker volume mount fails → "deploy fails" failure mode.
Net effect: the documented /trinity:onboard flow for archive-based deploy is broken on every standard deployment (dev + prod compose files both mark the templates dir :ro).
How to reproduce
- From a Claude Code agent without an associated GitHub repo, install the public marketplace plugin:
/plugin marketplace add abilityai/abilities /plugin install trinity@abilityai - Run
/trinity:onboardand choose "Deploy to Trinity". - The skill packages the local directory as a base64 tar.gz and calls
mcp__trinity__deploy_local_agent. - Observe either a hard failure or a "success" response where the new agent's
/api/agents/{name}/fileslisting shows no template content (noCLAUDE.md, notemplate.yaml, no.claude/skills/).
Acceptance criteria
-
POST /api/agents/deploy-localreliably extracts the archive to a host-mapped location (or another path that the new agent's bind-mount will actually see) - The fallback path no longer silently writes to a container-only directory; either it writes somewhere the new agent will read, or it fails fast with a clear error code
- After a successful
mcp__trinity__deploy_local_agentresponse, the new agent's workspace containstemplate.yaml,CLAUDE.md,.claude/skills/, and any other files from the archive - Repeated
/trinity:onboardruns against the same agent name produce the expected versioned redeploy (<base>-2, etc.) with full content, not empty workspaces - An integration test covers archive → deploy → verify-content on a clean Trinity instance using the stock
docker-compose.yml - Regression test added for the writable-templates-dir resolution so the read-only mount fallback can't silently degrade again
Technical notes
- Related code:
src/backend/services/agent_service/deploy.py—deploy_local_agent_logic, templates-dir writability probe, template copy stepsrc/backend/services/agent_service/crud.py—local:-prefixed template resolution,template_volumeconstructionsrc/backend/services/template_service.py—is_trinity_compatible(CLAUDE.md is a warning, not an error; an archive missing it still passes validation)docker-compose.ymlanddocker-compose.prod.yml—./config/agent-templates:/agent-configs/templates:ro(read-only mount that makes the writability probe always fall back)src/mcp-server/src/tools/agents.ts—deployLocalAgentMCP tool/trinity:onboardskill (SKILL.md v4.7) inabilityai/abilities— callsmcp__trinity__deploy_local_agentand writes.trinity-remote.yaml
- Related issue: SEC: POST /api/agents/deploy-local bypasses creator role check — any authenticated user can spawn agents (AISEC-H1) #592 (security gap on the same endpoint — role gating)
- Suggested fix direction: make
/agent-configs/templateswritable (either drop:roin compose, or mount a dedicated writable subdirectory for deployed-local templates while keeping the curated catalog read-only), and harden the fallback to fail loudly instead of writing into the container FS - Consider tightening
is_trinity_compatibleso deploys missingCLAUDE.mdor expected agent structure either fail or produce a structured warning surfaced in the deploy response, so users notice empty agents at deploy time instead of first interaction
Activity
fix(deploy-local): refactor to put_archive — works on dev + prod (#950)
fix(deploy): guard local template name against path traversal (#950)
fix(deploy): use resolve()+is_relative_to barrier for path-injection (#…
fix(deploy-local): write templates to host-mapped path (#950) (#971)
fix(deploy-local): add path-containment guard to clear CodeQL py/path…
vybe commentedon Jun 2, 2026
Closed by #982 (squash-merged to
dev). Core fix landed earlier in #971; this PR adds the deferred hardening:is_trinity_compatible()now blocks on a missing/empty/whitespace/non-UTF-8 CLAUDE.md (clean 400, not a 500), advisory MCP credential-gap warnings onDeployLocalResponse.warnings[], operator-supplied MCP server-name sanitization (CSO L1), and a path-containment guard on the deployed-template path. Ships tomainon next release.vybe commentedon Jun 2, 2026
Reopening — PR #982 hit a merge conflict against
devand is not yet merged. Will close once it lands.Merge origin/dev into plan-issue-950
fix(deploy-local): require usable CLAUDE.md + advisory MCP credential…
vybe commentedon Jun 2, 2026
Closed by #982 (squash-merged to
devafter resolving a docs-index merge conflict against current dev — CI re-ran green on the merge commit). Core fix landed earlier in #971; this PR adds the deferred hardening:is_trinity_compatible()now blocks on missing/empty/whitespace/non-UTF-8 CLAUDE.md (clean 400, not 500), advisory MCP credential-gap warnings onDeployLocalResponse.warnings[], operator-supplied MCP server-name sanitization (CSO L1), and a path-containment guard. Ships tomainon next release.9 remaining items
fix(agents): exempt ghosts from the volume-base gate; stub it in the …
fix(agents): adopting a pre-existing workspace volume is a decision, …
fix(volumes): rename-safe volume identity — sweep, purge, create and …
fix(agents): thread adopt_existing_workspace through create_agent_int…
fix(create): reject an unresolvable local: template instead of creati…
fix(agents): reject an invalid local: template and ship the missing l…
fix(agents): reject an invalid local: template and ship the missing l…
fix(create): reject an unresolvable local: template instead of creati…
fix(templates): contain local: template ids and stop deriving credent…
fix(deploy): confine the partial-deploy cleanup at the sink (#2006)
fix(deploy): validate an archive .mcp.json before it is persisted, no…
Release: v0.9.0 (#2268)
fix(deploy): make the dest_path containment guard the barrier shape C…
fix(deploy): deploy-local integrity contract — embedded manifest veri…