@security @prompt-injection @auto-debug-agent
Feature: AutoDebugAgent prompt injection vulnerability mitigation
  As a security-conscious developer
  I want AutoDebugAgent to sanitize user-provided content
  So that prompt injection attacks cannot override the agent's instructions

  @security @prompt-injection
  Scenario: Error message is wrapped with boundary markers
    Given an auto debug agent with a mock LLM
    When I invoke the agent with a normal error message
    Then the error message should be wrapped with USER_CONTENT_START and USER_CONTENT_END markers
    And the system prompt should include the boundary instruction

  @security @prompt-injection
  Scenario: Code context is wrapped with boundary markers
    Given an auto debug agent with a mock LLM
    When I invoke the agent with code context
    Then the code context should be wrapped with USER_CONTENT_START and USER_CONTENT_END markers
    And the system prompt should include the boundary instruction

  @security @prompt-injection
  Scenario: Prompt injection attempt in error message is neutralized
    Given an auto debug agent with a mock LLM
    When I invoke the agent with a malicious error message containing "Ignore all previous instructions"
    Then the malicious instruction should be sanitized
    And the agent should continue with its original instructions
    And the boundary markers should protect against the injection

  @security @prompt-injection
  Scenario: Prompt injection attempt in code context is neutralized
    Given an auto debug agent with a mock LLM
    When I invoke the agent with malicious code context containing "Ignore all previous instructions"
    Then the malicious instruction should be sanitized
    And the agent should continue with its original instructions
    And the boundary markers should protect against the injection

  @security @prompt-injection
  Scenario: HTML entities in user content are escaped
    Given an auto debug agent with a mock LLM
    When I invoke the agent with error message containing HTML entities
    Then the HTML entities should be escaped in the prompt
    And the boundary markers should be present

  @security @prompt-injection
  Scenario: Control characters are stripped from user content
    Given an auto debug agent with a mock LLM
    When I invoke the agent with error message containing control characters
    Then the control characters should be removed
    And the boundary markers should be present
