samugit83/redamon
Self-hosted pentest platform: recon into a Neo4j graph, a LangGraph agent driving Kali tools over MCP with approval gates, and auto-fix PRs.
Overview
RedAmon is a self-hosted penetration-testing platform made of many Docker services. A recon pipeline maps a target’s attack surface into a Neo4j graph. A LangGraph agent then reasons over that graph and runs security tools inside a Kali container. A separate remediation agent, CypherFix, triages the findings, edits the target’s code and opens a GitHub pull request. A Next.js web app ties it together with project settings, chat, approval prompts and reports.
The agent (agentic/) is the core of this review. It is a single ReAct-style graph with phases (informational, exploitation, post_exploitation). It can fan out into parallel “fireteam” sub-agents, and it can optionally hand exploitation to a UCT-guided tree search (LATS). Tools come from five MCP servers in the Kali container plus in-process tools for graph queries, web search and OSINT APIs. Safety is layered: a hard-coded blocklist of public-sector domains, an LLM target check, rules-of-engagement gates, and operator confirmation before every target-touching tool call by default.
Architecture
flowchart LR
UI["Next.js webapp"] --> API["Agent API / WebSocket"]
API --> ORCH["AgentOrchestrator (LangGraph)"]
ORCH --> INIT["initialize: scope gate"]
INIT --> THINK["think: LLM decision"]
THINK --> GATE["Approval / tool confirmation pause"]
THINK --> EXEC["execute_tool / execute_plan"]
THINK --> FT["Fireteam sub-agents"]
EXEC --> ROE["RoE + recon budget gate"]
ROE --> EXE["PhaseAwareToolExecutor"]
EXE --> KALI["Kali MCP servers (nmap, nuclei, msf, ...)"]
EXE --> NEO["Neo4j graph tools"]
RECON["Recon pipeline"] --> NEO
ORCH --> PG["Postgres checkpointer"]
ORCH --> EVO["EvoGraph chain writes to Neo4j"]
NEO --> FIX["CypherFix triage + CodeFix PR"]
| Component | Path | Role |
|---|---|---|
| Orchestrator | agentic/orchestrator.py |
Builds the LangGraph, routing functions, checkpointer, resume methods |
| Graph nodes | agentic/orchestrator_helpers/nodes/ |
initialize, think, execute_tool, execute_plan, approval and fireteam nodes |
| Guardrails | agentic/orchestrator_helpers/hard_guardrail.py, guardrail.py, roe_gate.py |
Domain blocklist, LLM target check, RoE and recon-budget refusals |
| Settings | agentic/project_settings.py |
Defaults, DANGEROUS_TOOLS, approval flags, LATS and fireteam settings |
| Tool layer | agentic/tools.py, agentic/mcp_registry.py |
MCP client, system and user MCP servers, phase-aware executor, deadlines |
| Kali sandbox | mcp/servers/, mcp/kali-sandbox/ |
MCP servers for recon, nmap, Metasploit, nuclei, Playwright, terminal |
| State | agentic/state.py |
AgentState, LLM decision and finding models, chain memory |
| Recon | recon/, recon_orchestrator/ |
Multi-phase scan pipeline that writes to Neo4j, with its own hard guardrail |
| Remediation | agentic/cypherfix_triage/, agentic/cypherfix_codefix/ |
Finding triage and a ReAct code-fix agent that opens PRs |
| Web app | webapp/ |
Next.js 16 / Prisma UI and project configuration |
How a request flows
Take a chat message such as “test the login form on the in-scope host”:
- Initialize and scope gate. The graph starts at
initialize._scope_gateruns the scope checks at session start and again whenever the project’s scope signature changes. Missing project settings or unverifiable scope groups refuse the turn (initialize_node.py). - Think.
think_nodebuilds the prompt from the active skill workflow, tool registry, phase, chain memory and todo list. The LLM returns a structured decision:use_tool,plan_tools,deploy_fireteam,transition_phase,switch_skill,ask_userorcomplete. - Confirmation gate. If
REQUIRE_TOOL_CONFIRMATIONis on (the default) and the chosen tool, or any step of a plan, is inDANGEROUS_TOOLS, the node setsawaiting_tool_confirmationinstead of running anything (think_node.py). Moving into exploitation or post-exploitation also asks for approval by default. - Route.
_route_after_thinkstops atmax_iterations(100 by default) ortask_complete, pauses toENDfor approvals and questions, or sends the decision toexecute_tool,execute_planordeploy_fireteam(orchestrator.py). A paused run resumes from the checkpoint when the operator answers. - Execute. Each executor path first calls
roe_gate.check_tool_call. A refusal becomes the tool’s output, so the model sees why (execute_tool_node.py).PhaseAwareToolExecutorthen checks that the tool is allowed in the current phase and calls the MCP server or in-process tool. - Analyse. Control goes back to
think, which analyses the raw output in the same LLM call that picks the next step. It extractschain_findingsand writes steps, findings and failures to the EvoGraph in Neo4j. - Respond.
generate_responsewrites a conversational answer, a summary or a full report.
Key components
Agent loop
The graph has 14 nodes and is compiled with a checkpointer (orchestrator.py). Tool results go straight back to think, so there is no separate analysis node. Fireteams are parallel member subgraphs that reuse the same execute nodes. Up to 5 members run at once, and fireteams require the persistent checkpointer. A member’s dangerous call escalates to the parent’s confirmation pause. LATS is off by default. When enabled for the exploitation phase, it grows a tree of candidate probes, scores them, and overrides the LLM’s next action with the selected wave. A recon budget refuses discovery tools after 15 informational iterations, to push the agent from scanning to testing (roe_gate.py).
Scope and safety controls
- Hard guardrail. A regex and exact-match list blocks government, military, education and intergovernmental domains. It cannot be switched off (hard_guardrail.py). In the agent, though, it runs only in domain mode. IP-mode projects skip it (initialize_node.py).
- LLM guardrail. A separate LLM call classifies the configured targets. It fails closed on errors, but its prompt says “When in doubt, ALLOW”, private IPs and public IPs without PTR records are auto-allowed, and
AGENT_GUARDRAIL_ENABLEDcan turn it off (guardrail.py). It is a filter against obviously wrong targets, not proof of authorization. - Rules of engagement. When RoE is enabled, forbidden tools and categories, an account-lockout switch and a maximum phase are enforced before every tool call (roe_gate.py). Engagement dates and time windows only add warnings to the prompt. They do not block.
- Human in the loop.
DANGEROUS_TOOLSlists the active scanners, HTTP clients, the browser, the brute-forcer, the Kali shell, code execution and Metasploit (project_settings.py). Confirmation and phase-approval flags default to on, but all are project settings. - What is missing. No per-call check that a tool’s arguments stay inside the scope. The guardrails judge the project’s configured targets, and the shell tools can reach any host once a call is approved. The Kali container has
NET_ADMINandNET_RAWand runs withseccomp:unconfined(docker-compose.yml). It isolates tools from the host, not targets from each other. Its MCP servers accept requests without a token whenMCP_AUTH_TOKENis unset.
Tool integration
Five system MCP servers in kali-sandbox (network recon, nmap, Metasploit, nuclei, Playwright) are reached over SSE with bearer auth and per-server timeouts (tools.py). Tool arguments are raw command strings, and output goes back to the LLM verbatim, with large outputs offloaded to a per-project workspace. In-process tools cover Neo4j queries, web search (Tavily or a local FAISS knowledge base), Shodan, Google dorks and a tradecraft lookup. Users can register their own MCP servers over SSE, streamable HTTP or stdio. Supply-chain analysis of untrusted packages is dispatched to a separate analyzer container, because the Kali worker must never hold the Docker socket.
Findings
Findings are LLM extractions. Each ChainFindingExtract has a type, severity, title, evidence text, CVEs, IPs, the recon finding ids it confirms, and a confidence score (state.py). No code re-runs a proof. Helper checks catch a model that claims it recorded a finding but did not, and score claimed productivity against actual state growth. Recon-side findings are more mechanical. Scanners write typed nodes into the graph, and several modules use confidence tiers and control probes.
State and memory
AgentState holds messages, the execution trace, todo list, chain memories and LATS state. With PERSISTENT_CHECKPOINTER on (the default in project settings) it is saved by LangGraph’s AsyncPostgresSaver. Without DATABASE_URL, or if setup fails, it falls back to in-memory MemorySaver (orchestrator.py). The EvoGraph writes AttackChain, step, finding, failure and decision nodes to Neo4j on a background thread, and a new session loads prior chains for the same project.
Models
The model id prefix selects the provider: openrouter/, bedrock/, deepseek/, gemini/, glm/, kimi/, qwen/, xai/, mistral/, custom/ (OpenAI-compatible, Bedrock or Ollama), claude-* for Anthropic, and OpenAI for anything else (llm_setup.py). The default is claude-opus-4-6 with Anthropic prompt caching. One model drives the agent. A few side features can use their own model. Token use is counted, but there is no spend cap, only iteration, deadline and LATS size limits.
Extending it
- MCP servers. Add a user MCP server in settings. Its tools merge into the registry next to the Kali tools.
- Skills. Built-in and user attack skills select a workflow prompt.
switch_skilllets the agent change skill mid-session. - Plugins. A plugin runner and gateway let you add capabilities without forking.
- Prompts and phases. Per-phase system prompts and the tool-to-phase map are project settings.
Running it
- Install.
./redamon.sh installbuilds and starts the stack. Without OpenVAS it runs nine containers: webapp, Postgres, Neo4j, agent, kali-sandbox, recon orchestrator, Docker broker and two plugin services. The README asks for roughly 70 GB of disk for the images alone. - Configure. Create an admin account, add LLM provider keys in the web app, create a project with its target scope, and set RoE, confirmation and phase-approval options.
- Use. Run recon, then chat with the agent. Approvals appear in the UI. CypherFix needs a GitHub token to open pull requests.
Strengths and caveats
- Strength: complete platform. Recon, graph, agent, reporting and remediation in one stack, with a real attack-surface graph the agent can query.
- Strength: human gates by default. Tool confirmation and phase approvals are on out of the box, and the RoE gate is enforced on every executor path, fireteams included.
- Strength: model choice. Many providers, local models through
custom/, and prompt caching. - Caveat: scope is checked per project, not per command. The LLM guardrail is lenient by design, the hard guardrail skips IP mode, and nothing ties an approved shell command to the scope list.
- Caveat: findings are self-judged. Confirmation is the model’s reading of tool output. There is no automated re-run of proof.
- Caveat: heavy operations. A dozen or more containers, large images, and a privileged Kali worker with
seccomp:unconfinedall need a dedicated host. - Caveat: no cost ceiling. Long sessions are bounded by iterations and deadlines, not by spend.
Sources: code at b13da9c, verified Q&A.
How it answers the Open-source AI pentest and offensive-security agents questions
Each answer was drafted by a code-reading agent at commit b13da9c. Its citations were checked mechanically. Compare with the other open-source ai pentest and offensive-security agents →
How is the agent loop and planning implemented?
answeredSingle-agent ReAct with multi-agent Fireteam extensions. The main loop is a single LangGraph StateGraph compiled in AgentOrchestrator._build_graph() (orchestrator.py:606). It is a single agent — not a role-based crew — but it can optionally deploy "fireteams": parallel child agents (build_fireteam_member_graph(), fireteam_member_graph.py:78), each an independent ReAct subgraph, for concurrent tool waves.
Planning. The agent uses an LLM-managed todo list (TodoItem model, state.py:142) and attack-path-type routing (attack_path_type in AgentState). On each new message, the initialize_node (initialize_node.py:295) classifies the attack path via classify_attack_path(), sets the phase and creates a ConversationObjective. The think node (think_node.py) assembles a system prompt from the active skill workflow, tool registry, phase definitions, chain memory, and todo list; the LLM produces a structured LLMDecision with action (use_tool, plan_tools, deploy_fireteam, transition_phase, switch_skill, ask_user, complete). Planning is entirely LLM-driven — there is no hardcoded planner decomposition beyond the phase model.
Turn structure. The graph has 14 nodes (orchestrator.py:681-813). Routing: START → initialize → think → (execute_tool | execute_plan | deploy_fireteam | await_approval | await_question | await_tool_confirmation | generate_response). After execute_tool/execute_plan, control returns to think (analyze output → plan next step). Pause nodes (await_approval, await_question, await_tool_confirmation) exit to END; resumption methods (resume_after_approval_with_streaming, etc.) feed the user's response back into the graph via astream().
Stop conditions. The loop terminates when current_iteration >= max_iterations (default 100, _route_after_think:849), task_complete is set, the LLM emits action=complete, a guardrail blocks the target, or recursion_limit (MAX_ITERATIONS × 5) is hit.
LATS search. For exploitation phases, an optional Language Agent Tree Search (lats.py) replaces the linear ReAct loop with UCT-guided tree search. lats_hook() (lats.py:1985) runs inside think_node: it evaluates prior probes, backpropagates scores, selects the next node to expand, generates candidate probes via lats_expand(), and overrides the LLM decision with the next wave. LATS supports shadow mode (observe-only) and drive mode (probes issued by the tree).
How are security tools integrated and executed?
answeredFive system MCP servers in a Kali sandbox. Tools are executed through PhaseAwareToolExecutor (tools.py:2220), which dispatches to either MCP servers or in-process tools. Five system MCP servers run inside the kali-sandbox container (tools.py:266-332): network_recon (curl, naabu, hydra, command exec), nmap (network mapper), metasploit (exploitation framework including msf_console), nuclei (template-based vulnerability scanner), and playwright (browser automation). Each connects via SSE with per-tool deadlines defined in TOOL_DEADLINES_S (tools.py:2125-2161), e.g. nmap 600s, nuclei 1800s, metasploit_console 2400s.
In-process tools live outside the Kali container: query_graph/graph_schema/graph_summary (Neo4j reads, neo4j_read_pool.py), web_search (Tavily API with optional Knowledge Base fallback), shodan (OSINT API), google_dork (SerpAPI), tradecraft_lookup (LLM-augmented security reference retrieval), and capture-proxy tools (traffic_tools.py) for reading captured HTTP traffic. Supply-chain tools split between Kali (execute_osv_scanner — passive, offline) and agent-native (execute_guarddog, supply_chain_tools.py — dispatches to a hardened analyzer container via the webapp).
User-defined MCP servers can be added through settings (mcp_registry.py), supporting sse, streamable_http, and stdio transports, with bearer auth. They're merged with system servers via reload_mcp_manifests() (orchestrator.py:493).
Command building and output parsing. Tools receive raw CLI arguments as a string (args key on tool_args), passed directly to the MCP server's execute_* handler. Output is not deterministically parsed — it's returned verbatim to the LLM, which produces a structured OutputAnalysis (output_analysis) with chain_findings, verdict, and productivity fields. A classify_error_class() helper (error_class.py) distinguishes tool/transport failures from application-level responses. Long-running tools (metasploit_console with run/exploit, hydra) support streaming progress callbacks (nodes/execute_plan_node.py:113-125).
Tool gating per-phase is enforced by TOOL_PHASE_MAP (project_settings.py), and the PhaseAwareToolExecutor.execute() checks is_tool_allowed_in_phase() before dispatching. Dangerous tools require an operator confirmation pause before execution.
How are scope, authorization and dangerous actions controlled?
answeredThree-layer defense: hard guardrail → soft guardrail → tool confirmation.
1. Hard guardrail (hard_guardrail.py): deterministic, non-disableable. Blocks government/military domains by TLD pattern (.gov, .mil, .edu, .int, and 28 country-variant patterns) and 340+ exact-blocked international-organization domains (UN, WHO, World Bank, Red Cross, etc.). Runs at session start in initialize_node (initialize_node.py:178-186) and on every scope change (_scope_gate() checks _scope_signature). Cannot be bypassed — no LLM involved, no settings toggle.
2. Soft LLM guardrail (guardrail.py): a separate LLM call (using GPT system prompt) that classifies targets as "allowed" or "blocked" with categories like major tech companies, cloud providers, social media, financial institutions, healthcare, critical infrastructure, etc. The fail-closed policy means an LLM error blocks the run (initialize_node.py:129-136). The prompt instructs: "When in doubt, ALLOW" — lenient by design. For IP-mode targets, it reverse-DNS-resolves public IPs to hostnames and checks those. The guardrail re-runs mid-session if _scope_signature changes (initialize_node.py:221).
3. Operator confirmation for dangerous actions. Tools in DANGEROUS_TOOLS (project_settings.py:42-55 — nmap, nuclei, curl, metasploit_console, kali_shell, execute_code, hydra, ffuf, playwright, etc.) require manual operator approval. The think node sets awaiting_tool_confirmation=True, the graph pauses at await_tool_confirmation (orchestrator.py:856), and the operator approves/modifies/rejects via process_tool_confirmation_node(). Phase transitions also require approval (configurable via REQUIRE_APPROVAL_FOR_EXPLOITATION), handled by await_approval_node/process_approval_node (approval_nodes.py).
4. RoE (Rules of Engagement) timing checks run every turn in initialize_node (initialize_node.py:234-292): engagement start/end dates, allowed days-of-week, time windows (with timezone support). Breaches surface as _roe_warnings in state.
5. Sandboxing and network isolation. All pentest MCP servers run inside the kali-sandbox container (not the agent container), so tool execution is network-separated. The capture proxy routes target-facing traffic; API-key tools (Shodan, Tavily, SerpAPI) explicitly bypass the proxy (tools.py:119-120). Supply-chain's execute_guarddog dispatches through a hardened, network-isolated analyzer container (supply_chain_tools.py). PhaseAwareToolExecutor enforces per-phase tool gating. TOOL_MUTEX_GROUPS prevents parallel access to singleton resources like Metasploit. _CURL_LONG_WITH_ARG (tools.py:155-168) validates curl argument structure to block injection attempts. The tool_deadline_seconds() mechanism (tools.py:2168) abandons hung tool calls rather than hanging the session.
How are findings validated and reported?
answeredFindings are LLM-extracted structured objects, not deterministic matches. When a tool returns output, the think node's LLM call produces an OutputAnalysis containing chain_findings — each a ChainFindingExtract model (state.py:382-408) with finding_type (e.g. vulnerability_confirmed, service_identified, exploit_success, privilege_escalation), severity, title, evidence, related_cves, related_ips, and confidence. There is no code-side confirmation: the model judges its own output. A finding_guard.py module catches unrecorded confirmations (the LLM wrote "Record X as confirmed" under actionable_findings instead of producing a chain_findings entry) and surfaces them as a prompt reminder next turn.
False positives are handled by productivity scoring. The compute_productivity_score() function (productivity.py) evaluates the LLM's self-reported productivity.verdict against observed state growth (detect_state_growth, detect_chain_advance). Discrepancies are surfaced as _last_productivity_discrepancy in the next prompt. The system can downgrade a "productive" claim if _iterations_since_state_grew exceeds a threshold, stalling detection. A uniform_response_anomaly detector flags repetitive near-identical tool outputs. The finding_guard.py module (unrecorded_confirmations()) explicitly warns the model when it described recording a finding but didn't actually produce a chain_findings entry.
Duplicate handling happens at the LATS level (lats.py:1336-1348): a _probe_dedup_key() function creates a stable key from (tool_name, normalized args), and _parse_expand_response() enforces HARD dedup — a byte-identical probe is dropped pre-expansion. A cross-tree _lats_probe_ledger keeps the dedup across resets. At the finding level, duplicates are left to the LLM: duplicate is a verdict value in OutputAnalysis.verdict.
Reporting format. The generate_response_node (generate_response_node.py) adaptively selects one of three response tiers via determine_response_tier(): conversational (direct answer), summary (brief recap), or full_report (comprehensive report with findings, tool outputs, recommendations). The FINAL_REPORT_PROMPT includes the execution trace, target info, todo list, and completion reason. All chain activity is also persisted to Neo4j via chain_graph_writer.py: AttackChain nodes, ChainStep edges, ChainFinding/ChainFailure/ChainDecision nodes are created as fire-and-forget writes on a dedicated thread pool.
Evidence re-run. There is no deterministic PoC re-execution for proof. LATS re-evaluates confirmed paths by re-traversing the tree, and the LLM can request tool re-runs, but confirmation is always a model-level judgment of the same output.
How is engagement state and knowledge kept across a long run?
answeredAgentState in LangGraph is the primary memory store (state.py:978): a TypedDict holding messages, execution trace, todo list, objectives, target info, chain findings memory, chain failures memory, chain decisions memory, chain waves memory, LATS tree state, QA history, phase history, fireteam plans, and token accounting. All this lives inside LangGraph's MemorySaver checkpointer by default (in-memory), replaced with AsyncPostgresSaver (orchestrator.py:160-196) when PERSISTENT_CHECKPOINTER=true, persisting the full state to Postgres via psycopg_pool. The thread_id is user_id:project_id:session_id (config.py:55), enabling session resume.
Neo4j graph persistence. The chain_graph_writer.py module writes the attack chain to Neo4j as fire-and-forget operations on a dedicated writer thread: AttackChain nodes (per session), ChainStep nodes (one per iteration), ChainFinding/ChainFailure/ChainDecision nodes, all linked by NEXT_STEP/HAS_PARENT relationships. This provides a durable, queryable attack graph separate from the agent's in-memory state. The fire_create_attack_chain() and fire_record_*() functions are called from initialization, tool confirmation, approval, and completion nodes.
Chain memory stores (chain_findings_memory, chain_failures_memory, chain_decisions_memory, chain_waves_memory) are accumulated lists on AgentState that survive across objectives (cleared only on session reset). chain_decisions_memory tracks phase transitions and operator decisions. chain_waves_memory tracks completed fireteam waves even when they produce zero findings (for coverage awareness).
Execution trace summarization. format_chain_context() (state.py:1694) renders the attack chain for the LLM prompt, grouping tool calls by iteration. summarize_trace_for_response() (state.py:1529) truncates to the last N steps for API responses. A cap of EXECUTION_TRACE_MEMORY_STEPS (default 100) prevents unbounded growth. LATS tree summaries are carried into execution_trace via _carry_tree_forward() (lats.py:1650-1672), and a persistent digest (_lats_tree_digest, _lats_leads, _lats_dead) survives execution trace eviction.
Resumption. Sessions resume by recovering the persisted state from Postgres via graph.aget_state(config) in the various resume_*_with_streaming() methods (orchestrator.py:1183-1401). The last checkpoint's state is loaded, the user's response injected, and graph.astream() continues from where it paused.
Prior chain context. On first invocation of a new session, initialize_node (initialize_node.py:518-534) queries Neo4j for prior chains from the same project (with a 15-second timeout), rendering them as _prior_chain_context in state. This allows the agent to see past attack chain results when starting a new objective.
PERSISTENT_CHECKPOINTER: True in agentic/project_settings.py L98, and set to "true" in docker-compose.yml); MemorySaver is only the fallback when it is switched off or DATABASE_URL is missing.Which models are supported and how are cost and context managed?
answered12 provider types are supported, resolved via model-id prefix (llm_setup.py:90-136): custom/<id> (user-configured), openrouter/<model>, bedrock/<model>, deepseek/<model>, gemini/<model>, glm/<model>, kimi/<model>, qwen/<model>, xai/<model>, mistral/<model>, claude-* (Anthropic), and anything else (OpenAI). Each maps to a LangChain wrapper: ChatOpenAI, ChatAnthropic, or ChatBedrockConverse (llm_setup.py:139-300).
Per-role model selection. The agent is a single-model system — the main think_node LLM is built by setup_llm() using the project's OPENAI_MODEL setting and user's Global Settings API keys. Separate models can be assigned to sub-features: the Tradecraft section picker uses feature_model() to resolve its own model from USER_SETTINGS (orchestrator.py:341-353), the guardrail uses whatever main LLM is configured, and the report summarizer uses the main model. There are no per-role models in a crew sense — only one agent drives all decisions.
Local model support via the custom/<id> provider type. The CUSTOM_PROVIDER_TYPES enum (llm_builder.py:42) includes openai_compatible, bedrock_custom, and ollama_local. OpenAI-compatible custom providers support streaming=True, reasoning_effort, configurable base_url, sslVerify toggle, custom headers, and timeout (llm_setup.py:224-263). The default API key is "ollama" (the key Ollama expects).
Cost and context management. The state tracks input_tokens_used/output_tokens_used/tokens_used cumulatively across the session (state.py:1123-1129). Per-turn deltas (_input_tokens_this_turn, _output_tokens_this_turn) are emitted for UI rendering. Anthropic prompt caching is supported (ANTHROPIC_PROMPT_CACHING_ENABLED, project_settings.py:80 — marks static system prompt prefixes with cache_control={"type": "ephemeral"}). There are no hard token budgets — the system relies on MAX_ITERATIONS (default 100), tool deadlines, and execution trace truncation (default 100 steps). The LATS tree is bounded by LATS_MAX_ROLLOUTS (24) and LATS_MAX_TREE_NODES (60). Provider keys rotate via KeyRotator (orchestrator.py:215-219) for rotating API keys on a per-N-calls basis.
Model discovery is available via the /models API endpoint using model_providers.py, which fetches available model lists from each configured provider (OpenAI, Anthropic, OpenRouter, Bedrock). The fetch_user_providers() function (llm_builder.py:71-95) retrieves the user's LLM provider configurations from the webapp API.