log:
  stdout_log_level: INFO
  log_file_level: DEBUG
  log_file: level2_parallel_execution.log

!include ../../shared_config.yaml

apps:
  # ============================================================================
  # LEVEL 2: PARALLEL EXECUTION WORKFLOW
  # ============================================================================
  # Tests implicit parallel execution with implicit fork and join
  # Complexity: Medium
  # Node types: agent (4)
  # Features: Parallel execution, implicit fork/join, dependency management
  # ============================================================================

  # ----------------------------------------------------------------------------
  # AGENT: Number Squarer
  # Squares a numeric value
  # ----------------------------------------------------------------------------
  - name: number_squarer_app
    app_base_path: .
    app_module: solace_agent_mesh.agent.sac.app
    broker:
      <<: *broker_connection

    app_config:
      namespace: ${NAMESPACE}
      agent_name: "NumberSquarer"
      model: *planning_model

      instruction: |
        You square numeric values.
        1. Read 'value' from input
        2. Calculate: squared_value = value * value
        3. Create a JSON artifact with: {"squared_value": <result>}
        4. End with: «result:artifact=<artifact_name> status=success»

        IMPORTANT: When invoked by a workflow, use the exact output filename specified in the workflow instructions.

      input_schema:
        type: object
        properties:
          value: {type: number}
        required: [value]

      output_schema:
        type: object
        properties:
          squared_value: {type: number}
        required: [squared_value]

      tools:
        - tool_type: builtin-group
          group_name: "artifact_management"

      session_service:
        <<: *default_session_service
      artifact_service:
        <<: *default_artifact_service

      agent_card:
        description: "Squares numeric values"
        skills: [{id: "square_value", name: "Square Value", description: "Squares a number", tags: ["math"]}]
      agent_card_publishing: { interval_seconds: 10 }
      agent_discovery: { enabled: true }

  # ----------------------------------------------------------------------------
  # AGENT: Number Incrementer
  # Increments a numeric value by 1
  # ----------------------------------------------------------------------------
  - name: number_incrementer_app
    app_base_path: .
    app_module: solace_agent_mesh.agent.sac.app
    broker:
      <<: *broker_connection

    app_config:
      namespace: ${NAMESPACE}
      agent_name: "NumberIncrementer"
      model: *planning_model

      instruction: |
        You increment numeric values by 1.
        1. Read 'value' from input
        2. Calculate: incremented_value = value + 1
        3. Create a JSON artifact with: {"incremented_value": <result>}
        4. End with: «result:artifact=<artifact_name> status=success»

        IMPORTANT: When invoked by a workflow, use the exact output filename specified in the workflow instructions.

      input_schema:
        type: object
        properties:
          value: {type: number}
        required: [value]

      output_schema:
        type: object
        properties:
          incremented_value: {type: number}
        required: [incremented_value]

      tools:
        - tool_type: builtin-group
          group_name: "artifact_management"

      session_service:
        <<: *default_session_service
      artifact_service:
        <<: *default_artifact_service

      agent_card:
        description: "Increments numeric values"
        skills: [{id: "increment_value", name: "Increment Value", description: "Increments a number", tags: ["math"]}]
      agent_card_publishing: { interval_seconds: 10 }
      agent_discovery: { enabled: true }

  # ----------------------------------------------------------------------------
  # AGENT: Number Adder
  # Adds two numeric values
  # ----------------------------------------------------------------------------
  - name: number_adder_app
    app_base_path: .
    app_module: solace_agent_mesh.agent.sac.app
    broker:
      <<: *broker_connection

    app_config:
      namespace: ${NAMESPACE}
      agent_name: "NumberAdder"
      model: *planning_model

      instruction: |
        You add two numeric values.
        1. Read 'value1' and 'value2' from input
        2. Calculate: sum = value1 + value2
        3. Create a JSON artifact with: {"sum": <result>}
        4. End with: «result:artifact=<artifact_name> status=success»

        IMPORTANT: When invoked by a workflow, use the exact output filename specified in the workflow instructions.

      input_schema:
        type: object
        properties:
          value1: {type: number}
          value2: {type: number}
        required: [value1, value2]

      output_schema:
        type: object
        properties:
          sum: {type: number}
        required: [sum]

      tools:
        - tool_type: builtin-group
          group_name: "artifact_management"

      session_service:
        <<: *default_session_service
      artifact_service:
        <<: *default_artifact_service

      agent_card:
        description: "Adds two numbers"
        skills: [{id: "add_numbers", name: "Add Numbers", description: "Adds two numbers", tags: ["math"]}]
      agent_card_publishing: { interval_seconds: 10 }
      agent_discovery: { enabled: true }

  # ============================================================================
  # WORKFLOW: Parallel Execution
  # ============================================================================
  - name: parallel_execution_workflow
    app_base_path: .
    app_module: solace_agent_mesh.workflow.app
    broker:
      <<: *broker_connection

    app_config:
      namespace: ${NAMESPACE}
      name: "ParallelExecutionWorkflow"
      display_name: "Parallel Execution Workflow"

      # Timeout configurations
      max_workflow_execution_time_seconds: 300  # 5 minutes
      default_node_timeout_seconds: 60          # 1 minute

      workflow:
        version: "1.0.0"
        description: |
          A parallel execution workflow for evaluation testing.

          This workflow:
          1. Validates input (single node)
          2. Parallel fork: Squares the value AND increments the value (parallel)
          3. Implicit join: Adds the results from both branches

          Tests: Implicit parallelism, fork/join, dependency management

        input_schema:
          type: object
          properties:
            value:
              type: number
              description: "The value to process"
          required: [value]

        output_schema:
          type: object
          properties:
            sum: {type: number}
            squared: {type: number}
            incremented: {type: number}
          required: [sum, squared, incremented]

        nodes:
          # Step 1: Validate (single node - runs first)
          - id: validate
            type: agent
            agent_name: "DataDoubler"
            instruction: "Validate the input by doubling it (just to have a validation step)."
            input:
              value: "{{workflow.input.value}}"

          # Step 2a: Square the value (runs in parallel with step 2b)
          - id: square_value
            type: agent
            agent_name: "NumberSquarer"
            depends_on: [validate]
            instruction: "Square the input value."
            input:
              value: "{{workflow.input.value}}"

          # Step 2b: Increment the value (runs in parallel with step 2a)
          - id: increment_value
            type: agent
            agent_name: "NumberIncrementer"
            depends_on: [validate]
            instruction: "Increment the input value by 1."
            input:
              value: "{{workflow.input.value}}"

          # Step 3: Add results (implicit join - waits for both parallel branches)
          - id: add_results
            type: agent
            agent_name: "NumberAdder"
            depends_on: [square_value, increment_value]
            instruction: "Add the squared and incremented values."
            input:
              value1: "{{square_value.output.squared_value}}"
              value2: "{{increment_value.output.incremented_value}}"

        output_mapping:
          sum: "{{add_results.output.sum}}"
          squared: "{{square_value.output.squared_value}}"
          incremented: "{{increment_value.output.incremented_value}}"

        skills:
          - id: "parallel_math"
            name: "Parallel Math Operations"
            description: "Performs parallel math operations and combines results"
            tags: ["eval", "level2", "parallel"]

      session_service:
        <<: *default_session_service
      artifact_service:
        <<: *default_artifact_service

      agent_card_publishing: { interval_seconds: 10 }
      agent_discovery: { enabled: true }
