Repository navigation
Description
Summary
When deploying an agent from a private GitHub repository template, Trinity fails with a PAT authentication error if no per-agent GitHub PAT is configured. Trinity should fall back to the platform-level GitHub PAT (set via `PUT /api/settings/api-keys/github`) for the template clone step, but it does not — the deploy fails instead of using the available platform credential.
Component
Backend / Agent Deploy / Git Template Clone
Priority
P2 — feature impaired, workaround available (set a per-agent PAT or configure the platform PAT before deploying)
Error
Error: GitHub PAT is not valid or does not have access to the repository
Observed during agent deploy from a private GitHub template when no per-agent PAT is set.
Root Cause
The agent deploy flow (template clone from github:ORG/REPO) checks for a per-agent GitHub PAT but does not fall back to the platform PAT when none is configured for the (not-yet-created) agent. The platform PAT stored via PUT /api/settings/api-keys/github is available in the backend but is not injected into the template clone operation.
Evidence: GITHUB_PAT env var is present in the backend container environment (confirming the field is wired up in compose) but can be empty if not set in .env. When empty, there is no fallback to the DB-stored platform PAT set via the API endpoint.
Reproduction Steps
- Stand up a Trinity instance without
GITHUB_PATset in the instance.env - Optionally set a platform PAT via
PUT /api/settings/api-keys/github(DB-stored path) - In the Trinity UI or via MCP, create a new agent using a private GitHub repo as the template (e.g.
github:ORG/private-repo) - Observe: deploy fails with PAT authentication error
- Expected: Trinity uses the platform PAT (env var or DB-stored) to authenticate the template clone
Expected Behaviour
The fallback chain for GitHub authentication during agent deploy should be:
- Per-agent PAT (from
agent_git_config.github_pat_encrypted) — if the agent already exists - Platform PAT (from
GITHUB_PATenv var or DB-stored via settings API) - Unauthenticated (public repos only)
Currently step 2 is skipped, causing private repo deploys to fail when no per-agent PAT exists.
Suggested Fix
In the agent template clone / deploy code path, after checking for a per-agent PAT, fall back to the platform PAT:
# Pseudocode — in the template fetch / git clone helper
pat = get_agent_pat(agent_name) # per-agent encrypted PAT
if not pat:
pat = settings.github_pat # platform PAT (env var or DB)
clone_url = inject_pat_into_url(template_repo_url, pat) if pat else template_repo_urlThe same fallback logic should apply consistently to: template clone at deploy time, git sync operations, and any other GitHub API calls made on behalf of an agent.
Environment
- Trinity version:
f7450cab - Docker version: 29.3.0
- OS: Ubuntu 22.04
Related
PUT /api/settings/api-keys/github— platform PAT storage endpointPUT /api/agents/{name}/github-pat— per-agent PAT endpointagent_git_config.github_pat_encrypted— per-agent PAT in DBGET /api/agents/{name}/github-patresponse includeshas_global: truefield, suggesting the platform PAT concept is already modelled — but not used in deploy path
Activity
vybe commentedon May 8, 2026
/claim
github-actions commentedon May 8, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/735-<short-slug>Fixes #735fix(git): use per-agent PAT fallback in github sync, helpers, and lif…
vybe commentedon May 10, 2026
Fixed in PR #739 (3c00d76 on dev). Per-agent PAT fallback now applied in github_sync, helpers, and lifecycle; platform-level PAT used when agent-specific one is absent.
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
Release: v0.6.1 (#1171)
test(#735): re-anchor the lifecycle PAT call-site guard onto _apply_g…
test(#735): re-anchor the lifecycle PAT call-site guard onto _apply_g…
test(#735): re-anchor the lifecycle PAT call-site guard onto _apply_g…
test(#735): re-anchor the lifecycle PAT call-site guard onto _apply_g…
fix(lifecycle): re-derive git env from the DB on config-drift recreat…
feat(git): bind an agent to a GitHub repo you own — post-creation own…