Feature: Configurable limits in context analysis and plan generation
  As a developer using the agents module
  I want to configure the maximum number of dependencies and context files
  So that I can tune the agents for different project sizes and resource constraints

  Background:
    Given the configurable limits module is importable

  # ContextAnalysisAgent.max_dependencies tests

  @configurable_limits
  Scenario: ContextAnalysisAgent uses default max_dependencies of 10
    Given a ContextAnalysisAgent with default settings
    When I parse dependencies from a string with 15 items
    Then the result should contain exactly 10 dependencies

  @configurable_limits
  Scenario: ContextAnalysisAgent respects custom max_dependencies
    Given a ContextAnalysisAgent with max_dependencies set to 3
    When I parse dependencies from a string with 15 items
    Then the result should contain exactly 3 dependencies

  @configurable_limits
  Scenario: ContextAnalysisAgent raises ValueError for non-positive max_dependencies
    When I create a ContextAnalysisAgent with max_dependencies set to 0
    Then a ValueError should be raised about max_dependencies

  @configurable_limits
  Scenario: ContextAnalysisAgent raises ValueError for negative max_dependencies
    When I create a ContextAnalysisAgent with max_dependencies set to -5
    Then a ValueError should be raised about max_dependencies

  @configurable_limits
  Scenario: ContextAnalysisAgent max_dependencies of 1 returns single dependency
    Given a ContextAnalysisAgent with max_dependencies set to 1
    When I parse dependencies from a string with 15 items
    Then the result should contain exactly 1 dependencies

  # PlanGenerationGraph.max_context_files tests

  @configurable_limits
  Scenario: PlanGenerationGraph uses default max_context_files of 5
    Given a PlanGenerationGraph with default settings
    When I format a context summary with 8 context files
    Then the summary should contain exactly 5 file entries
    And the summary should mention 3 more files

  @configurable_limits
  Scenario: PlanGenerationGraph respects custom max_context_files
    Given a PlanGenerationGraph with max_context_files set to 2
    When I format a context summary with 8 context files
    Then the summary should contain exactly 2 file entries
    And the summary should mention 6 more files

  @configurable_limits
  Scenario: PlanGenerationGraph raises ValueError for non-positive max_context_files
    When I create a PlanGenerationGraph with max_context_files set to 0
    Then a ValueError should be raised about max_context_files

  @configurable_limits
  Scenario: PlanGenerationGraph raises ValueError for negative max_context_files
    When I create a PlanGenerationGraph with max_context_files set to -1
    Then a ValueError should be raised about max_context_files

  @configurable_limits
  Scenario: PlanGenerationGraph with fewer contexts than max_context_files shows all
    Given a PlanGenerationGraph with max_context_files set to 10
    When I format a context summary with 3 context files
    Then the summary should contain exactly 3 file entries
    And the summary should not mention more files

  @configurable_limits
  Scenario: PlanGenerationGraph with exactly max_context_files contexts shows all
    Given a PlanGenerationGraph with default settings
    When I format a context summary with 5 context files
    Then the summary should contain exactly 5 file entries
    And the summary should not mention more files

  @configurable_limits
  Scenario: PlanGenerationGraph with empty contexts returns no context message
    Given a PlanGenerationGraph with default settings
    When I format a context summary with 0 context files
    Then the summary should be the no-context message
