test_case_id: "builtin_load_artifact_not_found_error_001"
description: |
  Tests the 'load_artifact' tool's error handling when the specified
  artifact filename does not exist.
tags: ["all","agent","tools","builtin_artifact_tools"]
skip_intermediate_events: true

# No setup_artifacts for the target file, as it's intended to be non-existent.

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "declarative_load_error_tester@example.com"
  a2a_parts:
    - type: "text"
      text: "Please try to load 'non_existent_doc.txt', version 0."
  external_context:
    a2a_session_id: "session_load_error_artifact_001"

llm_interactions:
  # Step 1: LLM calls load_artifact for a non-existent file
  - step_id: "llm_calls_load_non_existent_artifact"
    static_response:
      id: "chatcmpl-load-nonexistent-artifact-1"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "tool_call_load_nonexistent"
                type: "function"
                function:
                  name: "load_artifact"
                  arguments: '{"filename": "non_existent_doc.txt", "version": 0}'
          finish_reason: "tool_calls"

  # Step 2: LLM receives tool error result and formulates final response
  - step_id: "llm_final_response_after_load_error"
    expected_request: # After load_artifact tool call
      expected_tool_responses_in_llm_messages:
        - tool_call_id_matches_prior_request_index: 0
          response_json_contains:
            status: "error"
    static_response:
      id: "chatcmpl-load-nonexistent-artifact-2"
      object: "chat.completion"
      model: "test-llm-model"
      choices:
        - message:
            role: "assistant"
            content: "I couldn't load 'non_existent_doc.txt' because it was not found."
          finish_reason: "stop"

expected_gateway_output:
  - type: "final_response"
    kind: "task"
    id: "*"
    contextId: "session_load_error_artifact_001"
    status:
      state: "completed"
      message:
        kind: "message"
        messageId: "*"
        role: "agent"
        parts:
          - kind: "text"
            text_exact: "I couldn't load 'non_existent_doc.txt' because it was not found."
