You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从Oracle Function调用OCI生成式AI Agent遇404未知资源错误

OCI中通过Python SDK调用Generative AI Agent时404错误排查请求

在Oracle Cloud Infrastructure环境中,尝试通过Python SDK从Oracle Function调用Generative AI Agent的/actions/chat端点时,持续返回404「Unknown resource」错误。最终需求是从Oracle Apex调用该Agent,使其借助SQL工具查询数据库。

错误响应

{
    "status": "success",
    "ai_response": "Error calling AI agent: {
        'target_service': 'generative_ai_agent_runtime',
        'status': 404,
        'code': '404',
        'opc-request-id': '4264247FE14242459AEBB2F77E1568BC/08485F02DB93858AE94D4968465241AB/92FE3938AC1BB4E6A8C06F4EAF4F4195',
        'message': 'Unknown resource 2bf22eb5-db44-4fd7-b179-de723aa402aa',
        'operation_name': 'chat',
        'timestamp': '2025-06-11T09:35:37.231897+00:00',
        'client_version': 'Oracle-PythonSDK/2.154.1',
        'request_endpoint': 'POST https://agent-runtime.generativeai.eu-frankfurt-1.oci.oraclecloud.com/20240531/agentEndpoints/ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa3dyenfkvuz7mqixqetkzgftymw7gclbn3evpqif2zlnq/actions/chat'
    }"
}

调用Python代码

import io
import os
import json
import oci
import uuid
import logging
from oci.config import from_file


def call_generative_ai(prompt):
    try:
        # Use Resource Principal Signer
        signer = oci.auth.signers.get_resource_principals_signer()

        generative_ai_agent_runtime_client = oci.generative_ai_agent_runtime.GenerativeAiAgentRuntimeClient(
            config={}, signer=signer
        )

        session_id = str(uuid.uuid4())

        chat_response = generative_ai_agent_runtime_client.chat(
            agent_endpoint_id="ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa3dyenfkvuz7mqixqetkzgftymw7gclbn3evpqif2zlnq",
            chat_details=oci.generative_ai_agent_runtime.models.ChatDetails(
                user_message=prompt,
                session_id=session_id
            )
        )

        return chat_response.data

    except Exception as e:
        return f"Error calling AI agent: {str(e)}"

已完成的排查操作

  • 在eu-frankfurt-1区域正确创建Generative AI Agent和Agent Endpoint,并验证OCID无误
  • 为Oracle Function配置动态组,分配IAM策略允许其访问对应compartment的generative-ai-family资源
  • Function使用资源主体认证,请求签名正常,无认证错误
  • 确认Agent和Agent Endpoint的OCID与控制台显示完全一致
  • 确认compartment OCID正确,且Agent处于活跃状态
  • 当前OCI CLI版本为3.54.5,Cloud Shell未安装对应插件,缺少oci gen-ai命令

请求协助解决该404错误问题。


内容的提问来源于stack exchange,提问作者Nagailîc Pavel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 22:06:19