> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google ADK

> Weave를 사용하여 Google의 Agent Development Kit(ADK)로 빌드한 에이전트를 트레이스하세요.

export const AgentLensBanner = ({href}) => <Tip>
    <strong>This workflow is also available in CoreWeave Agent Lens.</strong> Agent Lens is the Forge experience built for tracing, monitoring, and analyzing AI agents, with automated insights into agent failures and user intents. It uses the same trace data as Weights & Biases Weave, so the traces you already send appear there with nothing to migrate.{' '}
    <a href={href || '/products/agent-lens'}>{href ? 'See how to do this in Agent Lens' : 'Learn about Agent Lens'}</a>.
  </Tip>;

<AgentLensBanner href="/ko/products/agent-lens/integrations/google-adk" />

Google의 Agent Development Kit(ADK)는 에이전트를 구축하고 오케스트레이션하기 위한 유연한 프레임워크로, 특정 모델에 종속되지 않습니다. ADK는 Gemini에 최적화되어 있지만 모든 모델을 지원하며, 단순한 작업부터 복잡한 멀티 에이전트 워크플로까지 폭넓게 지원합니다. Weave는 ADK로 구축한 에이전트를 자동으로 트레이스하며, 각 에이전트 호출, 하위 에이전트 핸드오프, 모델 Call, 도구 Call을 모두 기록합니다. 캡처된 데이터는 프로젝트의 **Agents** 뷰에서 확인할 수 있습니다.

<h2 id="trace-google-adk-agents-with-weave">
  Weave로 Google ADK 에이전트 트레이스하기
</h2>

<Tabs>
  <Tab title="Python">
    Weave SDK는 [Google ADK for Python](https://google.github.io/adk-docs/)을 자동 패치하므로 최소한의 설정만으로 ADK 에이전트의 트레이스를 캡처할 수 있습니다. 이 가이드에서는 Weave를 초기화한 다음, Google ADK로 구축한 멀티턴 리서치 에이전트를 실행하는 방법을 보여줍니다. 이렇게 하면 Weave가 세션 전체에서 발생하는 모든 에이전트 호출, 모델 Call, 도구 Call을 캡처합니다.

    <h3 id="prerequisites">
      사전 요구 사항
    </h3>

    * CoreWeave Forge 계정 및 `WANDB_API_KEY` 환경 변수로 설정된 [API 키](https://forge.coreweave.com/settings#apikeys).
    * Gemini용 [Google API 키](https://aistudio.google.com/apikey).
    * Python 3.10 이상.
  </Tab>

  <Tab title="TypeScript">
    Weave는 [Google ADK for Node.js](https://google.github.io/adk-docs/)(`@google/adk`)와 통합되어 에이전트 run을 자동으로 트레이스합니다.

    <h3 id="prerequisites-2">
      사전 요구 사항
    </h3>

    * CoreWeave Forge 계정 및 `WANDB_API_KEY` 환경 변수로 설정된 [API 키](https://forge.coreweave.com/settings#apikeys).
    * `GEMINI_API_KEY` 또는 `GOOGLE_GENAI_API_KEY` 환경 변수로 설정된 [Google API 키](https://aistudio.google.com/apikey).
    * Node.js 18 이상.
    * `@google/adk` 버전 `1.0.0` 이상.
  </Tab>
</Tabs>

<h3 id="install-packages">
  패키지 설치
</h3>

개발 환경에 다음 패키지를 설치하세요. 이 패키지는 Weave SDK, Google ADK 프레임워크, 예시 도구에서 사용하는 HTTP 클라이언트를 제공합니다.

<CodeGroup>
  ```bash Python theme={"system"}
  pip install weave google-adk requests
  ```

  ```bash TypeScript theme={"system"}
  npm install weave @google/adk zod
  ```
</CodeGroup>

<h3 id="initialize-weave-in-your-code">
  코드에서 Weave 초기화하기
</h3>

<Tabs>
  <Tab title="Python">
    프로젝트에 `weave.init`을 추가하고 CoreWeave Forge 팀 이름과 프로젝트 이름을 지정한 다음, 평소처럼 에이전트를 구축하세요. 다음 코드는 `gemini-2.5-flash`와 `wikipedia_search` 도구를 사용하는 `research_assistant` 에이전트를 생성한 후, 하나의 ADK 세션에서 세 가지 질문을 실행합니다. 이 과정에서 Weave가 트레이스를 캡처합니다.

    ```python lines highlight="8" theme={"system"}
    import asyncio
    import requests
    import weave
    from google.adk.agents import Agent
    from google.adk.runners import InMemoryRunner
    from google.genai import types

    weave.init("<your-team>/<your-project-name>")

    def wikipedia_search(query: str) -> dict:
        """Search Wikipedia for a topic and return its title and intro paragraph.

        Args:
            query: The topic to search for.

        Returns:
            A dictionary with the article title and intro extract.
        """
        r = requests.get(
            "https://en.wikipedia.org/w/api.php",
            params={
                "action": "query", "generator": "search", "gsrsearch": query, "gsrlimit": 1,
                "prop": "extracts", "exintro": True, "explaintext": True, "format": "json",
            },
            headers={"User-Agent": "weave-demo"},
        ).json()
        page = next(iter(r["query"]["pages"].values()))
        return {"title": page["title"], "extract": page["extract"]}

    agent = Agent(
        name="research_assistant",
        model="gemini-2.5-flash",
        instruction=(
            "You are a research assistant. Use the wikipedia_search tool to look up "
            "topics when needed, and cite the article titles you used."
        ),
        tools=[wikipedia_search],
    )

    async def main():
        runner = InMemoryRunner(agent=agent, app_name="research-app")
        session = await runner.session_service.create_session(
            app_name="research-app", user_id="user-1"
        )

        questions = [
            "Who founded Anthropic?",
            "What is Claude (the AI assistant)?",
            "Summarize what we discussed in one sentence.",
        ]

        for question in questions:
            print(f"USER: {question}")
            async for event in runner.run_async(
                user_id="user-1",
                session_id=session.id,
                new_message=types.Content(
                    role="user",
                    parts=[types.Part(text=question)],
                ),
            ):
                if event.is_final_response() and event.content:
                    print(f"AGENT: {event.content.parts[0].text}\n")

    asyncio.run(main())
    ```

    이 예시는 하나의 ADK 세션에서 세 개의 턴을 실행합니다. 처음 두 턴에서는 Wikipedia 조회가 트리거되고, 세 번째 턴에서는 도구 Call 없이 이전 대화 컨텍스트를 활용해 요약을 생성합니다.
  </Tab>

  <Tab title="TypeScript">
    Weave는 `WeaveAdkPlugin`을 통해 `@google/adk` 러너를 트레이스하며, 이 플러그인은 러너의 `plugins` 배열에 직접 등록합니다. 플러그인을 명시적으로 등록하는 방식은 ESM 프로젝트와 CommonJS 프로젝트에서 똑같이 작동하므로 모듈 로더 훅을 따로 설정할 필요가 없습니다.

    다음 코드는 `wikipedia_search` 도구를 사용하는 `research_assistant` 에이전트를 생성한 다음, 하나의 ADK 세션에서 세 가지 질문을 실행합니다. 이 과정에서 Weave가 트레이스를 캡처합니다.

    ```typescript lines highlight="35" theme={"system"}
    import * as weave from "weave";
    import { FunctionTool, Gemini, InMemoryRunner, LlmAgent } from "@google/adk";
    import { WeaveAdkPlugin } from "weave";
    import { z } from "zod";

    const GEMINI_API_KEY = process.env.GEMINI_API_KEY

    const wikipediaSearchTool = new FunctionTool({
      name: "wikipedia_search",
      description: "Search Wikipedia for a topic and return its title and intro paragraph.",
      parameters: z.object({
        query: z.string().describe("The topic to search for"),
      }),
      execute: async ({ query }) => {
        const url = new URL("https://en.wikipedia.org/w/api.php");
        url.search = new URLSearchParams({
          action: "query",
          generator: "search",
          gsrsearch: query,
          gsrlimit: "1",
          prop: "extracts",
          exintro: "true",
          explaintext: "true",
          format: "json",
        }).toString();

        const response = await fetch(url, { headers: { "User-Agent": "weave-demo" } });
        const data = await response.json();
        const page = Object.values(data.query.pages)[0] as { title: string; extract: string };
        return { title: page.title, extract: page.extract };
      },
    });

    async function main() {
      await weave.init("<your-team>/<your-project-name>");

      const agent = new LlmAgent({
        name: "research_assistant",
        description: "Answers research questions using Wikipedia.",
        instruction:
          "You are a research assistant. Use the wikipedia_search tool to look up " +
          "topics when needed, and cite the article titles you used.",
        model: new Gemini({ model: "gemini-2.5-flash", apiKey: GEMINI_API_KEY }),
        tools: [wikipediaSearchTool],
      });

      const APP_NAME = "weave-adk-example";
      const USER_ID = "example-user";

      const runner = new InMemoryRunner({
        agent,
        appName: APP_NAME,
        plugins: [new WeaveAdkPlugin()],
      });
      const session = await runner.sessionService.createSession({
        appName: APP_NAME,
        userId: USER_ID,
      });

      const questions = [
        "Who founded Anthropic?",
        "What is Claude (the AI assistant)?",
        "Summarize what we discussed in one sentence.",
      ];

      for (const question of questions) {
        console.log(`USER: ${question}`);
        for await (const event of runner.runAsync({
          userId: USER_ID,
          sessionId: session.id,
          newMessage: {
            role: "user",
            parts: [{ text: question }],
          },
        })) {
          const text = event.content?.parts
            ?.map(part => part.text)
            .filter(Boolean)
            .join("");
          if (text) {
            console.log(`AGENT: ${text}\n`);
          }
        }
      }

      await weave.flushOTel();
    }

    main().catch(console.error);
    ```

    이 예시는 하나의 ADK 세션에서 세 개의 턴을 실행합니다. 처음 두 턴에서는 Wikipedia 조회가 트리거되고, 세 번째 턴에서는 도구 Call 없이 이전 대화 컨텍스트를 활용해 요약을 생성합니다.
  </Tab>
</Tabs>

<h3 id="see-your-agent-traces-in-the-agents-view">
  Agents 뷰에서 에이전트 트레이스 확인하기
</h3>

스크립트가 실행되면 `weave.init()`이 프로젝트 링크를 출력합니다. **Agents** 뷰를 열어 다음을 확인하세요:

* 대화의 턴을 포함하는 세션.
* 중첩된 `chat` 및 `execute_tool` 하위 항목이 있는 `invoke_agent` span으로 표시되는 각 턴.
* 각 단계의 전체 입력, 모델, 출력, 토큰 사용량 및 도구 결과.

Weave에서 Agents 데이터를 확인하는 방법에 대한 자세한 내용은 [에이전트 활동 확인하기](/ko/products/wandb/weave/guides/tracking/view-agent-activity)를 참조하세요.
