Files
gns3-server/docs/gns3-copilot/roadmap/injection-fault-tracking-roadmap.md
T
YueGuobin 6a4cbe39c1 refactor(copilot): reuse MCP tools via a bridge; extract shared device runners
The copilot and the MCP service maintained two parallel wrapper layers
(LangChain BaseTool classes vs @mcp.tool() functions) over the same
handlers in gns3_client/api_handlers.py. Descriptions and parameters
drifted apart (compute_id and link_type were missing on the copilot
side). This makes the MCP registration the single source of truth and
removes the duplicated wrappers.

tools_v2/mcp_bridge.py adapts the MCP server's tool registration into
LangChain tools: names, descriptions and argument schemas come from the
MCP tools. The pool is filtered to project-scoped tools
(MCP_ALLOWED_TOOLS) because the copilot runs inside one open project —
project management, compute/appliance/image administration and server
info tools stay out. The bridge carries the copilot's request JWT into
the MCP contextvars (username/token_version decoded from the token so
ticket-minting tools work) and runs the async MCP functions from the
copilot's sync tool node on either thread flavor.

Mode toolsets (teaching / lab_automation / troubleshooting_injection)
are now composed from adapted MCP tools plus a few copilot-native ones
that add value the MCP versions lack: link_create (port-name
resolution), wait_seconds, packet_analysis(+skills), and the topology
reader. Eight orphaned LangChain wrappers are deleted.

The device command tools had the dependency inverted (the MCP handlers
instantiated the copilot LangChain classes and round-tripped through
JSON strings). The Nornir/Netmiko classes moved verbatim (git mv) into
the shared layer as plain runners — DeviceConfigCommandRunner,
DeviceShowCommandRunner, VpcsCommandRunner — with _run(json_string)
becoming run(params, gns3_ctx). The optional Jinja2 template rendering
moved from the MCP handlers into the runners (and into
utils/device_configs.render_device_template), so both entry paths get
it; the MCP handlers are now pure delegation. This also drops the
json.dumps/json.loads detour the MCP path used to take.

test_tool_params consistency gate extended: a handler that forwards the
whole params dict to a callee is a wildcard (same rationale as the
params.items() case) — the per-key check cannot see through delegation.
2026-11-03 22:04:57 +08:00

2.6 KiB

This document is a roadmap/planning document. The described features have not been implemented yet.

Injection Fault Tracking — Roadmap

Problem

When using the AI Copilot in troubleshooting injection mode across multiple chat sessions within the same project, there is no mechanism to prevent the same fault from being injected repeatedly. Each new session starts with a clean slate, unaware of what faults have already been used. This leads to:

  • Duplicate injection scenarios across different sessions
  • No visibility for instructors into which faults have been used
  • No record of which devices were affected or whether faults were resolved

Proposed Solution

Track injected faults per chat session and feed the history into the LLM's system prompt as context, so the model actively avoids repeating scenarios.

1. Storage

The existing chat_sessions table has metadata and stats JSON columns. After each fault injection, the agent records:

// stored in chat_session.metadata
{
    "injected_fault": {
        "fault_type": "injection_ospf",
        "issue_key": "ospf_hello_dead_mismatch",
        "issue_name": "OSPF Hello/Dead Interval Mismatch",
        "device": "R1",
        "severity": "major",
        "injected_at": "2026-05-11T23:00:00Z",
        "resolved": false
    }
}

2. Context Injection

When starting a new troubleshooting session, query all previous sessions for the project, filter by copilot_mode = "troubleshooting_injection", extract injected_fault data, and inject a summary into the system prompt via a placeholder (similar to the existing {{topology_info}} mechanism):

Previously injected faults in this project:
  1. OSPF Hello/Dead Interval Mismatch on R1 (2026-05-11) — resolved
  2. BGP Route Reflector misconfiguration on R3 (2026-05-10) — resolved

Select a fault that has NOT been used before.

3. Prompt Update

The troubleshooting_injection.md prompt in the GNS3-Skills repository gains an {{injection_history}} placeholder, and the agent is instructed to choose a fault not in the history list.

Status

  • GNS3-Skills: add {{injection_history}} placeholder to troubleshooting_injection.md
  • gns3-server: implement injection fault recording in agent chat session flow
  • gns3-server: implement injection history query across sessions per project
  • gns3-server: inject history into system prompt via context_manager.py
  • gns3-server: add exclude parameter to injection_skill_get for filtering used faults