Skip to content

Instantly share code, notes, and snippets.

@enakai00
Created February 17, 2026 21:13
Show Gist options
  • Select an option

  • Save enakai00/a80bf3a8106a17cafeecd93881ce4784 to your computer and use it in GitHub Desktop.

Select an option

Save enakai00/a80bf3a8106a17cafeecd93881ce4784 to your computer and use it in GitHub Desktop.
Gemini Enterprise UI から利用する際に画像が2回表示される問題を回避する方法

本文中の「ADK エージェントの定義」にある下記の部分のコードを修正します。

また、このエージェントを実行するための AdkApp オブジェクトを次のように定義します。

def artifact_builder():
    return GcsArtifactService(bucket_name=BUCKET_NAME)

adk_app = AdkApp(
    agent=root_agent,
    app_name='smartphone_maps_qa_app',
    artifact_service_builder=artifact_builder,
)

上記のコードを次の内容に置き換えてください。

from google.adk.plugins import BasePlugin

class GcsArtifactPlugin(BasePlugin):
    def __init__(self):
        super().__init__(name='GcsArtifactPlugin')

    async def before_agent_callback(
            self, *, agent, callback_context
    ):
        callback_context._invocation_context.artifact_service = GcsArtifactService(
            bucket_name=BUCKET_NAME
        )
        return None

def artifact_builder():
    return GcsArtifactService(bucket_name=BUCKET_NAME)

adk_app = AdkApp(
    agent=root_agent,
    app_name='smartphone_maps_qa_app',
    artifact_service_builder=artifact_builder,
    plugins=[GcsArtifactPlugin()],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment