test_case_id: test_mermaid_invalid_syntax
description: "Tests graceful failure when provided with invalid Mermaid syntax."
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_invalid_syntax"
  prompt:
    parts:
      - text: "Generate a diagram with this invalid syntax."

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_abc"
                type: "function"
                function:
                  name: "mermaid_diagram_generator"
                  arguments: '{"mermaid_syntax": "this is not valid mermaid syntax"}'
    expected_request:
      tools_present:
        - "mermaid_diagram_generator"
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I could not generate the diagram because the syntax was invalid."
    expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_contains: "UnknownDiagramError: No diagram type detected"

expected_gateway_output:
  - type: status_update
    event_purpose: tool_invocation_start
    expected_tool_name: "mermaid_diagram_generator"

  - type: final_response
    content_parts:
      - type: text
        text_exact: "I could not generate the diagram because the syntax was invalid."

expected_artifacts: []
