test_case_id: test_mermaid_autogen_filename
description: "Tests successful generation with an auto-generated filename when none is provided."
tags: ["all", "agent", "tools", "general_agent_tools"]
skip_intermediate_events: true

gateway_input:
  user_identity: "test_user@example.com"
  target_agent_name: "TestAgent"
  external_context:
    a2a_session_id: "session_mermaid_autogen"
  prompt:
    parts:
      - text: "Create a pie chart showing parts of a whole."

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_456"
                type: "function"
                function:
                  name: "mermaid_diagram_generator"
                  arguments: |
                    {"mermaid_syntax": "pie title \"Parts of a Whole\" \"Frogs\" : 45 \"Hogs\" : 30 \"Dogs\" : 25"}
    expected_request:
      tools_present:
        - "mermaid_diagram_generator"
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I have created the pie chart."
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_contains: "Mermaid diagram rendered and saved as artifact"

expected_gateway_output:
  - type: status_update
    kind: task
    id: '*'
    contextId: "session_mermaid_autogen"
    status:
      state: unknown
      message:
        kind: message
        messageId: '*'
        role: agent
    event_purpose: tool_invocation_start
    expected_tool_name: "mermaid_diagram_generator"
    expected_tool_args_contain:
      mermaid_syntax: 'pie title "Parts of a Whole" "Frogs" : 45 "Hogs" : 30 "Dogs" : 25'

  - type: final_response
    kind: task
    id: '*'
    contextId: "session_mermaid_autogen"
    status:
      state: completed
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: text
            text_exact: "I have created the pie chart."

expected_artifacts:
  - filename_matches_regex: "^mermaid_diagram_.*\\.png$"
    mime_type: "image/png"
    metadata_contains:
      description: "PNG image generated from Mermaid syntax. Original requested filename: N/A"
      source_format: "mermaid_syntax"
