Repository navigation
fix(agent-runtime): drop the startup credentials auto-import that called a route that never existed (#3510) - #3758
Conversation
…led a route that never existed (#3510) startup.sh called POST /api/internal/decrypt-and-inject when an agent started with a .credentials.enc and no .env. No handler was ever added, so the call failed on every start and the message blamed a missing encryption key, while the agent ran without its credentials. Ruled: remove it rather than implement it. An implementation needs an agent-callable decrypt (the master internal secret never reaches an agent), and the file lives in the agent's own home, so an agent could stage another agent's blob and have the platform decrypt it. Decrypting stays the owner's Import from Git / import_credentials. - startup.sh: the curl is gone; on .credentials.enc without .env it says the file is not imported at startup and names Import from Git. - models.py: drop the unreferenced InternalDecryptInjectRequest. - test_3510: every literal backend call in the agent image must resolve to a route in the live table (via the #2996 census helper); the scanner is checked against the old call. - test_2007: the render-after-.env ordering anchors on /generated-creds. - Docs: api-endpoints, credential-injection flow, two user docs and the agent guide no longer describe an automatic import. Fixes #3510 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Tested against a local instance (rc3 agent base image
Before (the current base image): No After (the same image with only this PR's No The named remedy works. Notes:
|
|
merge-train: held back from today's train. It rides the next one once this is addressed. Blocking: the new startup message and docs describe the wrong behaviour. Needs a decision: should subscription-mode agents still get their non-Anthropic credentials (MCP keys in Smaller, mechanical:
Removing the dead curl block itself is correct and safe: the route never existed. |
…credentials-import
…f-string backend calls (#3510) startup.sh and four docs claimed .credentials.enc is never imported at start; the backend imports it after the agent is ready (skipped for subscription, ephemeral, no-key). The route-existence test now matches {backend_url}/api forms and asserts a non-empty scan. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
obasilakis
left a comment
There was a problem hiding this comment.
Review + validate-pr: approve. No blockers. CI green (pytest (head) 27303 passed, regression diff clean).
Reverting the fix turns test_startup_says_what_happens… and test_the_dead_request_model_is_gone red. The route scanner finds 5 real backend calls in the image, so it is not vacuous.
Docs and descriptions that don't match the final code. The code and user docs now say the backend imports a committed .credentials.enc on cold start, via lifecycle.inject_assigned_credentials(). These spots still say only the owner imports it:
- PR body: Summary and Changes still quote "…not imported at startup… Credentials tab > Import from Git". The new test asserts that wording is gone.
- Test docstrings:
tests/unit/test_3510_startup_backend_paths.py:10-11andtests/unit/test_2007_mcp_template_render.py:364-365. Suggested wording: "the backend imports it after the agent is ready; startup.sh never decrypts". docs/memory/feature-flows/credential-injection.mdFlow 4 ends with a paragraph on the removed route and the decision date. Keep only the current behaviour and the pointer to the guard test.
Low
4. The scanner regex at tests/unit/test_3510_startup_backend_paths.py:35-38 matches only inline URLs (http://backend:8000/..., {backend_url}/..., ${TRINITY_BACKEND_URL}/...). It misses a path held in a constant and appended later: docker/base-image/hooks/_skill_gate.py:86 CHECK_PATH = "/api/skill-gate/check", used at :748. That route exists today. Either also scan quoted "/api/…" literals in the image, or state the covered call shapes in the test.
Follow-up (already on dev, out of scope here)
5. src/backend/services/agent_service/lifecycle.py:114-185 → credential_encryption.py:438 import_to_agent decrypts whatever .credentials.enc sits in the agent's home with the platform key. Nothing binds the file to that agent. #3510's ruling rejects a startup decrypt for exactly that reason (staging another agent's blob), and this PR now documents the backend path as the supported one. Worth a separate issue: bind the encrypted file to its agent, or restate the ruling so it matches the path that runs.
Info
- The backend import lands after the
.mcp.json.templaterender;startup.sh:705-707already notes this. - The startup message prints even when the backend import will succeed. Accurate but noisy.
obasilakis
left a comment
There was a problem hiding this comment.
Approving. Please fix the stale PR body and docstrings noted in the review comment above. The follow-up item is for a separate issue.
….enc too (#3510) Review decision: the #612 skip silently dropped a subscription agent's MCP keys and other non-Anthropic credentials. Under subscription the agent server force-unsets Anthropic API-key variables at every spawn (#2114), so an imported ANTHROPIC_API_KEY cannot shadow the subscription. The #606/#612 harm (a missing file read as failed, retried, failing the trigger) stays fixed: it is the clean no_credentials_enc_file skip, tried once. startup.sh and the docs drop the subscription exception. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed in Blocking: the startup message and docs. Corrected. Decision: subscription agents import too. We removed the #612 skip in
Mechanical.
Locally: 14 targeted tests pass, and 1739 pass across the credential, subscription and lifecycle tests. 🤖 Generated with Claude Code |
Summary
startup.shcalledPOST /api/internal/decrypt-and-injectwhenever an agent started with a.credentials.encand no.env. No handler was ever added: the feature commit added only the call and a request model. So the call failed on every start, the message blamed "key may not be configured", and the agent ran without its credentials.import_credentials, which already works.Changes
docker/base-image/startup.sh: thecurlblock is replaced by a message ("Found .credentials.enc but no .env: encrypted credentials are not imported at startup… Credentials tab > Import from Git"). The.mcp.json.templatecomment no longer counts it as an.envsource.src/backend/models.py: the unreferencedInternalDecryptInjectRequestis removed.tests/unit/test_3510_startup_backend_paths.py(new):http://backend:8000/api/…call indocker/base-imagemust resolve to a route in the live table (through the bug(auth): agent-scoped keys can toggle their own agent's autonomy — PUT /api/agents/{name}/autonomy lacks reject_agent_principal #2996 census subprocess);tests/unit/test_2007_mcp_template_render.py: the render-after-.envordering now anchors on/generated-creds/.env.architecture/api-endpoints.md(the row is removed),feature-flows/credential-injection.md(Flow 4 rewritten),user-docs/credentials/credential-management.md,user-docs/faq/credentials-and-subscriptions.md,TRINITY_COMPATIBLE_AGENT_GUIDE.md.Test Plan
startup.shor these docs: 729 passed, 1 skipped..credentials.enconly it prints the message and exits 0; with a.envpresent it says nothing../scripts/deploy/build-base-image.sh); an agent created from a repo that commits only.credentials.enclogs the new message, and Import from Git fills.env.Fixes #3510
🤖 Generated with Claude Code