claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🐍aidp-agent-highcode

説明

aidputils と LangGraph を使用して、高コード Python で AIDP エージェントを構築します (低コードのエージェントフローキャンバスに対する、コードファーストの代替手段です)。 次のような場合に使用: - Python でエージェントを記述したい - LangGraph / `create_react_agent` / `StateGraph` を使用したい - `aidputils`(`OCIAIConf`、`AIDPToolConf`、`init_oci_llm`、`create_langgraph_tool`)を呼び出したい - カスタムまたはマルチエージェントのスーパーバイザーフローをコードで構築したい - 「AIDP エージェントをコーディングするにはどうすればよいか」と質問している 低コード/REST ノードグラフのパスについては、`aidp-agent-flows` を使用してください。

原文を表示

Build AIDP agents in high-code Python with aidputils + LangGraph (the code-first alternative to the low-code agent-flow canvas). Use when the user wants to write an agent in Python, use LangGraph / create_react_agent / StateGraph, call aidputils (OCIAIConf, AIDPToolConf, init_oci_llm, create_langgraph_tool), build a custom or multi-agent supervisor flow in code, or asks "how do I code an AIDP agent". For the low-code/REST node-graph path use aidp-agent-flows.

ユースケース

  • PythonでAIDPエージェントを構築したい
  • LangGraphを使用してエージェントを実装したい
  • カスタムエージェントフローをコードで構築したい
  • マルチエージェントのスーパーバイザーフローを構築したい

本文(日本語訳)

aidp-agent-highcode — コードファースト AIDP エージェント(aidputils + LangGraph)

GA(一般提供)ハイコードパス:aidputils(AI Compute にプリインストール済み;ローカルへの pip インストール不可;旧名 aidp_flowutils)と LangGraph 1.x を組み合わせて、Python エージェントクラスを記述するアプローチです。 .py ファイルをワークスペース(aidp-workspace-files / aidp-notebooks)で作成し、AI Compute 上で実行します。 根拠ドキュメント:AIDP_High_Code_Complete_Reference.md §4〜12、§22。


次のような場合に使用

  • AIDP エージェントをコードで記述・実装したい場合、LangGraph、create_react_agentStateGraph、カスタムツールロジック、コードによるマルチエージェントスーパーバイザー、または aidputils に関わる操作全般。
  • ドラッグ&ドロップ/REST ノードグラフ → aidp-agent-flows を使用すること。
  • RAG コーパスの構築 → aidp-knowledge-bases を使用すること。

インポート(現行 aidputils;旧 aidp_flowutils も引き続き動作)

from aidputils.agents.toolkit.tool_helper import create_langgraph_tool
from aidputils.agents.toolkit.agent_helper import init_oci_llm, pre_invoke_setup
from aidputils.agents.toolkit.configs import AIDPToolConf, OCIAIConf, ModelArgs
from langgraph.prebuilt import create_react_agent
from langgraph.graph import StateGraph, MessagesState, START, END
from langchain_core.messages import HumanMessage

エージェントクラスのコントラクト(必須)

すべてのエージェントは __init__ / setup() / async invoke() を実装しなければなりません:

class MyAgent:
    def __init__(self) -> None:
        self.agent = None                      # または self.graph = None

    def setup(self) -> None:                   # 同期処理、一度だけ呼ばれる:LLM + ツール + エージェントを構築
        llm = init_oci_llm(OCIAIConf(
            model_provider="generic", model_id="xai.grok-4",
            compartment_id="ocid1.compartment.oc1..…",
            endpoint="https://inference.generativeai.us-ashburn-1.oci.oraclecloud.com",
            model_args=ModelArgs(temperature=0.7, max_tokens=4096),
            guardrails_config={"policies": []}, auth_type="SECURITY_TOKEN", auth_profile="DEFAULT"))
        tool = create_langgraph_tool(AIDPToolConf(
            name="summarizer", description="Summarize text",
            tool_class="PromptTool",            # または "SQLTool" / "RAGTool"
            conf={...}, params=[{"name":"text","type":"string","description":"…"}]).model_dump())
        self.agent = create_react_agent(llm, [tool])    # シングルエージェント;マルチエージェントの場合は StateGraph

    async def invoke(self, user_query: str, **kwargs):
        config = pre_invoke_setup(**kwargs)             # invoke の先頭で必ず呼ぶこと
        message = {"messages": [dict(HumanMessage(content=user_query))]}
        return await self.agent.ainvoke(input=message, config=config)

ルール(HC リファレンス §5):

  • setup()同期処理で、一度だけ実行される。
  • invoke()非同期処理で、クエリごとに実行される。
  • pre_invoke_setup(**kwargs)invoke() の先頭で必ず最初に呼び出すこと。
  • 入力は常に {"messages": [dict(HumanMessage(content=…))]} の形式とする。

ビルディングブロック

要素 API 備考
LLM OCIAIConf(model_provider, model_id, compartment_id, endpoint, model_args, guardrails_config, auth_type, auth_profile)init_oci_llm() モデル例:xai.grok-4(デフォルト)、xai.grok-4-fast-reasoningcohere.command-r-08-2024
ツール AIDPToolConf(name, description, tool_class, conf, params)create_langgraph_tool(.model_dump()) tool_classPromptTool / SQLTool / RAGTool のいずれか(RAGTool には KB が必要 → aidp-knowledge-bases
シングルエージェント create_react_agent(llm, tools) LangGraph 組み込み
マルチエージェント StateGraph(MessagesState) + スーパーバイザー(HC リファレンス §10) ノード + START/END エッジ
オブザーバビリティ AIDPObservability(HC リファレンス §12) トレーシング

デプロイ

エージェントの .py ファイルをワークスペースに配置し、エントリーファイルと依存ファイルを指定した上で(HC リファレンス §22)、AI Compute(プレビュー — aidp-cluster-ops 参照)上で実行・デプロイします。 デプロイとセッションの管理は、agent-flow デプロイアクション(aidp-agent-flows)経由でも可能です。

2026-06-10 de-agent にて実動確認済み — 補足事項: agent-flow デプロイアクションにはゲート制御と必須フィールドのコントラクトが存在します。

(1) agentFlows への書き込み操作全体(作成を含む)は、DataLake の aiFeatureStatus=Ready をゲート条件としています。 新規 DataLake では、Enable-AI-Feature ワークフローが完了するまで、作成操作が 409 IncorrectState AiFeatureStatus=None(「しばらくしてから再試行してください」)を返します。 これはリクエストボディの不備ではなく、プラットフォームのプロビジョニング状態によるものです。

(2) POST …/actions/deployAgentFlow には deploymentType enum が必須です(agentFlowKey のみでは → 400「deploymentType must not be null」)。 有効な値は AI_COMPUTE / SERVERLESS / DEDICATED / ON_DEMAND / QUICK_START / STANDARD / DEFAULT ではありません(いずれも 400「Invalid DeploymentType」)。 デプロイ前に SDK の DeploymentType/Deployment モデルから正しい enum 値を取得してください。


ガードレール

  • aidputils は AI Compute 内にのみ存在します。コードの作成・編集は aidp-workspace-files 経由で行い、ローカルでは実行しないでください。pip install aidputils がローカルで使えると案内しないこと。
  • model_id やエンドポイントは架空の値を使用しないでください。aidp-models-catalog で現行の一覧を確認してください。安全ポリシーは guardrails_config で付与してください(enum 値は aidp-agent-flows のガードレールセクションを参照)。

関連リファレンス

原文(English)を表示

aidp-agent-highcode — code-first AIDP agents (aidputils + LangGraph)

The GA high-code path: write a Python agent class using aidputils (pre-installed in AI Compute; not pip-installable locally; legacy name aidp_flowutils) on top of LangGraph 1.x. You author the .py in the workspace (aidp-workspace-files / aidp-notebooks) and run it on AI Compute. Grounded in AIDP_High_Code_Complete_Reference.md §4–12, §22.

When to use

  • "Write/code an AIDP agent", LangGraph, create_react_agent, StateGraph, custom tool logic, multi-agent supervisor in code, or anything aidputils.
  • NOT the drag-and-drop / REST node graph → aidp-agent-flows. NOT building the RAG corpus → aidp-knowledge-bases.

Imports (current aidputils; legacy aidp_flowutils still works)

from aidputils.agents.toolkit.tool_helper import create_langgraph_tool
from aidputils.agents.toolkit.agent_helper import init_oci_llm, pre_invoke_setup
from aidputils.agents.toolkit.configs import AIDPToolConf, OCIAIConf, ModelArgs
from langgraph.prebuilt import create_react_agent
from langgraph.graph import StateGraph, MessagesState, START, END
from langchain_core.messages import HumanMessage

The agent class contract (REQUIRED)

Every agent MUST implement __init__ / setup() / async invoke():

class MyAgent:
    def __init__(self) -> None:
        self.agent = None                      # or self.graph = None

    def setup(self) -> None:                   # sync, called once: build LLM + tools + agent
        llm = init_oci_llm(OCIAIConf(
            model_provider="generic", model_id="xai.grok-4",
            compartment_id="ocid1.compartment.oc1..…",
            endpoint="https://inference.generativeai.us-ashburn-1.oci.oraclecloud.com",
            model_args=ModelArgs(temperature=0.7, max_tokens=4096),
            guardrails_config={"policies": []}, auth_type="SECURITY_TOKEN", auth_profile="DEFAULT"))
        tool = create_langgraph_tool(AIDPToolConf(
            name="summarizer", description="Summarize text",
            tool_class="PromptTool",            # or "SQLTool" / "RAGTool"
            conf={...}, params=[{"name":"text","type":"string","description":"…"}]).model_dump())
        self.agent = create_react_agent(llm, [tool])    # single-agent; StateGraph for multi-agent

    async def invoke(self, user_query: str, **kwargs):
        config = pre_invoke_setup(**kwargs)             # MUST be first line of every invoke
        message = {"messages": [dict(HumanMessage(content=user_query))]}
        return await self.agent.ainvoke(input=message, config=config)

Rules (HC ref §5): setup() is synchronous, runs once; invoke() is async, per query; pre_invoke_setup(**kwargs) must be the first call in invoke(); input is always {"messages": [dict(HumanMessage(content=…))]}.

Building blocks

Piece API Notes
LLM OCIAIConf(model_provider, model_id, compartment_id, endpoint, model_args, guardrails_config, auth_type, auth_profile)init_oci_llm() Models: xai.grok-4 (default), xai.grok-4-fast-reasoning, cohere.command-r-08-2024
Tools AIDPToolConf(name, description, tool_class, conf, params)create_langgraph_tool(.model_dump()) tool_classPromptTool / SQLTool / RAGTool (RAGTool needs a KB → aidp-knowledge-bases)
Single agent create_react_agent(llm, tools) LangGraph prebuilt
Multi-agent StateGraph(MessagesState) + supervisor (HC ref §10) nodes + START/END edges
Observability AIDPObservability (HC ref §12) tracing

Deploy

Place the agent .py in the workspace and designate the entry file + dependency files (HC ref §22), then run/deploy on AI Compute (Preview — see aidp-cluster-ops). Deployment + sessions can also be managed via the agent-flow deploy action (aidp-agent-flows).

Live-verified 2026-06-10 on de-agent — correction: the agent-flow deploy action is gated and has a required-field contract. (1) The ENTIRE agentFlows write surface (create included) is gated on the DataLake's aiFeatureStatus=Ready — on a fresh datalake, create returns 409 IncorrectState AiFeatureStatus=None ("try again later") until the Enable-AI-Feature workflow completes; this is a platform-provisioning state, not a body defect. (2) POST …/actions/deployAgentFlow requires a deploymentType enum (the agentFlowKey alone → 400 "deploymentType must not be null"); the valid value is NOT AI_COMPUTE/SERVERLESS/DEDICATED/ON_DEMAND/QUICK_START/STANDARD/DEFAULT (all 400 "Invalid DeploymentType") — pull the real enum from the SDK DeploymentType/Deployment models before deploying.

Guardrails

  • aidputils only exists inside AI Compute — examples are authored/edited via aidp-workspace-files, not run locally. Don't claim a local pip install aidputils.
  • Don't fabricate model_ids/endpoints — list live via aidp-models-catalog. Attach safety policies via guardrails_config (enums in aidp-agent-flows guardrails section).

References

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。