2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenAI の Agent builder を今になって試してみる(テンプレートの内容を少し変更して実行)【AIエージェント構築&運用】

2
Last updated at Posted at 2025-12-21

(この記事は AIエージェント構築&運用 Advent Calendar 2025 の記事です)

はじめに

リリースされた際に気になりつつ、長らく試せていなかった「OpenAI の Agent builder」を試してみた話です。

●Agent Builder | OpenAI API
 https://platform.openai.com/docs/guides/agent-builder

その中で、直近でリリースされたばかりの「GPT Image 1.5」を絡めた内容にしてみます。

さっそく試す

早速、以下の公式のページの情報も少し見つつ、試していきます。

●Agent builder - OpenAI API
 https://platform.openai.com/agent-builder

2025-12-21_23-24-00.jpg

ワークフロー作成画面を見てみる

上記のページから、ワークフロー作成画面へと進みます。

●Agent builder - new workflow - OpenAI API
 https://platform.openai.com/agent-builder/edit

2025-12-21_23-25-01.jpg

初期状態の確認

画面内の「My agent」をクリックします。そうすると、以下の内容が表示されます。

2025-12-21_23-26-39.jpg

いくつかの項目がありますが、例えば Tools という部分を見ると以下の内容が選べるようです。

2025-12-21_23-28-00.jpg

「More」と書かれた部分を押すと、「Evaluate」の関連項目が色々出てきたりもしました。

2025-12-21_23-28-53.jpg

また、「Start」のほうは以下の内容が出てきました。

2025-12-21_23-41-41.jpg

テンプレートの 1つを見てみる

テンプレートとして用意されていたものも、試しに 1つ見てみることにします。具体的には以下の「Data enrichment」を開いてみました。

2025-12-22_00-26-25.jpg

2025-12-22_00-26-51.jpg

また、用意されている内容を順番に見てみます。「Start」はデフォルト設定のままのようです。

2025-12-22_00-27-59.jpg

次の「Web research agent」は以下の内容になっています。

2025-12-22_00-29-10.jpg

さらにプロンプトと出力の内容は、以下のとおりです。

プロンプト
You are a helpful assistant. Use web search to find information about the following company I can use in marketing asset based on the underlying topic.

2025-12-22_00-31-15.jpg

「Tools」に何も設定されていないので、Web検索をしないで提示できる情報を、上記の JSON の項目に合わせて出すもののようです。

3つ目の「Summarize and display」も確認していきます。

2025-12-22_00-32-58.png

プロンプト
Put the research together in a nice display using the output format described.

出力は以下となっていて、どうやら ChatKit widgets が使われているようです。

2025-12-22_00-35-33.jpg

この画面の「Edit」を選ぶと、それを編集するための ChatKit StudioWidget Builder が開きました。

2025-12-22_00-33-52.jpg

内容の編集は行わず、サンプルを動かしてみます。

処理の実行1

画面上部の再生ボタンを押すと、画面右に以下の内容が表示されました。

2025-12-22_00-40-17.jpg

とりあえず「マイクロソフトの情報」というプロンプトを入れてみました。

2025-12-22_00-42-38.jpg

最終出力は以下となっているようでした。

2025-12-22_00-43-35.jpg

処理の実行2

さらに「OpenAI」という内容だけを入力して試してみます。

2025-12-22_00-46-40.jpg

この時の最終出力は、以下となりました。

2025-12-22_00-47-22.jpg

少し手を加えてみる

先ほどの内容に、少しだけ手を加えてみます。「Summarize and display」のプロンプトに、以下のように「The text is translated into Japanese.」という内容を加えてみました。

2025-12-22_00-52-22.jpg

処理を実行してみる

あとは処理を実行してみます。「OpenAI」という内容で試してみたところ、「Summarize and display」の処理のところで日本語への翻訳が行われ、最終出力のとことを日本語に変えられました。

2025-12-22_00-54-04.jpg

2025-12-22_00-55-59.jpg

コードなどの出力

最後に、画面右上にある「Code」という部分を押してみました。そうすると、以下のようなコードなどを出力できるようでした。

2025-12-22_00-57-23.jpg

コードのほうの内容は、以下のとおりです。
【Workflow ID】 の部分は、もとは「 wf_ という文字列と、その後に続く英数字」だったのを置きかえています

import { z } from "zod";
import { Agent, AgentInputItem, Runner, withTrace } from "@openai/agents";

const WebResearchAgentSchema = z.object({
  companies: z.array(
    z.object({
      company_name: z.string(),
      industry: z.string(),
      headquarters_location: z.string(),
      company_size: z.string(),
      website: z.string(),
      description: z.string(),
      founded_year: z.number(),
    })
  ),
});
const SummarizeAndDisplaySchema = z.object({
  company_name: z.string(),
  industry: z.string(),
  headquarters_location: z.string(),
  company_size: z.string(),
  website: z.string(),
  description: z.string(),
  founded_year: z.number(),
});
const webResearchAgent = new Agent({
  name: "Web research agent",
  instructions:
    "You are a helpful assistant. Use web search to find information about the following company I can use in marketing asset based on the underlying topic.",
  model: "gpt-5-mini",
  outputType: WebResearchAgentSchema,
  modelSettings: {
    reasoning: {
      effort: "low",
      summary: "auto",
    },
    store: true,
  },
});

const summarizeAndDisplay = new Agent({
  name: "Summarize and display",
  instructions:
    "Put the research together in a nice display using the output format described.  The text is translated into Japanese.",
  model: "gpt-5",
  outputType: SummarizeAndDisplaySchema,
  modelSettings: {
    reasoning: {
      effort: "minimal",
      summary: "auto",
    },
    store: true,
  },
});

type WorkflowInput = { input_as_text: string };

// Main code entrypoint
export const runWorkflow = async (workflow: WorkflowInput) => {
  return await withTrace("New agent", async () => {
    const state = {};
    const conversationHistory: AgentInputItem[] = [
      {
        role: "user",
        content: [{ type: "input_text", text: workflow.input_as_text }],
      },
    ];
    const runner = new Runner({
      traceMetadata: {
        __trace_source__: "agent-builder",
        workflow_id: "【Workflow ID】",
      },
    });
    const webResearchAgentResultTemp = await runner.run(webResearchAgent, [
      ...conversationHistory,
    ]);
    conversationHistory.push(
      ...webResearchAgentResultTemp.newItems.map((item) => item.rawItem)
    );

    if (!webResearchAgentResultTemp.finalOutput) {
      throw new Error("Agent result is undefined");
    }

    const webResearchAgentResult = {
      output_text: JSON.stringify(webResearchAgentResultTemp.finalOutput),
      output_parsed: webResearchAgentResultTemp.finalOutput,
    };
    const summarizeAndDisplayResultTemp = await runner.run(
      summarizeAndDisplay,
      [...conversationHistory]
    );

    if (!summarizeAndDisplayResultTemp.finalOutput) {
      throw new Error("Agent result is undefined");
    }

    const summarizeAndDisplayResult = {
      output_text: JSON.stringify(summarizeAndDisplayResultTemp.finalOutput),
      output_parsed: summarizeAndDisplayResultTemp.finalOutput,
    };
  });
};
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?