Knowledge Base updated: 2026-11-16
Knowledge Base Index
1. Orientation
This repository contains PentestGPT implementations and agent infrastructure: a redesigned pentestgpt_agent package, a reusable unified_agent abstraction, and the legacy PentestGPT CLI/LLM stack. The highest-level runtime flow is an agent-driven penetration-testing loop: tasks/plans are created, an agent/backend executes actions, memory/trace state records progress, and reports or events expose results.
Main parts:
unified_agent/— backend-neutral agent, task, event, tool-server, and skill-loading framework.pentestgpt_agent/— redesigned PentestGPT domain model and execution/trial loop packaged as a standalone Python project.pentestgpt_legacy/— legacy interactive CLI, prompt/reporting helpers, and LLM provider abstraction.tests/andpentestgpt_agent/tests/— repository-level and package-local pytest coverage.- Root Docker, Makefile, setup, and script files — development/container runtime and operational helpers.
Critical state is mostly local and in-process rather than persisted in a database:
- Agent/task/memory/trace objects live in Python runtime objects under
unified_agent/andpentestgpt_agent/src/pentestgpt_agent/. - Skill pinning/configuration lives in skills-lock.json.
- Runtime configuration comes from environment variables, .env.example, root/package pyproject.toml, Docker Compose, and helper scripts.
- There is no repository-defined database, queue, object store, cache, or vector store schema.
2. Architecture diagrams
flowchart TD
subgraph Unified[unified_agent]
UA[agent.py]
UT[task/events/types]
UB[backends]
UTools[tools/tool_server]
USkills[skills.py]
end
subgraph NewPG[pentestgpt_agent]
Domain[domain model]
Exec[execution/loop/trial]
Pkg[package tests/docs]
end
subgraph Legacy[pentestgpt_legacy]
CLI[main/config]
Orch[pentest_gpt/task_handler]
Prompt[prompts/reporting]
LLM[llm providers]
end
subgraph Dev[repo runtime]
Docker[Dockerfile/compose]
Scripts[scripts/setup]
Tests[tests]
end
UA --> UT
UA --> UB
UA --> UTools
UA --> USkills
Exec --> Domain
CLI --> Orch
Orch --> Prompt
Orch --> LLM
Tests --> Unified
Tests --> Legacy
Pkg --> NewPG
Docker --> Unified
Docker --> Legacy
flowchart LR
Plan[plan/task input] --> Loop[trial or loop]
Loop --> Exec[execution step]
Exec --> Memory[memory]
Exec --> Trace[trace/audit]
Exec --> Result[result or next action]
Result --> Loop
sequenceDiagram
participant CLI as legacy main.py
participant Orchestrator as pentest_gpt/task_handler
participant Prompts as prompts + prompt_select
participant Client as llm client/factory
participant Provider as provider implementation
CLI->>Orchestrator: start interactive pentest
Orchestrator->>Prompts: select/build prompt
Orchestrator->>Client: request model response
Client->>Provider: dispatch provider call
Provider-->>Client: response text
Client-->>Orchestrator: normalized response
Orchestrator->>CLI: next action/report content
flowchart TD
Task[Unified task] --> Agent[unified_agent.agent]
Agent --> Backend[Claude Code or Codex backend]
Agent --> ToolServer[tool_server]
Agent --> Skills[skills registry/lock]
Backend --> Events[events]
ToolServer --> ToolResults[tool results]
Events --> TaskState[task lifecycle state]
3. Glossary
- PentestGPT — the repository’s penetration-testing assistant/application, represented by both legacy and redesigned implementations.
unified_agent— backend-neutral agent framework that coordinates tasks, tools, skills, events, and concrete coding-agent backends.pentestgpt_agent— the redesigned standalone PentestGPT package with domain objects and execution/trial loops.- skills-lock.json — repository-level skill lock/configuration file consumed by the unified agent skill system.
4. Codebase-wide invariants
- Python implementation code is split between three top-level packages: unified_agent/…/*.py, pentestgpt_agent/…/*.py, and pentestgpt_legacy/…/*.py; tests mirror these areas in tests/…/*.py and pentestgpt_agent/…/*.py.
- There are two packaging scopes: the repository root has pyproject.toml/uv.lock, while the redesigned package also has pentestgpt_agent/pyproject.toml/pentestgpt_agent/uv.lock.
- Containerized development is defined at the repository root with
Dockerfile, docker-compose.yml,.dockerignore, and helper scripts underscripts/**. - Legacy LLM provider implementations are isolated under pentestgpt_legacy/…/*.py, with surrounding registry/factory/client files under pentestgpt_legacy/…/*.py.
5. Routing table
-
any change to unified task lifecycle, event emission, or shared agent types -> docs/unified-agent-core.md
-
any change to Claude Code or Codex backend behavior -> docs/unified-agent-backends.md
-
any change to unified tool definitions or tool-server runtime behavior -> docs/unified-agent-tools.md
-
any change to skill discovery, selection, or lock semantics -> docs/unified-agent-skills.md
-
pentestgpt_agent/…/__init__.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/agents.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/identifiers.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/plan.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/memory.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/trace.py -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/audit.py -> docs/pentestgpt-agent-domain.md
-
any change to redesigned PentestGPT domain identifiers, memory, planning, traces, or audit records -> docs/pentestgpt-agent-domain.md
-
pentestgpt_agent/…/execution.py -> docs/pentestgpt-agent-execution-flow.md
-
pentestgpt_agent/…/loop.py -> docs/pentestgpt-agent-execution-flow.md
-
pentestgpt_agent/…/trial.py -> docs/pentestgpt-agent-execution-flow.md
-
any change to redesigned execution, trial orchestration, or agent loop flow -> docs/pentestgpt-agent-execution-flow.md
-
pentestgpt_agent/pyproject.toml -> docs/pentestgpt-agent-package-and-tests.md
-
pentestgpt_agent/README.md -> docs/pentestgpt-agent-package-and-tests.md
-
pentestgpt_agent/CONTEXT.md -> docs/pentestgpt-agent-package-and-tests.md
-
pentestgpt_agent/HTB_ENIGMA_QUALIFICATION_20260712.md -> docs/pentestgpt-agent-package-and-tests.md
-
pentestgpt_agent/uv.lock -> docs/pentestgpt-agent-package-and-tests.md
-
pentestgpt_agent/…/*.py -> docs/pentestgpt-agent-package-and-tests.md
-
any change to package-local benchmarks, live tests, or package metadata for
pentestgpt_agent-> docs/pentestgpt-agent-package-and-tests.md -
pentestgpt_legacy/__init__.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/_version.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/config.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/main.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/smoke_test.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/test_connection.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/…/__init__.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/…/pentest_gpt.py -> docs/legacy-cli-and-orchestration.md
-
pentestgpt_legacy/…/task_handler.py -> docs/legacy-cli-and-orchestration.md
-
any change to the legacy interactive CLI or pentest task orchestration -> docs/legacy-cli-and-orchestration.md
-
any change to legacy LLM provider configuration, factory, registry, client, or provider implementations -> docs/legacy-llm-layer.md
-
pentestgpt_legacy/…/*.py -> docs/legacy-prompts-and-reporting.md
-
pentestgpt_legacy/…/prompt_select.py -> docs/legacy-prompts-and-reporting.md
-
pentestgpt_legacy/…/report_generator.py -> docs/legacy-prompts-and-reporting.md
-
any change to legacy prompt templates, prompt selection, or report generation -> docs/legacy-prompts-and-reporting.md
-
any change to repository-level pytest fixtures, unified-agent tests, legacy tests, unit tests, or Docker tests -> docs/repository-test-suite.md
-
Dockerfile-> docs/development-and-container-runtime.md -
docker-compose.yml -> docs/development-and-container-runtime.md
-
Makefile-> docs/development-and-container-runtime.md -
fix-workspace-permissions.sh -> docs/development-and-container-runtime.md
-
.dockerignore-> docs/development-and-container-runtime.md -
.github/**-> docs/development-and-container-runtime.md -
scripts/**-> docs/development-and-container-runtime.md -
docs/architecture.md -> docs/development-and-container-runtime.md
-
docs/docker-dev-plan.md -> docs/development-and-container-runtime.md
-
docs/redesign/**-> docs/development-and-container-runtime.md -
PENTESTGPT_AGENT_NEW_MIGRATION_REPORT.md -> docs/development-and-container-runtime.md
-
PENTESTGPT_AGENT_NEW_PRODUCTION_HARDENING_REPORT.md -> docs/development-and-container-runtime.md
-
any change to repository packaging, dependency locks, Docker runtime, setup scripts, or developer-facing architecture docs -> docs/development-and-container-runtime.md