Repository navigation
Description
Summary
When a subscription-mode agent is stopped and started, the start API response includes \"credentials_injection\": \"failed\" with error \"No .credentials.enc file found in agent workspace\". This is misleading — subscription-mode agents (SUB-002) use CLAUDE_CODE_OAUTH_TOKEN env var injection, not file-based credential injection. The message implies a real failure when there is none, causing operators to take unnecessary remediation actions (e.g. re-assigning the subscription, which recreates the container and disrupts running state).
Component
Backend / Agent Lifecycle / Subscription Management
Priority
P3
Error
{
"message": "Agent <name> started",
"credentials_injection": "failed",
"credentials_result": {
"status": "failed",
"error": "No .credentials.enc file found in agent workspace"
}
}Root Cause
The agent start endpoint attempts file-based credential injection regardless of the agent's auth mode. When the agent is in subscription mode, no .credentials.enc file exists (by design — SUB-002 uses CLAUDE_CODE_OAUTH_TOKEN env var set at container creation time), so the injection step fails and surfaces that failure in the response. The response does not distinguish between a real failure (missing credentials on an API-key-mode agent) and an expected non-operation (subscription-mode agent where file injection is irrelevant).
Reproduction Steps
- Register a subscription and assign it to an agent
- Verify the agent container has
CLAUDE_CODE_OAUTH_TOKENset andANTHROPIC_API_KEYabsent - Call
POST /api/agents/{name}/stopthenPOST /api/agents/{name}/start - Observe: start response contains
credentials_injection: faileddespite the agent being correctly configured
Suggested Fix
In the agent start endpoint, check the agent's auth mode before attempting file-based credential injection:
# Before running file injection, check auth mode
agent_auth = db.get_agent_auth_mode(agent_name)
if agent_auth.auth_mode == "subscription":
# Subscription agents use CLAUDE_CODE_OAUTH_TOKEN env var — no file injection needed
credentials_result = {
"status": "skipped",
"reason": "subscription mode — credentials injected via CLAUDE_CODE_OAUTH_TOKEN env var"
}
else:
# Attempt file-based injection for API-key-mode agents
credentials_result = inject_credentials_file(agent_name)
return {
"message": f"Agent {agent_name} started",
"credentials_injection": credentials_result["status"],
"credentials_result": credentials_result
}This makes the response self-documenting: "credentials_injection": "skipped" with a clear reason is unambiguous, while "failed" is reserved for genuine failures on API-key-mode agents.
Environment
- Trinity version:
7d8abe8 - Docker version: 24.x
- OS: Ubuntu 22.04
Related
- SUB-002: subscription token injection via
CLAUDE_CODE_OAUTH_TOKENenv var - Agent start endpoint in
src/backend/routers/agents.py(or equivalent)
Activity
fix(agent-lifecycle): stop showing credentials_injection: failed for …
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
test(retention): load settings.py in isolation to dodge sys.modules p…
test(retention): load settings.py in isolation to dodge sys.modules p…
test(retention): load settings.py in isolation to dodge sys.modules p…
feat(retention): OSS 5-day community floor + prod-compose LOG_* fix (…
fix(tests): scope the #612 module stubs to the load that needs them (#…
fix(credentials): subscription agents import a committed .credentials…
fix(agent-runtime): drop the startup credentials auto-import that cal…