Download docs/BUILDER.md from DetVape/Vape: direct link, hf CLI and curl.
- Browser
- Download file 3.73 kB
-
https://huggingface.co/spaces/DetVape/Vape/resolve/main/docs/BUILDER.md
- Command line
-
hf download hf://spaces/DetVape/Vape/docs/BUILDER.md
-
curl -L -o BUILDER.md https://huggingface.co/spaces/DetVape/Vape/resolve/main/docs/BUILDER.md
A newer version of the Gradio SDK is available: 6.32.0
Builder β Self-Improving Code Generation Agent
agents/builder.py
Builder is V.A.P.E.'s self-improvement engine. It generates production-ready Python β new tools, playbooks, and improvement proposals β grounded in Memory and gated by a two-tier security validator. Every successful output is appended back to Memory, so the system's capability compounds over time.
Lifecycle of a generation
task βββΆ search Memory (grounding) βββΆ build prompt βββΆ LLM (tier=deep)
βββΆ extract code βββΆ security validate βββΆ append skill to Memory βββΆ return
- Ground β
search_memory(task)pulls the most relevant prior lessons/skills. - Prompt β grounding + Memory stats are injected into the Builder system prompt.
- Generate β routed through the multi-provider
agents/llm.pylayer attier="deep". - Validate β two-tier security review (see below).
- Append β safe outputs are stored as
skillentries viaauto_append_to_memory.
Usage
from agents.builder import Builder
builder = Builder()
code, meta = builder.generate_code(
task="Create a keyless recon helper that checks Base contract verification status",
tier="deep",
)
if code:
builder.auto_append_to_memory(code, meta)
Propose an improvement to an existing module
code, meta = builder.propose_improvement(
module="agents/run.py",
issue="Add Memory grounding before the LLM call",
)
CLI
python agents/builder.py "Create a playbook for static analysis on new Solidity repos"
python agents/builder.py --improve "agents/run.py: add memory grounding"
python agents/builder.py --stats
Security validation (two tiers)
Builder never ships arbitrary dangerous code, but it also must not reject ordinary, legitimate Python. So validation is split:
BLOCK (hard reject β is_safe = False)
Arbitrary code execution, shell execution, and unsafe deserialization:
eval(, exec(, __import__, os.system(, os.popen(, subprocess.call/Popen/run(,
pickle.load/loads, marshal.load, yaml.load(, shell=True, plus destructive
filesystem ops (os.remove, shutil.rmtree) on delete/remove tasks.
WARN (advisory β recorded, non-blocking)
Common, legitimate patterns that merely deserve a reviewer's eye and slightly lower the
stored confidence: open(, requests., urllib.request, import os, sys.argv,
input(.
from agents.builder import validate_security
is_safe, notes = validate_security(code, task)
# is_safe == False β generation rejected
# is_safe == True β notes may still contain advisory 'review:' items
This design was a deliberate fix: an earlier version hard-rejected import os, open(,
requests.get, and json.loads, which would have rejected nearly every real file.
Grounding & interconnection
- Reads Memory before every generation (
_ground_in_memory). - Writes Memory after every safe generation (category
skill). - LLM layer β uses
agents/llm.py, so it inherits the free multi-provider fallback chain (Groq β Cerebras β OpenRouter β GitHub Models β Together). - Graceful degradation β if no provider key is set,
Builder.llm_readyisFalseand generation returns empty without crashing.
Audit trail
Every generation is recorded in-process:
builder.get_audit_trail() # list of {timestamp, task, code_len, provider, safe}
builder.get_stats() # {total_tasks, safe_tasks, total_code_chars}
Builder turns accumulated Memory into new capability β safely, and with a full audit trail behind every line it writes.