test_case_id: "dynamic_tool_loading_and_execution_001"
description: |
  Verifies that dynamic tools from both single-class and provider modules
  are correctly loaded with multiple parameters, declared to the LLM, and executed.
skip_intermediate_events: true
tags: ["all", "agent", "tools", "dynamic_tools"]

gateway_input:
  target_agent_name: "CombinedDynamicAgent"
  user_identity: "dynamic_tester@example.com"
  a2a_parts:
    - type: "text"
      text: "Use the dynamic tool to greet 'World' with three exclamation marks, then combine 'Hello' and 'Again', and finally say farewell."

llm_interactions:
  - step_id: "llm_calls_dynamic_tools"
    expected_request:
      expected_tool_declarations_contain:
        - name: "get_dynamic_greeting"
          description_contains: "dynamically-configured greeting"
        - name: "get_provider_farewell"
          description_contains: "farewell message generated by the provider"
        - name: "combine_strings"
          description_contains: "Combines two strings"
    static_response:
      id: "chatcmpl-dynamic-tools-1"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_1"
                type: "function"
                function:
                  name: "get_dynamic_greeting"
                  arguments: '{"name": "World", "punctuation": "!!!"}'
              - id: "call_2"
                type: "function"
                function:
                  name: "combine_strings"
                  arguments: '{"first": "Hello", "second": "Again"}'
              - id: "call_3"
                type: "function"
                function:
                  name: "get_provider_farewell"
                  arguments: '{"name": "World"}'
          finish_reason: "tool_calls"

  - step_id: "llm_final_response"
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_json_matches:
            greeting: "Hi there, World!!!"
        - tool_call_id_matches_prior_request_index: 1
          response_json_matches:
            combined: "HelloAgain"
        - tool_call_id_matches_prior_request_index: 2
          response_json_matches:
            farewell: "Goodbye, World!"
    static_response:
      id: "chatcmpl-dynamic-tools-2"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            content: "Greeting: Hi there, World!!!, Combined: HelloAgain, Farewell: Goodbye, World!"
          finish_reason: "stop"

expected_gateway_output:
  - type: "final_response"
    kind: task
    id: "*"
    contextId: "session_dynamic_tester_001"
    status:
      state: "completed"
      message:
        kind: message
        messageId: "*"
        role: agent
        parts:
          - type: "text"
            text_exact: "Greeting: Hi there, World!!!, Combined: HelloAgain, Farewell: Goodbye, World!"
