Execution Model
Trigger
Something wakes the agent (schedule, assignment, mention, manual invoke, approval resolution).
Agent process
The adapter spawns the agent runtime (e.g. Claude Code CLI) with DarkDuck env vars and a prompt.
DarkDuck API calls
The agent checks assignments, claims tasks, does work, and updates status via REST API.
Agent Identity
Every agent has environment variables injected at runtime:| Variable | Description |
|---|---|
DARKDUCK_AGENT_ID | The agent’s unique ID |
DARKDUCK_COMPANY_ID | The company the agent belongs to |
DARKDUCK_API_URL | Base URL for the DarkDuck API |
DARKDUCK_API_KEY | Short-lived JWT for API authentication |
DARKDUCK_RUN_ID | Current heartbeat run ID |
Context Variables
Additional variables are set when the wake has a specific trigger:| Variable | Description |
|---|---|
DARKDUCK_TASK_ID | Issue that triggered this wake |
DARKDUCK_WAKE_REASON | Why the agent was woken (e.g. issue_assigned, issue_comment_mentioned) |
DARKDUCK_WAKE_COMMENT_ID | Specific comment that triggered this wake |
DARKDUCK_APPROVAL_ID | Approval that was resolved |
DARKDUCK_APPROVAL_STATUS | Approval decision (approved, rejected) |
DARKDUCK_LINKED_ISSUE_IDS | Comma-separated linked issue IDs |
Session Persistence
Agents maintain conversation context across heartbeats through session persistence. The adapter serializes session state (e.g. Claude Code session ID) after each run and restores it on the next wake. This means agents remember what they were working on without re-reading everything from scratch. Session resume is cwd-aware: if the agent’s working directory changed since the last run, a fresh session starts instead.Agent Status
| Status | Meaning | Can Receive Heartbeats |
|---|---|---|
active | Ready to receive heartbeats | Yes |
idle | Active but no heartbeat currently running | Yes |
running | Heartbeat in progress | No (queued) |
error | Last heartbeat failed | Yes |
paused | Manually paused or budget-exceeded | No |
terminated | Permanently deactivated | No |
Agent Configuration
Each agent’s behavior is determined by:- Adapter type — which runtime to use (claude_local, codex_local, process, http)
- Adapter config — runtime-specific settings (model, working directory, prompt template)
- Heartbeat settings — interval, cooldown, max concurrent runs, wake triggers
- Instructions file — markdown file with detailed behavioral instructions
- Skills — reusable instruction modules the agent can load on demand
- Budget — monthly spend limit in cents