π οΈ Troubleshooting Common Agent Failures
This page consolidates all recurring issues across Early AI agents β including the GitHub PR Action, CLI PR, Commit CLI, and Repository CLI.
Each section below addresses a common failure type, its symptoms, root causes, and how to fix it.
Use this as your single reference for debugging any Early AI workflow.
β API Key Missing or Invalidβ
Symptomsβ
Error: Missing required environment variable: API_KEY- CLI exits immediately after initialization
- Logs show:
401 Unauthorizedwhen contacting Early backend
Causeβ
The agent cannot authenticate with the Early backend.
Fixβ
- Ensure
API_KEYis defined in your CI/CD environment (EARLY_API_KEYor equivalent). - Confirm it matches the key issued to your organization.
- In GitHub Actions:
env:
API_KEY: ${{ secrets.EARLY_API_KEY }} - Contact support@startearly.ai if your key is expired or unknown.
β GitHub or SCM Token Missing or Insufficientβ
Symptomsβ
fatal: Authentication failed for 'https://github.com/org/repo.git/'401 Unauthorized: Unable to access package or commitError: Permission denied while committing files
Causeβ
The token used for source control (GitHub, Bitbucket, etc.) lacks sufficient permissions.
Fixβ
- Set the
TOKENenvironment variable to a valid Personal Access Token (PAT) or App Password. - Review token scopes in Source Control Tokens β.
- For GitHub:
- Classic PAT β
repo,read:packages - Fine-grained PAT β
Contents: Read & Write,Pull Requests: Read & Write,Metadata: Read
- Classic PAT β
- For Bitbucket:
- App Password β Repositories: Read & Write
- For GitLab:
- Personal Access Token β
api,read_repository,write_repository
- Personal Access Token β
If you still see permission issues, verify the token is scoped to the correct repository.
β NPM Authentication Fails (Cannot Install CLI)β
Symptomsβ
npm ERR! 401 UnauthorizedUnable to authenticate, need: Bearer token
Causeβ
The CLI is installed from GitHub Packages, which requires a classic token with read:packages.
Fixβ
- Set up
.npmrccorrectly in your pipeline:echo "@earlyai:registry=https://npm.pkg.github.com" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ~/.npmrc - Ensure
NPM_TOKENis a classic PAT withread:packages. - Fine-grained tokens and
${{ secrets.GITHUB_TOKEN }}will not work.
β Out of Memory (Node.js Heap Limit)β
Symptomsβ
FATAL ERROR: Ineffective mark-compacts near heap limitAllocation failed - JavaScript heap out of memory
Causeβ
Node.js exceeded its memory limit during test generation β usually when MAX_CONCURRENCY=4.
Fixβ
Option 1 β Reduce concurrency:
export MAX_CONCURRENCY=3
Option 2 β Increase Node.js memory:
export NODE_OPTIONS="--max-old-space-size=5120"
Do not exceed 6000 MB on standard GitHub runners.
See Memory Tuning β for more guidance.
β Linting or Formatting Failsβ
Symptomsβ
- Commit step fails even though tests were generated successfully
- ESLint or Prettier errors appear in logs
pre-commit hook failed
Causeβ
Your repository enforces linting or formatting rules, and Early-generated tests donβt meet them.
Fixβ
Define these environment variables in your CI configuration:
export LINT_COMMAND="npx --no eslint $early_filename --fix"
export PRETTIER_COMMAND="npx --no prettier $early_filename --write"
These commands ensure generated test files are fixed and formatted before commit.
See Lint & Formatting.
β Test or Coverage Command Failsβ
Symptomsβ
jest: command not foundCoverage directory missingTest suite failed to run
Causeβ
Coverage or test commands in the project are misconfigured or missing dependencies.
Fixβ
- Verify Jest is installed:
npm install --save-dev jest - Ensure your project can run
npx jestsuccessfully. - If needed, override commands in your configuration:
export TEST_COMMAND="npm run test"
export COVERAGE_COMMAND="npm run coverage" - See Concurrency & Performance for runtime tuning.
β Nothing Generated / No Tests Createdβ
Symptomsβ
- CLI runs successfully but no test files appear
- Logs show β0 files processedβ
Causeβ
All target functions already have coverage above the current threshold (0% detection for now).
Fixβ
- Ensure the folder or commit includes untested code.
- For folder-based runs, target directories like
src/utilsorlib/legacy. - Upcoming versions will include adjustable thresholds.
β Git Push or Commit Rejectedβ
Symptomsβ
error: failed to push some refsrejected: fetch first
Causeβ
The branch changed while Early was generating tests, or Git identity was not configured.
Fixβ
- Ensure
GIT_USER_EMAILandGIT_USER_NAMEare set:export GIT_USER_EMAIL="ci@earlyai.com"
export GIT_USER_NAME="Early Bot" - In GitHub Actions, add:
- uses: actions/checkout@v4
with:
fetch-depth: 0 - Re-run the workflow once the branch is up to date.
β Repository or SCM Connection Issuesβ
Symptomsβ
fatal: not a git repositoryError: cannot find remote origin
Causeβ
The CI job lacks Git setup or correct SCM configuration.
Fixβ
- Verify
SCM_PROVIDERis defined (github,bitbucket, orgitlab). - Ensure your build agent includes Git.
- For Jenkins and CircleCI, use full checkouts instead of shallow clones.
- Review SCM Support β.
π¬ Still Stuck?β
If problems persist:
- Email support@startearly.ai with your logs and agent name.
- Mention your CI/CD system (e.g., Jenkins, GitHub Actions, CircleCI).
π Next: FAQ