hire-an-agent does not persist per-agent secrets to .env #847

Closed
opened 2026-04-16 10:03:53 +00:00 by dev-bot · 0 comments
Collaborator

Problem

disinto hire-an-agent <name> <role> creates a Forgejo user and API token successfully, but does not write the resulting credentials into /home/johba/disinto/.env. The compose service block is emitted referencing env vars like FORGE_TOKEN_DEV_QWEN, FORGE_PASS_DEV_QWEN, and ANTHROPIC_BASE_URL — none of which exist in .env. The container starts with empty credentials and either crash-loops or 401s against Forgejo silently.

Generalization: the bug applies to any secret an emitted service block references, regardless of backend. Local-model agents need FORGE_TOKEN_<USER> + FORGE_PASS_<USER> + ANTHROPIC_BASE_URL; Anthropic-backend agents need FORGE_TOKEN_<USER> + FORGE_PASS_<USER> + ANTHROPIC_API_KEY. Today neither set is persisted by hire-an-agent.

Repro

  1. Run disinto hire-an-agent dev-qwen dev --local-model http://10.10.10.1:8081 --model unsloth/Qwen3.5-35B-A3B on a fresh .env with no FORGE_TOKEN_DEV_QWEN.
  2. Confirm Forgejo user + token were created (visible in admin UI).
  3. grep DEV_QWEN /home/johba/disinto/.env → empty.
  4. disinto updisinto-agents-llama starts with blank FORGE_TOKEN; git push and Forgejo API calls return 401.

Naming rule (so the fix matches reality)

Env-var keys are derived from forge_user: dashes → underscores, uppercased. So agent dev-qwen needs:

  • FORGE_TOKEN_DEV_QWEN
  • FORGE_PASS_DEV_QWEN
  • ANTHROPIC_BASE_URL (shared, when local model) OR ANTHROPIC_API_KEY (when Anthropic backend)

Fix

  • hire-an-agent writes/merges the required vars into .env after creating the Forgejo user.
  • disinto up validates that every emitted service block has its required env vars present, and fails loudly with the exact missing keys.

Do both: write on hire, validate on up.

Rotation

Define the rotation path explicitly:

  • Re-running disinto hire-an-agent <same-name> should rotate the API token + password idempotently and update .env in place, OR
  • Introduce disinto agent rotate <name> as a separate subcommand.

Either works; pick one and document it. Today there is no defined rotation story, which is how this whole class of bug started (secrets drifted out of .env, no one remembered how to regenerate them).

Acceptance

  • After hire-an-agent dev-qwen, .env contains the agent's token + password + backend URL/API key.
  • disinto up with a service referencing missing keys exits non-zero with a message listing the missing keys.
  • Rotation command/flow is documented in docs/agents-llama.md and discoverable from disinto --help.

Related: #845, #846.

## Problem `disinto hire-an-agent <name> <role>` creates a Forgejo user and API token successfully, but does not write the resulting credentials into `/home/johba/disinto/.env`. The compose service block is emitted referencing env vars like `FORGE_TOKEN_DEV_QWEN`, `FORGE_PASS_DEV_QWEN`, and `ANTHROPIC_BASE_URL` — none of which exist in `.env`. The container starts with empty credentials and either crash-loops or 401s against Forgejo silently. Generalization: the bug applies to **any** secret an emitted service block references, regardless of backend. Local-model agents need `FORGE_TOKEN_<USER>` + `FORGE_PASS_<USER>` + `ANTHROPIC_BASE_URL`; Anthropic-backend agents need `FORGE_TOKEN_<USER>` + `FORGE_PASS_<USER>` + `ANTHROPIC_API_KEY`. Today neither set is persisted by `hire-an-agent`. ## Repro 1. Run `disinto hire-an-agent dev-qwen dev --local-model http://10.10.10.1:8081 --model unsloth/Qwen3.5-35B-A3B` on a fresh `.env` with no `FORGE_TOKEN_DEV_QWEN`. 2. Confirm Forgejo user + token were created (visible in admin UI). 3. `grep DEV_QWEN /home/johba/disinto/.env` → empty. 4. `disinto up` → `disinto-agents-llama` starts with blank `FORGE_TOKEN`; git push and Forgejo API calls return 401. ## Naming rule (so the fix matches reality) Env-var keys are derived from `forge_user`: dashes → underscores, uppercased. So agent `dev-qwen` needs: - `FORGE_TOKEN_DEV_QWEN` - `FORGE_PASS_DEV_QWEN` - `ANTHROPIC_BASE_URL` (shared, when local model) OR `ANTHROPIC_API_KEY` (when Anthropic backend) ## Fix - `hire-an-agent` writes/merges the required vars into `.env` after creating the Forgejo user. - `disinto up` validates that every emitted service block has its required env vars present, and fails loudly with the exact missing keys. Do both: write on hire, validate on up. ## Rotation Define the rotation path explicitly: - Re-running `disinto hire-an-agent <same-name>` should rotate the API token + password idempotently and update `.env` in place, OR - Introduce `disinto agent rotate <name>` as a separate subcommand. Either works; pick one and document it. Today there is no defined rotation story, which is how this whole class of bug started (secrets drifted out of `.env`, no one remembered how to regenerate them). ## Acceptance - After `hire-an-agent dev-qwen`, `.env` contains the agent's token + password + backend URL/API key. - `disinto up` with a service referencing missing keys exits non-zero with a message listing the missing keys. - Rotation command/flow is documented in `docs/agents-llama.md` and discoverable from `disinto --help`. Related: #845, #846.
dev-bot added the
backlog
label 2026-04-16 10:03:53 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:10:55 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:10:55 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:10:56 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:10:57 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:12:02 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:12:02 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:12:04 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:12:04 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:13:07 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:13:07 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:13:08 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:13:09 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:14:13 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:14:13 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:14:15 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:14:15 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:18:33 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:18:33 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:18:34 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:18:34 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:19:38 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:19:38 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:19:40 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:19:40 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:20:44 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:20:45 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:20:46 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:20:46 +00:00
dev-qwen2 self-assigned this 2026-04-16 11:21:50 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-16 11:21:50 +00:00
dev-qwen2 removed their assignment 2026-04-16 11:21:51 +00:00
dev-qwen2 added
backlog
and removed
in-progress
labels 2026-04-16 11:21:52 +00:00
dev-qwen self-assigned this 2026-04-16 11:55:21 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-16 11:55:21 +00:00
dev-qwen removed their assignment 2026-04-16 12:40:39 +00:00
dev-qwen removed the
in-progress
label 2026-04-16 12:40:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#847
No description provided.