BRTEX: How Dual-Graph Architecture Keeps LLM Pentest Agents From Chasing Their Own Tails
Hook
Most LLM penetration testing agents fail spectacularly at multi-step attack chains because they treat every wake-up as a blank slate. BRTEX solves this with a persistent todolist and a graph architecture that remembers not just what was found, but how it was discovered.
Context
Autonomous LLM agents sound perfect for penetration testing: they can probe attack surfaces, chain exploits, and explore laterally without human hand-holding. The reality is messier. When you give an LLM agent like AutoGPT or a custom LangChain workflow a pentesting task, it tends to re-scan the same ports, forget half-completed exploit chains, and duplicate work across parallel workers. The core problem is state management: stateless agents can't distinguish between "we tried this and failed" versus "we haven't explored this yet," and stateful agents that dump everything into a single shared context window hit token limits fast.
BRTEX is a Go-based fork of ARTEX v0.3.15 (the last open-source release before ARTEX went closed-source) that tackles these problems with a dual-graph architecture and worker trace exchange. It's explicitly a personal fork — '自用魔改版' translates to "personal modified version for own use" — but the architectural decisions it makes are legitimately novel for anyone building multi-agent offensive security tools. Instead of treating all knowledge as a flat list of facts, BRTEX maintains two separate graphs: an Asset Graph (global shared inventory of targets, credentials, and vulnerabilities) and an Exploration Graph (per-task reasoning chains showing what intents led to what discoveries). The system is event-driven: a planner goroutine watches the graphs, spawns intents into a frontier queue, and N worker goroutines execute tools (bash commands, HTTP requests through a MITM proxy) and write results back to PostgreSQL, which triggers the next planning cycle.
Technical Insight
The genius of the dual-graph design is separation of concerns at the data model level. The Asset Graph is global and deduplicated — if three different tasks discover the same SSH service on port 22, there's one canonical asset record. The Exploration Graph is per-task and preserves lineage — it knows that Intent #47 ("check for SQL injection in /login") spawned Fact #102 ("found error-based SQLi") which led to Intent #53 ("extract database credentials"). These graphs link through anchor points: every intent and fact points to a specific asset ID, so you can see coverage heatmaps ("which assets have we explored most?") and cross-task knowledge reuse ("this credential worked on three different hosts").
What makes this practical is the planner's persistent todolist. In a naive agent loop, the planner wakes up, generates a plan, spawns intents, and goes back to sleep. When it wakes again, it has to re-derive the entire plan from scratch by reading all facts. BRTEX's planner maintains a todolist that survives across wake-ups:
type Planner struct {
todolist []string // Persistent across planning cycles
db *sql.DB
frontier *IntentQueue
}
func (p *Planner) PlanningCycle() {
assets := p.db.GetAssetGraph()
facts := p.db.GetRecentFacts()
// LLM call: given assets, facts, and EXISTING todolist,
// update the todolist and spawn next intents
updatedTodo, newIntents := p.llm.Plan(assets, facts, p.todolist)
p.todolist = updatedTodo // Persist for next cycle
for _, intent := range newIntents {
p.frontier.Push(intent)
}
}
This solves the multi-step attack chain problem elegantly. When the agent discovers a SQL injection, the LLM can add "extract admin credentials" and "lateral move to internal network" to the todolist. The planner doesn't spawn all those intents immediately — it waits for prerequisite facts to appear. When credentials are extracted, the next planning cycle sees both the todolist item and the new credential fact, and only then spawns the lateral movement intent. This serializes dependencies without hardcoding them.
The worker trace exchange is the second killer feature. Workers don't just write facts to the database — they write full execution traces (the tool invocations, arguments, outputs, and timestamps for every step). Other workers can query these traces:
// Tool: search_all_worker_traces
// Search other workers' execution logs (excluding own intent)
func SearchAllWorkerTraces(query string, excludeIntentID int) []Trace {
// Keyword search across tool invocations and outputs
// Returns: [{workerID, intentID, tool, args, output, timestamp}]
}
// Tool: get_worker_trace
// Retrieve full execution history of a specific intent
func GetWorkerTrace(intentID int) []Step {
// Returns chronological list of all tool calls
}
Why does this matter? Imagine Worker A is fuzzing a web API and discovers that /api/v2/users returns a 403. It doesn't write a fact (403 isn't interesting), but the trace exists. Worker B is trying to enumerate endpoints and uses search_all_worker_traces("api v2") — it discovers Worker A's 403, deduces that /api/v2/ exists, and tries authenticated requests. This is collaboration at the process level, not just the fact level. Workers share partial observations that never crystallized into formal discoveries.
The MITM proxy integration wraps all HTTP tool invocations and logs full request/response pairs to PostgreSQL with intent linkage. This isn't just forensic — it lets the planner reason about HTTP-level patterns:
type HTTPLog struct {
IntentID int
Method string
URL string
ReqHeaders map[string]string
ReqBody []byte
RespStatus int
RespBody []byte
Timestamp time.Time
}
// Planner can query: "show me all 403s on /admin paths"
// and spawn intents to bypass auth on those specific endpoints
The event-driven engine uses PostgreSQL LISTEN/NOTIFY to debounce planning cycles. When a worker writes a fact, it sends a NOTIFY. The planner goroutine batches notifications with a 2-second debounce window, then runs a planning cycle. This prevents the planner from thrashing on every single fact write, but stays responsive when workers are actively discovering things.
One detail that reveals real-world usage: the codebase includes LLM config sanitization that strips zero-width characters and byte-order marks from pasted API keys and URLs. This tiny validation catches the invisible Unicode garbage that breaks URL parsing when you copy from Notion, Slack, or Discord. It's the kind of unglamorous polish that only shows up after production pain.
Gotcha
BRTEX has architectural merit but minimal ecosystem support. There are 3 GitHub stars, no prebuilt binaries in releases, and the entire README is in Chinese. The one-click web update mechanism (which downloads releases, verifies SHA256SUMS, smoke-tests, stages as artex.new, and auto-rollbacks on failure) is clever, but it depends on GitHub releases with SHA256SUMS files that don't exist yet. Right now, you're doing manual git pull && go build workflows.
The vendored 'norma' SDK (agentcore, tool, permission, harness, memory, transcript) is completely undocumented. There's no public API contract, no versioning, and no explanation of how the agent primitives actually work. If you want to add custom tools or modify planning behavior, you're reverse-engineering the vendor directory. Worker trace search is keyword-based with no semantic indexing — in large tasks with hundreds of intents, search_all_worker_traces returns noisy results and will scale poorly compared to embedding-based retrieval. The system has hardcoded 3-worker concurrency per task with no auto-scaling based on workload or LLM rate limits. High-parallelism tasks bottleneck on worker count; low-activity tasks waste goroutine slots. There's also no structured export of exploration graph lineage — you can't generate visual attack path diagrams or machine-readable provenance reports for compliance documentation.
Verdict
Use if: You're researching multi-agent coordination for offensive security, need a self-hostable LLM pentesting lab to study autonomous attack chain planning, or want to fork an agent architecture that solves real problems (asset deduplication, exploration provenance, worker knowledge exchange) instead of being yet another ReAct wrapper. The dual-graph design and persistent todolist are legitimately novel and worth studying even if you never deploy BRTEX in production. Skip if: You need production-ready tooling with binary releases and support, don't read Mandarin Chinese (docs and config are Chinese-first), want a stable upstream project (ARTEX is closed-source now and BRTEX is a personal fork), or expect plug-and-play deployment — this is research-grade software that requires Go expertise and PostgreSQL operations to maintain.