test_case_id: "mcp_no_fallback_on_error_001"
description: "Verifies that if fallback_to_raw_on_error is false, a processing error
  results in no artifact and a clear failure message."
tags: ["all", "agent", "mcp"]
skip_intermediate_events: true

test_runner_config_overrides:
  agent_config:
    mcp_tool_response_save_threshold_bytes: 10 # Force saving
    mcp_intelligent_processing:
      fallback_to_raw_on_error: false

monkeypatch_spec:
  # Force an error during the intelligent processing step
  - target: "solace_agent_mesh.agent.adk.intelligent_mcp_callbacks._save_content_item_as_artifact"
    side_effect: "exception"
    exception_type: "ValueError"
    exception_message: "Simulated intelligent save failure"

gateway_input:
  target_agent_name: "TestAgent"
  user_identity: "mcp_fallback_tester@example.com"
  parts:
    - type: "text"
      text: "Get a response that will fail to save, with fallback disabled."
  external_context:
    a2a_session_id: "session_mcp_no_fallback_on_error_001"

llm_interactions:
  - static_response:
      choices:
        - message:
            role: "assistant"
            tool_calls:
              - id: "call_mcp_tool_123"
                type: "function"
                function:
                  name: "get_data_stdio"
                  arguments: '{"response_to_return": {"content": [{"type": "text",
                    "text": "This content will trigger a save that fails."}]}}'

  - expected_request:
      expected_tool_responses_in_llm_messages:
        - tool_name: "get_data_stdio"
          response_json_matches:
            status: "processed_save_failed"
            message_to_llm: "Saving the full response as an artifact failed."
            saved_mcp_response_artifact_details:
              status: "error"
              message: "Failed to save MCP response as artifact: Simulated intelligent
                save failure"
    static_response:
      choices:
        - message:
            role: "assistant"
            content: "I tried to process the data, but an error occurred and no artifact
              was saved because the fallback mechanism was disabled."

expected_gateway_output:
  - type: "final_response"
    kind: task
    id: '*'
    contextId: "session_mcp_no_fallback_on_error_001"
    status:
      state: completed
      message:
        kind: message
        messageId: '*'
        role: agent
        parts:
          - type: "text"
            text_exact: "I tried to process the data, but an error occurred and no
              artifact was saved because the fallback mechanism was disabled."
    # No assert_artifact_state, as no artifact should be created.
