test_case_id: "embed_artifact_meta_existing_latest_001"
description: "Tests «artifact_meta:file1.txt» resolves to the latest version's metadata."
tags: ["all","common","embeds"]
skip_intermediate_events: true

setup_artifacts:
  - filename: "file1.txt"
    mime_type: "text/plain"
    content: "Version 0 content"
    metadata: {"source": "initial_upload"}
  - filename: "file1.txt"
    mime_type: "text/markdown"
    content: "## Version 1 Content"
    metadata: {"source": "latest_upload"}

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "embed_tester@example.com"
  a2a_parts:
    - type: "text"
      text: "Get metadata for file1.txt"
  external_context:
    a2a_session_id: "fixed_session_for_artifact_meta_test_latest_001"

llm_interactions:
  - static_response:
      choices: [{message: {role: "assistant", content: "Metadata: «artifact_meta:file1.txt»"}}]

expected_gateway_output:
  - type: "final_response"
    kind: "task"
    id: "*"
    contextId: "fixed_session_for_artifact_meta_test_latest_001"
    status:
      state: "completed"
      message:
        kind: "message"
        messageId: "*"
        role: "agent"
        parts:
          - kind: "text"
            text_contains:
              - "--- Metadata for artifact 'file1.txt' (v1) ---"
              - "*   **Source:** latest_upload"
              - "*   **Type:** text/markdown"
              - "*   **Schema Type:** text/markdown"
            text_matches_regex:
              - "\\*   size: \\d+"
