AIDP エージェント(AI駆動型のプログラム実行システム)を Python で高度な実装により構築する際に、aidputils + LangGraph(コード主導型の代替手段で、低コード型のビジュアルエディタの代わりとなるもの)を使用します。 次のような場合に使用: - ユーザーが 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.
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。
create_react_agent、StateGraph、カスタムツールロジック、コードによるマルチエージェントスーパーバイザー、または aidputils に関わる操作全般。aidp-agent-flows を使用すること。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-reasoning、cohere.command-r-08-2024 |
| ツール | AIDPToolConf(name, description, tool_class, conf, params) → create_langgraph_tool(.model_dump()) |
tool_class は PromptTool / 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 IncorrectStateAiFeatureStatus=None(「しばらくしてから再試行してください」)を返します。 これはリクエストボディの不備ではなく、プラットフォームのプロビジョニング状態によるものです。(2)
POST …/actions/deployAgentFlowにはdeploymentTypeenum が必須です(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 のガードレールセクションを参照)。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.
create_react_agent, StateGraph, custom tool logic, multi-agent
supervisor in code, or anything aidputils.aidp-agent-flows. NOT building the RAG corpus → aidp-knowledge-bases.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
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=…))]}.
| 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_class ∈ PromptTool / 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 |
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
agentFlowswrite surface (create included) is gated on the DataLake'saiFeatureStatus=Ready— on a fresh datalake, create returns 409 IncorrectStateAiFeatureStatus=None("try again later") until the Enable-AI-Feature workflow completes; this is a platform-provisioning state, not a body defect. (2)POST …/actions/deployAgentFlowrequires adeploymentTypeenum (theagentFlowKeyalone → 400 "deploymentType must not be null"); the valid value is NOTAI_COMPUTE/SERVERLESS/DEDICATED/ON_DEMAND/QUICK_START/STANDARD/DEFAULT(all 400 "Invalid DeploymentType") — pull the real enum from the SDKDeploymentType/Deploymentmodels before deploying.
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.model_ids/endpoints — list live via aidp-models-catalog. Attach safety policies via
guardrails_config (enums in aidp-agent-flows guardrails section).原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。