test_case_id: "fenced_artifact_creation_simple_001"
description: "Tests that a simple fenced artifact block is correctly parsed, saved, and confirmed."
tags: ["all","core_a2a"]
skip_intermediate_events: true

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "fenced_artifact_tester@example.com"
  parts: [{type: "text", text: "Create a file named 'report.md' with the content '# Q1 Report'."}]
  external_context:
    a2a_session_id: "fixed_session_for_fenced_artifact_test_001"

llm_interactions:
  # 1. The LLM responds with the fenced block. The callback will parse this,
  #    save the artifact, and inject a `_notify_artifact_save` tool call into the response.
  - static_response:
      choices:
        - message:
            role: "assistant"
            # The user-facing text is "Okay, I am creating the report for you."
            # The rest is the fenced block that should be processed by the callback.
            content: |
              Okay, I am creating the report for you.
              «««save_artifact: filename="report.md" mime_type="text/markdown" description="Q1 Sales Report"
              # Q1 Report
              This is the first quarter report.
              »»»
          finish_reason: "stop"
      usage: {prompt_tokens: 20, completion_tokens: 100, total_tokens: 120}

  # 2. The ADK runs the `_notify_artifact_save` tool and calls the LLM again with the result.
  #    This is the LLM's final response to the user.
  - static_response:
      choices:
        - message:
            role: "assistant"
            content: "I have successfully created the artifact 'report.md' for you."
          finish_reason: "stop"
      usage: {prompt_tokens: 130, completion_tokens: 20, total_tokens: 150}
    expected_request:
      # Assert that the prompt for this second call contains the response from the internal `_notify_artifact_save` tool.
      expected_tool_responses_in_llm_messages:
        - tool_name: "_notify_artifact_save"
          response_json_matches:
            filename: "report.md"
            version: 0
            status: "success"

expected_gateway_output:
  - type: "final_response"
    kind: "task"
    id: "*"
    contextId: "fixed_session_for_fenced_artifact_test_001"
    status:
      state: "completed"
      message:
        kind: "message"
        messageId: "*"
        role: "agent"
        parts:
          - kind: "text"
            text_contains:
              - "Okay, I am creating the report for you."
              - "I have successfully created the artifact 'report.md' for you."
    assert_artifact_state:
      - filename: "report.md"
        version: 0
        expected_content_text: |
          # Q1 Report
          This is the first quarter report.
        expected_metadata_contains:
          description: "Q1 Sales Report"
          mime_type: "text/markdown"
          schema:
            type: "text/markdown"
            inferred: false
