test_case_id: "builtin_load_artifact_text_content_001"
description: |
  Tests the 'load_artifact' tool for loading the content of a simple text artifact.
tags: ["all","agent","tools","builtin_artifact_tools"]
skip_intermediate_events: true

setup_artifacts:
  - filename: "sample_text_doc.txt"
    content: "This is the content of the sample text document." # Length 46
    mime_type: "text/plain"
    metadata:
      description: "A sample text document for load_artifact testing."
      source: "test_setup"
      mime_type: "text/plain"
      size_bytes: 48

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "declarative_load_text_tester@example.com"
  a2a_parts:
    - type: "text"
      text: "Please load the content of 'sample_text_doc.txt', version 0."
  external_context:
    a2a_session_id: "session_load_text_artifact_001"

llm_interactions:
  # Step 1: LLM decides to call load_artifact
  - step_id: "llm_calls_load_artifact"
    static_response:
      id: "chatcmpl-load-text-artifact-1"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "tool_call_load_text_doc"
                type: "function"
                function:
                  name: "load_artifact"
                  arguments: '{"filename": "sample_text_doc.txt", "version": 0}'
          finish_reason: "tool_calls"

  # Step 2: LLM receives tool result and formulates final response
  - step_id: "llm_final_response_after_load"
    expected_request: # After load_artifact tool call
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_json_matches:
            status: "success"
            filename: "sample_text_doc.txt"
            version: 0
            mime_type: "text/plain"
            content: "This is the content of the sample text document."
            size_bytes: 48
    static_response:
      id: "chatcmpl-load-text-artifact-2"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            content: "Loaded 'sample_text_doc.txt' (v0): This is the content of the sample text document."
          finish_reason: "stop"

expected_gateway_output:
  - type: "final_response"
    kind: "task"
    id: "*"
    contextId: "session_load_text_artifact_001"
    status:
      state: "completed"
      message:
        kind: "message"
        messageId: "*"
        role: "agent"
        parts:
          - kind: "text"
            text_exact: "Loaded 'sample_text_doc.txt' (v0): This is the content of the sample text document."
    # Assert state of the setup artifact to ensure it was not modified by load
    assert_artifact_state:
      - filename: "sample_text_doc.txt"
        user_id: "declarative_load_text_tester@example.com"
        session_id: "session_load_text_artifact_001"
        version: 0
        expected_content_text: "This is the content of the sample text document."
        expected_metadata_contains:
          description: "A sample text document for load_artifact testing."
          source: "test_setup"
          mime_type: "text/plain"
          size_bytes: 48
