Skip to content

🧬 feat(agents): add bee.Evolver autonomous self-improvement agent#208

Merged
zaebee merged 5 commits into
mainfrom
feat/bee-evolver
Apr 17, 2026
Merged

🧬 feat(agents): add bee.Evolver autonomous self-improvement agent#208
zaebee merged 5 commits into
mainfrom
feat/bee-evolver

Conversation

@zaebee

@zaebee zaebee commented Apr 17, 2026

Copy link
Copy Markdown
Owner

What

Introduces bee.Evolver — an autonomous agent that runs on parasitic compute (GitHub Actions free tier + Google Colab) and improves the Hive by generating code patches, prompt updates, docs, and GitHub Issues/PRs.

Architecture

Follows the existing ATCG pattern, lives at agents/bee-evolver/:

Nucleotide File Responsibility
A src/hive/aggregator/ Reads git log, HIVE_STATE.md, open Issues/PRs, filesystem, keeper prompt
T src/hive/transformer/ LLM analysis → EvolutionPlan with typed Improvement items
G src/hive/generator/ Creates evolver/cycle-{timestamp} branch, applies patches via git apply, commits [skip ci] + pushes
C src/hive/connector/ Opens GitHub Issues + PR (label: evolver), sends Telegram pulse via Bot API

Triggers

  • Scheduled: every Monday 06:00 UTC (cron: '0 6 * * 1')
  • Manual: workflow_dispatch with optional focus input (e.g. "improve prompts", "fix heresies")

Telegram metabolic pulse

After each cycle, sends a message to AURA_BEE_KEEPER__ADMIN_CHAT_ID:

🧬 bee.Evolver Pulse — 20260417-060012

Improvements generated: 3
🔧 Fix raw os.getenv usage in aggregator (code)
🧠 Sharpen bee.Keeper diagnosis prompt (prompt)
📋 Implement NATS Bloodstream Visualization (issue)

Tokens consumed: 1842
PR: https://github.com/zaebee/aura/pull/...
Status: ✅ Cycle complete

Key design decisions

  • No NATS dependency — Telegram goes directly via https://api.telegram.org. The evolver runs in CI without cluster access.
  • [skip ci] on all commits — prevents the evolver's own push from triggering the main pipeline in a loop.
  • Patch safety — code patches run git apply --check first; failures are collected and reported in the Telegram pulse rather than aborting the cycle.
  • issue type as safe fallback — the LLM prompt instructs the model to prefer type: "issue" over a potentially broken code patch when uncertain.

Google Colab

tools/evolver_colab.ipynb — 7-cell notebook for manual heavy-inference runs on Colab T4 GPU. Not auto-triggered.

Secrets required

Add to GitHub repo secrets if not already present:

  • AURA_TELEGRAM_TOKEN
  • AURA_BEE_KEEPER__ADMIN_CHAT_ID (already used by bee.Keeper)

MISTRAL_API_KEY, OPENAI_API_KEY, GITHUB_TOKEN are already configured.

Introduces bee.Evolver — an agent that runs on parasitic compute
(GitHub Actions free tier + Google Colab) and autonomously improves
the Hive by generating code patches, prompt updates, docs, and
GitHub Issues/PRs.

Architecture follows the existing ATCG pattern:
- Aggregator: reads git log, HIVE_STATE.md, open Issues/PRs, filesystem
- Transformer: LLM analysis (Mistral primary, GPT-4o-mini fallback)
  produces an EvolutionPlan with typed Improvement items
- Generator: creates evolver/cycle-{timestamp} branch, applies patches
  via git apply, commits with [skip ci] and pushes
- Connector: opens GitHub Issues + PR (label: evolver), sends Telegram
  metabolic status pulse directly via Bot API (no NATS dependency)

Triggers: weekly cron (Mon 06:00 UTC) + workflow_dispatch with
optional focus hint input.

Also includes tools/evolver_colab.ipynb for manual heavy-inference
runs on Colab T4 GPU.

Co-authored-by: Ona <no-reply@ona.com>
@zaebee zaebee added enhancement New feature or request evolver labels Apr 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces bee.Evolver, an autonomous self-improvement agent for the Aura Hive. The agent follows the ATCG (Aggregator, Transformer, Connector, Generator) architecture to analyze the repository's state, propose mutations via an LLM, apply code or documentation patches, and communicate results through GitHub and Telegram. The review feedback focuses on enhancing the robustness and configurability of the agent. Key suggestions include implementing recursive filesystem scanning to provide better context to the LLM, avoiding global git configuration side effects in CI environments, and externalizing hardcoded parameters such as API pagination limits and truncation thresholds into the settings module.

Comment thread agents/bee-evolver/src/hive/aggregator/__init__.py Outdated
Comment thread agents/bee-evolver/src/hive/metabolism.py
Comment thread agents/bee-evolver/src/hive/aggregator/__init__.py Outdated
Comment thread agents/bee-evolver/src/hive/aggregator/__init__.py Outdated
- Filesystem scan: switch from top-level iterdir to recursive rglob
  with configurable exclude_dirs (default: .git, .venv, __pycache__,
  gen-proto, etc.) so the LLM receives full project context
- Git identity: drop --global flag, scope config to repo with
  check=True so failures surface immediately rather than silently
- GitHub Issues fetch: remove empty labels= param (was filtering for
  unlabelled issues only); externalize per_page and body truncation
  limit into EvolverSettings (EVOLVER_ISSUES_PER_PAGE,
  EVOLVER_ISSUE_BODY_LIMIT)

Co-authored-by: Ona <no-reply@ona.com>
@zaebee

zaebee commented Apr 17, 2026

Copy link
Copy Markdown
Owner Author

All four review comments addressed in e57fab3:

[high] Recursive filesystem scan (r3103113462)
Switched _scan_filesystem from iterdir (top-level only) to rglob("*"). Exclusions are now driven by settings.exclude_dirs (configurable via EVOLVER_EXCLUDE_DIRS; defaults to .git, .venv, __pycache__, gen-proto, gen, .mypy_cache, .ruff_cache).

[high] Local git config, no silent failures (r3103113478)
Removed --global flag — config is now scoped to the repository. Both calls use check=True so a failure raises CalledProcessError immediately. The error handler logs stderr and re-raises, surfacing the failure in CI logs rather than silently continuing.

[medium] GitHub Issues fetch params (r3103113487)
Removed the labels="" parameter (was inadvertently filtering for unlabelled issues only). per_page is now read from settings.issues_per_page (EVOLVER_ISSUES_PER_PAGE, default 20).

[medium] Issue body truncation limit (r3103113497)
Hardcoded 500 replaced with settings.issue_body_limit (EVOLVER_ISSUE_BODY_LIMIT, default 500). Also switched from .get("body") to direct i["body"] access as suggested — the GitHub API guarantees the key is present.

zaebee and others added 2 commits April 17, 2026 20:49
- generator/__init__.py: remove unused datetime/UTC imports (timestamp
  is passed in as a pre-formatted string from metabolism.py)
- tools/evolver_colab.ipynb: exclude from ruff in pyproject.toml;
  Colab notebooks have inherently cross-cell state that makes E402
  (imports after non-import statements) and I001 (import ordering)
  inapplicable; also remove unused json import and bare f-string

Co-authored-by: Ona <no-reply@ona.com>
- main.py: add noqa: E402 to imports after sys.path.insert block
- connector/__init__.py: remove unused UTC and datetime imports

Co-authored-by: Ona <no-reply@ona.com>
@zaebee

zaebee commented Apr 17, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces bee.Evolver, an autonomous self-improvement agent for the Aura Hive. The agent follows the ATCG (Aggregator, Transformer, Connector, Generator) architecture to analyze the repository's state, propose mutations via an LLM, apply code or documentation patches, and communicate results through GitHub and Telegram. The review feedback suggests several technical refinements: using git checkout -B for more robust branch management, switching to a more reliable Telegram message format (HTML or MarkdownV2) to prevent parsing failures, optimizing filesystem traversal by pruning excluded directories early, and implementing pagination for GitHub API requests to ensure full context is captured.

Comment thread agents/bee-evolver/src/hive/generator/__init__.py Outdated
Comment thread agents/bee-evolver/src/hive/connector/__init__.py Outdated
Comment thread agents/bee-evolver/src/hive/aggregator/__init__.py Outdated
Comment thread agents/bee-evolver/src/hive/aggregator/__init__.py Outdated
- generator: use checkout -B (force-reset) instead of -b so a
  previously interrupted cycle on the same timestamp doesn't fail
  with 'branch already exists'

- connector: switch Telegram parse_mode from Markdown V1 to HTML;
  add _h() escape helper for &, <, > so LLM-generated titles with
  underscores, asterisks, or backticks don't cause 400 parse errors

- aggregator: replace rglob+post-filter with os.walk and in-place
  dirs pruning so excluded directories (.git, .venv, node_modules)
  are never traversed, improving performance on large repos

- aggregator: paginate GitHub Issues fetch; collects pages until
  issues_per_page total items are gathered or the last page is
  reached, ensuring no issues are silently missed

Co-authored-by: Ona <no-reply@ona.com>
@zaebee
zaebee merged commit ea2770d into main Apr 17, 2026
15 checks passed
@zaebee
zaebee deleted the feat/bee-evolver branch April 17, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request evolver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant