<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>hyunsoo's blog</title>
    <link>https://note24432.tistory.com/</link>
    <description>Seoul nationl university college of liberal studies 
( double majoring in economics, computer science )</description>
    <language>ko</language>
    <pubDate>Thu, 15 Oct 2026 19:30:32 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>hyunsoo CHUNG</managingEditor>
    <image>
      <title>hyunsoo's blog</title>
      <url>https://tistory1.daumcdn.net/tistory/8323430/attach/e4b53d03e2954b4898cf669ae3f8f31b</url>
      <link>https://note24432.tistory.com</link>
    </image>
    <item>
      <title>Google ADK: Youtube shorts maker(1)- full code and agent pipleline</title>
      <link>https://note24432.tistory.com/36</link>
      <description>&lt;p&gt;agent pipline&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1078&quot; data-origin-height=&quot;332&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/Ejeaz/dJMcaivbGN9/GE5ozDAgu2DluIuhpnAkQk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/Ejeaz/dJMcaivbGN9/GE5ozDAgu2DluIuhpnAkQk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/Ejeaz/dJMcaivbGN9/GE5ozDAgu2DluIuhpnAkQk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FEjeaz%2FdJMcaivbGN9%2FGE5ozDAgu2DluIuhpnAkQk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1078&quot; height=&quot;332&quot; data-origin-width=&quot;1078&quot; data-origin-height=&quot;332&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1254&quot; data-origin-height=&quot;209&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/QJtZr/dJMcagRIcD1/o94mKqdvX9NGSUUn1osoI1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/QJtZr/dJMcagRIcD1/o94mKqdvX9NGSUUn1osoI1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/QJtZr/dJMcagRIcD1/o94mKqdvX9NGSUUn1osoI1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FQJtZr%2FdJMcagRIcD1%2Fo94mKqdvX9NGSUUn1osoI1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1254&quot; height=&quot;209&quot; data-origin-width=&quot;1254&quot; data-origin-height=&quot;209&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;full code&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;198&quot; data-origin-height=&quot;828&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/RqWoy/dJMcafSOQY0/JhLedxKt8wIFxOc1c17Hv1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/RqWoy/dJMcafSOQY0/JhLedxKt8wIFxOc1c17Hv1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/RqWoy/dJMcafSOQY0/JhLedxKt8wIFxOc1c17Hv1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FRqWoy%2FdJMcafSOQY0%2FJhLedxKt8wIFxOc1c17Hv1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;198&quot; height=&quot;828&quot; data-origin-width=&quot;198&quot; data-origin-height=&quot;828&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h1&gt;YouTube Shorts Maker - Complete Code Collection&lt;/h1&gt;
&lt;p&gt;This document contains all Python code files from the project, organized by file path for easy copy-paste.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/__init__.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from . import agent&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.genai import types
from google.adk.agents import Agent
from google.adk.tools.agent_tool import AgentTool
from google.adk.models.lite_llm import LiteLlm
from .sub_agents.content_planner.agent import content_planner_agent
from .sub_agents.asset_generator.agent import asset_generator_agent
from .sub_agents.video_assembler.agent import video_assembler_agent
from .prompt import SHORTS_PRODUCER_DESCRIPTION, SHORTS_PRODUCER_PROMPT
from google.adk.agents.callback_context import CallbackContext
from google.adk.models.llm_request import LlmRequest
from google.adk.models.llm_response import LlmResponse

MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)


def before_model_callback(
    callback_context: CallbackContext,
    llm_request: LlmRequest,
):
    history = llm_request.contents
    last_message = history[-1]
    if last_message.role == &amp;quot;user&amp;quot;:
        text = last_message.parts[0].text
        if &amp;quot;hummus&amp;quot; in text:
            return LlmResponse(
                content=types.Content(
                    parts=[
                        types.Part(text=&amp;quot;Sorry I can&amp;#39;t help with that.&amp;quot;),
                    ],
                    role=&amp;quot;model&amp;quot;,
                )
            )
    return None


shorts_producer_agent = Agent(
    name=&amp;quot;ShortsProducerAgent&amp;quot;,
    model=MODEL,
    description=SHORTS_PRODUCER_DESCRIPTION,
    instruction=SHORTS_PRODUCER_PROMPT,
    tools=[
        AgentTool(agent=content_planner_agent),
        AgentTool(agent=asset_generator_agent),
        AgentTool(agent=video_assembler_agent),
    ],
    before_model_callback=before_model_callback,
)

root_agent = shorts_producer_agent&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;SHORTS_PRODUCER_DESCRIPTION = (
    &amp;quot;Primary orchestrator for creating vertical YouTube Shorts videos (9:16 portrait format) through a 5-phase workflow. &amp;quot;
    &amp;quot;Guides users through requirements gathering, coordinates specialized sub-agents in sequence &amp;quot;
    &amp;quot;(ContentPlanner → AssetGenerator → VideoAssembler), provides progress updates, &amp;quot;
    &amp;quot;handles error recovery, and delivers the final vertical MP4 video file.&amp;quot;
)

SHORTS_PRODUCER_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the ShortsProducerAgent, the primary orchestrator for creating vertical YouTube Shorts videos (9:16 portrait format).

## Your Workflow:
1. **Phase 1**: Greet user and gather requirements
2. **Phase 2**: Use ContentPlannerAgent to create structured script
3. **Phase 3**: Use AssetGeneratorAgent to generate images and audio in parallel
4. **Phase 4**: Use VideoAssemblerAgent to assemble final MP4 video
5. **Phase 5**: Present final result to user

## Important Guidelines:
- Always use agents in sequence: ContentPlanner → AssetGenerator → VideoAssembler
- Provide progress updates and handle errors gracefully
- Maintain a helpful and professional tone throughout

Begin by greeting the user and asking about their YouTube Short requirements.
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/content_planner/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from .prompt import CONTENT_PLANNER_DESCRIPTION, CONTENT_PLANNER_PROMPT
from pydantic import BaseModel, Field
from typing import List


class SceneOutput(BaseModel):
    id: int = Field(description=&amp;quot;Scene ID number&amp;quot;)
    narration: str = Field(description=&amp;quot;Narration text for the scene&amp;quot;)
    visual_description: str = Field(
        description=&amp;quot;Detailed description for image generation&amp;quot;
    )
    embedded_text: str = Field(
        description=&amp;quot;Text overlay for the image (can be any case/style)&amp;quot;
    )
    embedded_text_location: str = Field(
        description=&amp;quot;Where to position the text on the image (e.g., &amp;#39;top center&amp;#39;, &amp;#39;bottom left&amp;#39;, &amp;#39;middle right&amp;#39;, &amp;#39;center&amp;#39;)&amp;quot;
    )
    duration: int = Field(description=&amp;quot;Duration in seconds for this scene&amp;quot;)


class ContentPlanOutput(BaseModel):
    topic: str = Field(description=&amp;quot;The topic of the YouTube Short&amp;quot;)
    total_duration: int = Field(description=&amp;quot;Total video duration in seconds (max 20)&amp;quot;)
    scenes: List[SceneOutput] = Field(
        description=&amp;quot;List of scenes (agent decides how many)&amp;quot;
    )


MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)

content_planner_agent = Agent(
    name=&amp;quot;ContentPlannerAgent&amp;quot;,
    description=CONTENT_PLANNER_DESCRIPTION,
    instruction=CONTENT_PLANNER_PROMPT,
    model=MODEL,
    output_schema=ContentPlanOutput,
    output_key=&amp;quot;content_planner_output&amp;quot;,
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/content_planner/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;CONTENT_PLANNER_DESCRIPTION = (
    &amp;quot;Creates complete structured content plan for vertical YouTube Shorts videos (9:16 portrait format) in one step. &amp;quot;
    &amp;quot;Analyzes topic for key teaching points, determines optimal number of scenes and timing, &amp;quot;
    &amp;quot;generates narration text for each scene, designs vertical visual descriptions, &amp;quot;
    &amp;quot;and plans embedded text overlays. Outputs structured JSON format with max 20 seconds total.&amp;quot;
)

CONTENT_PLANNER_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the ContentPlannerAgent, responsible for creating complete structured content plans for vertical YouTube Shorts videos (9:16 portrait format).

## Your Task:
Given a topic from the user, create a comprehensive vertical YouTube Shorts script (9:16 portrait format) with a MAXIMUM of 20 seconds total duration.

## Output Format:
Return a valid JSON object with this structure:
{
  &amp;quot;topic&amp;quot;: &amp;quot;[the provided topic]&amp;quot;,
  &amp;quot;total_duration&amp;quot;: &amp;quot;[sum of all scene durations - MUST be ≤ 20]&amp;quot;,
  &amp;quot;scenes&amp;quot;: [
    {
      &amp;quot;id&amp;quot;: 1,
      &amp;quot;narration&amp;quot;: &amp;quot;[narration text matching scene duration]&amp;quot;,
      &amp;quot;visual_description&amp;quot;: &amp;quot;[description for image generation]&amp;quot;,
      &amp;quot;embedded_text&amp;quot;: &amp;quot;[text overlay for image]&amp;quot;,
      &amp;quot;embedded_text_location&amp;quot;: &amp;quot;[position: top center, bottom left, etc.]&amp;quot;,
      &amp;quot;duration&amp;quot;: &amp;quot;[seconds for this scene]&amp;quot;
    }
  ]
}

## Guidelines:
- **CRITICAL**: Total duration MUST NOT exceed 20 seconds
- Scene count: 3-6 scenes typically work best
- Narration: Match word count to scene duration (2-3 words per second)
- Visual descriptions: Be specific for vertical image generation
- Embedded text: 2-8 words max, attention-grabbing, NO emojis

Return only the JSON object, no additional text.
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import ParallelAgent
from .prompt import ASSET_GENERATOR_DESCRIPTION
from .image_generator.agent import image_generator_agent
from .voice_generator.agent import voice_generator_agent

asset_generator_agent = ParallelAgent(
    name=&amp;quot;AssetGeneratorAgent&amp;quot;,
    description=ASSET_GENERATOR_DESCRIPTION,
    sub_agents=[
        image_generator_agent,
        voice_generator_agent,
    ],
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;ASSET_GENERATOR_DESCRIPTION = (
    &amp;quot;Creates multimedia assets for vertical YouTube Shorts (9:16 portrait format) through parallel processing. Should ONLY be used after &amp;quot;
    &amp;quot;ContentPlannerAgent has completed and provided the structured script. &amp;quot;
    &amp;quot;Runs ImageGeneratorAgent (for vertical visual assets with embedded text) and VoiceGeneratorAgent &amp;quot;
    &amp;quot;(for narration audio) simultaneously to generate all required media assets.&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import SequentialAgent
from .prompt_builder.agent import prompt_builder_agent
from .image_builder.agent import image_builder_agent

image_generator_agent = SequentialAgent(
    name=&amp;quot;ImageGeneratorAgent&amp;quot;,
    sub_agents=[
        prompt_builder_agent,
        image_builder_agent,
    ],
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/prompt_builder/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from .prompt import PROMPT_BUILDER_DESCRIPTION, PROMPT_BUILDER_PROMPT
from pydantic import BaseModel, Field
from typing import List

MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)


class OptimizedPrompt(BaseModel):
    scene_id: int = Field(description=&amp;quot;Scene ID from the original content plan&amp;quot;)
    enhanced_prompt: str = Field(
        description=&amp;quot;Detailed prompt with technical specs and text overlay instructions for vertical YouTube Shorts&amp;quot;
    )


class PromptBuilderOutput(BaseModel):
    optimized_prompts: List[OptimizedPrompt] = Field(
        description=&amp;quot;Array of optimized image generation prompts for vertical YouTube Shorts&amp;quot;
    )


prompt_builder_agent = Agent(
    name=&amp;quot;PromptBuilderAgent&amp;quot;,
    description=PROMPT_BUILDER_DESCRIPTION,
    instruction=PROMPT_BUILDER_PROMPT,
    model=MODEL,
    output_schema=PromptBuilderOutput,
    output_key=&amp;quot;prompt_builder_output&amp;quot;,
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/prompt_builder/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;PROMPT_BUILDER_DESCRIPTION = (
    &amp;quot;Analyzes visual descriptions from the content plan, adds technical specifications for vertical YouTube Shorts &amp;quot;
    &amp;quot;(9:16 portrait aspect ratio, 1080x1920), embeds text overlay instructions with positioning, &amp;quot;
    &amp;quot;and optimizes prompts for GPT-Image-1 model. Outputs array of optimized vertical image generation prompts.&amp;quot;
)

PROMPT_BUILDER_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the PromptBuilderAgent, responsible for transforming scene visual descriptions into optimized prompts for vertical YouTube Shorts image generation (9:16 portrait format).

## Your Task:
Take the structured content plan: {content_planner_output} and create optimized vertical image generation prompts for each scene.

## Input:
You will receive the content plan with scenes containing:
- visual_description: Basic description of what should be in the image
- embedded_text: Text that needs to be overlaid on the image
- embedded_text_location: Where the text should be positioned

## Process:
For each scene:
1. Analyze the visual description and enhance it with specific details
2. Add technical specifications: &amp;quot;9:16 portrait aspect ratio, 1080x1920 resolution, vertical composition&amp;quot;
3. Include embedded text instructions with precise positioning
4. Optimize for GPT-Image-1 model with style and quality keywords

## Output Format:
Return a JSON object:
{
  &amp;quot;optimized_prompts&amp;quot;: [
    {
      &amp;quot;scene_id&amp;quot;: 1,
      &amp;quot;enhanced_prompt&amp;quot;: &amp;quot;[detailed prompt with technical specs and text overlay instructions]&amp;quot;
    }
  ]
}

## Guidelines:
- Always include technical specs: &amp;quot;9:16 portrait aspect ratio, 1080x1920 resolution, vertical composition, high quality, professional, YouTube Shorts format&amp;quot;
- Text overlay: Include &amp;quot;with bold, readable text &amp;#39;[TEXT]&amp;#39; positioned at [POSITION], with generous padding from borders&amp;quot;
- Style consistency: Maintain the same visual style, tone, and lighting across ALL prompts
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/image_builder/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from .prompt import IMAGE_BUILDER_DESCRIPTION, IMAGE_BUILDER_PROMPT
from .tools import generate_images

MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)

image_builder_agent = Agent(
    name=&amp;quot;ImageBuilder&amp;quot;,
    description=IMAGE_BUILDER_DESCRIPTION,
    instruction=IMAGE_BUILDER_PROMPT,
    model=MODEL,
    output_key=&amp;quot;image_builder_output&amp;quot;,
    tools=[
        generate_images,
    ],
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/image_builder/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;IMAGE_BUILDER_DESCRIPTION = (
    &amp;quot;Loops through each optimized prompt from PromptBuilderAgent, calls OpenAI GPT-Image-1 API &amp;quot;
    &amp;quot;to generate vertical YouTube Shorts images (9:16 portrait format), downloads and saves images&amp;quot;
    &amp;quot;Outputs array of generated image files with metadata.&amp;quot;
)

IMAGE_BUILDER_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the ImageBuilderAgent, responsible for generating vertical images for YouTube Shorts using OpenAI&amp;#39;s GPT-Image-1 API.

## Your Task:
Generate vertical images for each scene using the optimized prompts from the previous agent.

## Process:
1. Use the generate_images tool to process all optimized prompts
2. Validate results and ensure all images are properly generated
3. Return metadata about the generated images

The tool will access optimized prompts containing:
- scene_id: Scene identifier from the content plan
- enhanced_prompt: Detailed prompt optimized for vertical YouTube Shorts generation
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/image_generator/image_builder/tools.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import base64
from google.genai import types
from openai import OpenAI
from google.adk.tools.tool_context import ToolContext

client = OpenAI()


async def generate_images(tool_context: ToolContext):

    prompt_builder_output = tool_context.state.get(&amp;quot;prompt_builder_output&amp;quot;)
    optimized_prompts = prompt_builder_output.get(&amp;quot;optimized_prompts&amp;quot;)

    existing_artifacts = await tool_context.list_artifacts()

    generated_images = []

    for prompt in optimized_prompts:
        scene_id = prompt.get(&amp;quot;scene_id&amp;quot;)
        enhanced_prompt = prompt.get(&amp;quot;enhanced_prompt&amp;quot;)
        filename = f&amp;quot;scene_{scene_id}_image.jpeg&amp;quot;

        if filename in existing_artifacts:
            generated_images.append(
                {
                    &amp;quot;scene_id&amp;quot;: scene_id,
                    &amp;quot;prompt&amp;quot;: enhanced_prompt[:100],
                    &amp;quot;filename&amp;quot;: filename,
                }
            )
            continue

        image = client.images.generate(
            model=&amp;quot;gpt-image-1&amp;quot;,
            prompt=enhanced_prompt,
            n=1,
            quality=&amp;quot;low&amp;quot;,
            moderation=&amp;quot;low&amp;quot;,
            output_format=&amp;quot;jpeg&amp;quot;,
            background=&amp;quot;opaque&amp;quot;,
            size=&amp;quot;1024x1536&amp;quot;,
        )

        image_bytes = base64.b64decode(image.data[0].b64_json)

        artifact = types.Part(
            inline_data=types.Blob(
                mime_type=&amp;quot;image/jpeg&amp;quot;,
                data=image_bytes,
            )
        )

        await tool_context.save_artifact(
            filename=filename,
            artifact=artifact,
        )

        generated_images.append(
            {
                &amp;quot;scene_id&amp;quot;: scene_id,
                &amp;quot;prompt&amp;quot;: enhanced_prompt[:100],
                &amp;quot;filename&amp;quot;: filename,
            }
        )

    return {
        &amp;quot;total_images&amp;quot;: len(generated_images),
        &amp;quot;generated_images&amp;quot;: generated_images,
        &amp;quot;status&amp;quot;: &amp;quot;complete&amp;quot;,
    }&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/voice_generator/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from .prompt import VOICE_GENERATOR_PROMPT, VOICE_GENERATOR_DESCRIPTION
from .tools import generate_narrations

MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)

voice_generator_agent = Agent(
    name=&amp;quot;VoiceGeneratorAgent&amp;quot;,
    description=VOICE_GENERATOR_DESCRIPTION,
    instruction=VOICE_GENERATOR_PROMPT,
    model=MODEL,
    tools=[
        generate_narrations,
    ],
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/voice_generator/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;VOICE_GENERATOR_DESCRIPTION = &amp;quot;Generates high-quality narration audio for vertical YouTube Shorts using OpenAI TTS API.&amp;quot;

VOICE_GENERATOR_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the VoiceGeneratorAgent, responsible for generating narration audio for YouTube Shorts using OpenAI&amp;#39;s Text-to-Speech API.

## Content Plan:
{content_planner_output}

## Process:
1. Analyze the content plan to understand the topic, mood, and each scene&amp;#39;s narration text
2. Select the best voice from OpenAI&amp;#39;s options based on content mood:
   - **alloy**: Neutral, balanced tone
   - **echo**: Calm, soothing
   - **fable**: Warm, engaging for storytelling
   - **onyx**: Deep, authoritative
   - **nova**: Energetic, youthful
   - **shimmer**: Soft, gentle

3. Call the generate_narrations tool with:
   - Your selected voice
   - A list of dictionaries for each scene with:
     - input: the exact text to speak
     - instructions: combined instruction for speed and tone based on scene duration
     - scene_id: the scene number

## Voice Selection Guidelines:
- Cooking/Food: Use &amp;quot;fable&amp;quot; for warm, engaging instruction
- Fitness/Energy: Use &amp;quot;nova&amp;quot; for energetic, motivating tone
- Educational: Use &amp;quot;alloy&amp;quot; for clear, neutral delivery
- Professional/Business: Use &amp;quot;onyx&amp;quot; for authoritative tone

Extract narration text exactly from each scene in the content plan as &amp;quot;input&amp;quot;.
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/asset_generator/voice_generator/tools.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.genai import types
from openai import OpenAI
from google.adk.tools.tool_context import ToolContext
from typing import List, Dict, Any

client = OpenAI()


async def generate_narrations(
    tool_context: ToolContext, voice: str, voice_instructions: List[Dict[str, Any]]
):
    &amp;quot;&amp;quot;&amp;quot;
    Generate narration audio for each scene using OpenAI TTS API

    Args:
        tool_context: Tool context to access artifacts and save files
        voice: Selected voice for TTS (alloy, echo, fable, onyx, nova, shimmer)
        voice_instructions: List of dictionaries containing narration instructions for each scene

    Returns:
        Information about all generated audio files
    &amp;quot;&amp;quot;&amp;quot;

    existing_artifacts = await tool_context.list_artifacts()

    generated_narrations = []

    for instruction in voice_instructions:
        text_input = instruction.get(&amp;quot;input&amp;quot;)
        instructions = instruction.get(&amp;quot;instructions&amp;quot;)
        scene_id = instruction.get(&amp;quot;scene_id&amp;quot;)
        filename = f&amp;quot;scene_{scene_id}_narration.mp3&amp;quot;

        if filename in existing_artifacts:
            generated_narrations.append(
                {
                    &amp;quot;scene_id&amp;quot;: scene_id,
                    &amp;quot;filename&amp;quot;: filename,
                    &amp;quot;input&amp;quot;: text_input,
                    &amp;quot;instructions&amp;quot;: instructions[:50],
                }
            )
            continue

        with client.audio.speech.with_streaming_response.create(
            model=&amp;quot;gpt-4o-mini-tts&amp;quot;,
            voice=voice,
            input=text_input,
            instructions=instructions,
        ) as response:

            audio_data = response.read()

        artifact = types.Part(
            inline_data=types.Blob(mime_type=&amp;quot;audio/mpeg&amp;quot;, data=audio_data)
        )

        await tool_context.save_artifact(filename=filename, artifact=artifact)

        generated_narrations.append(
            {
                &amp;quot;scene_id&amp;quot;: scene_id,
                &amp;quot;filename&amp;quot;: filename,
                &amp;quot;input&amp;quot;: text_input,
                &amp;quot;instructions&amp;quot;: instructions[:50],
            }
        )

    return {
        &amp;quot;total_narrations&amp;quot;: len(generated_narrations),
        &amp;quot;generated_narrations&amp;quot;: generated_narrations,
        &amp;quot;status&amp;quot;: &amp;quot;complete&amp;quot;,
    }&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/video_assembler/agent.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from .prompt import VIDEO_ASSEMBLER_DESCRIPTION, VIDEO_ASSEMBLER_PROMPT
from .tools import assemble_video

MODEL = LiteLlm(model=&amp;quot;openai/gpt-4o&amp;quot;)

video_assembler_agent = Agent(
    name=&amp;quot;VideoAssemblerAgent&amp;quot;,
    model=MODEL,
    description=VIDEO_ASSEMBLER_DESCRIPTION,
    instruction=VIDEO_ASSEMBLER_PROMPT,
    output_key=&amp;quot;video_assembler_output&amp;quot;,
    tools=[
        assemble_video,
    ],
)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/video_assembler/prompt.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;VIDEO_ASSEMBLER_DESCRIPTION = (
    &amp;quot;Final step agent that assembles generated image and audio artifacts into a complete vertical YouTube Shorts video. &amp;quot;
    &amp;quot;Should be used ONLY after both image generation and voice generation are complete and all scene assets exist as artifacts. &amp;quot;
    &amp;quot;Reads content plan timing, locates all media artifacts, and executes video assembly to produce final MP4 output.&amp;quot;
)

VIDEO_ASSEMBLER_PROMPT = &amp;quot;&amp;quot;&amp;quot;
You are the VideoAssemblerAgent, responsible for creating the final YouTube Shorts video from generated assets.

## Your Task:
Use the assemble_video tool to create the final vertical YouTube Shorts video from all the generated image and audio artifacts.

## Process:
1. Call the assemble_video tool
2. The tool will automatically:
   - Read the content plan timing from context
   - Locate all image and audio artifacts
   - Execute FFmpeg assembly with proper vertical formatting
   - Create the final MP4 video

## Important:
- Only use this agent after all images and audio files have been generated
- The tool handles all technical details including timing, formatting, and FFmpeg execution
- Report the results of the video assembly process
&amp;quot;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;code&gt;youtube_shorts_maker/sub_agents/video_assembler/tools.py&lt;/code&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;&amp;quot;&amp;quot;&amp;quot;Tools for VideoAssemblerAgent&amp;quot;&amp;quot;&amp;quot;

import subprocess
import re
import tempfile
import os
from google.adk.tools.tool_context import ToolContext
import google.genai.types as types


async def assemble_video(tool_context: ToolContext) -&amp;gt; str:
    &amp;quot;&amp;quot;&amp;quot;Assemble final YouTube Shorts video from image and audio artifacts

    Args:
        tool_context: Tool context to access state and artifacts

    Returns:
        Information about the video assembly process
    &amp;quot;&amp;quot;&amp;quot;
    temp_files = []  # Track temporary files for cleanup

    try:
        # Read content plan from context
        content_planner_output = tool_context.state.get(&amp;quot;content_planner_output&amp;quot;, {})
        scenes = content_planner_output.get(&amp;quot;scenes&amp;quot;, [])

        if not scenes:
            return &amp;quot;No scenes found in content plan&amp;quot;

        print(f&amp;quot;  VIDEO ASSEMBLER: Starting assembly for {len(scenes)} scenes&amp;quot;)

        # List all available artifacts
        existing_artifacts = await tool_context.list_artifacts()

        # Find image and audio files
        image_files = []
        audio_files = []

        for artifact_name in existing_artifacts:
            if artifact_name.startswith(&amp;quot;scene_&amp;quot;) and artifact_name.endswith(
                &amp;quot;_image.jpeg&amp;quot;
            ):
                image_files.append(artifact_name)
            elif artifact_name.startswith(&amp;quot;scene_&amp;quot;) and artifact_name.endswith(
                &amp;quot;_narration.mp3&amp;quot;
            ):
                audio_files.append(artifact_name)

        # Sort by scene number
        def extract_scene_number(filename):
            match = re.search(r&amp;quot;scene_(\d+)_&amp;quot;, filename)
            return int(match.group(1)) if match else 0

        image_files.sort(key=extract_scene_number)
        audio_files.sort(key=extract_scene_number)

        print(f&amp;quot; ️ Found {len(image_files)} image artifacts&amp;quot;)
        print(f&amp;quot;  Found {len(audio_files)} audio artifacts&amp;quot;)

        if len(image_files) != len(scenes) or len(audio_files) != len(scenes):
            return f&amp;quot;Missing artifacts: Expected {len(scenes)} images and audio files, found {len(image_files)} images and {len(audio_files)} audio files&amp;quot;

        # Load artifacts and create temporary files
        temp_image_paths = []
        temp_audio_paths = []

        for i, (image_name, audio_name) in enumerate(zip(image_files, audio_files)):
            # Load and save image artifact
            print(f&amp;quot;  Loading image artifact: {image_name}&amp;quot;)
            image_artifact = await tool_context.load_artifact(filename=image_name)
            if image_artifact and image_artifact.inline_data:
                temp_image = tempfile.NamedTemporaryFile(suffix=&amp;quot;.jpeg&amp;quot;, delete=False)
                temp_image.write(image_artifact.inline_data.data)
                temp_image.close()
                temp_image_paths.append(temp_image.name)
                temp_files.append(temp_image.name)
                print(f&amp;quot;  Created temp image: {temp_image.name}&amp;quot;)
            else:
                return f&amp;quot;Failed to load image artifact: {image_name}&amp;quot;

            # Load and save audio artifact
            print(f&amp;quot;  Loading audio artifact: {audio_name}&amp;quot;)
            audio_artifact = await tool_context.load_artifact(filename=audio_name)
            if audio_artifact and audio_artifact.inline_data:
                temp_audio = tempfile.NamedTemporaryFile(suffix=&amp;quot;.mp3&amp;quot;, delete=False)
                temp_audio.write(audio_artifact.inline_data.data)
                temp_audio.close()
                temp_audio_paths.append(temp_audio.name)
                temp_files.append(temp_audio.name)
                print(f&amp;quot;  Created temp audio: {temp_audio.name}&amp;quot;)
            else:
                return f&amp;quot;Failed to load audio artifact: {audio_name}&amp;quot;

        # Build FFmpeg command with temporary file paths
        input_args = []
        filter_parts = []

        # Add inputs for each scene
        for i, (temp_image, temp_audio) in enumerate(
            zip(temp_image_paths, temp_audio_paths)
        ):
            input_args.extend([&amp;quot;-i&amp;quot;, temp_image, &amp;quot;-i&amp;quot;, temp_audio])

            # Get scene duration from content plan
            scene_duration = scenes[i].get(&amp;quot;duration&amp;quot;, 4)  # fallback to 4 seconds

            # Create video stream that displays image for scene duration
            total_frames = int(30 * scene_duration)  # 30fps * duration in seconds
            filter_parts.append(
                f&amp;quot;[{i*2}:v]scale=1080:1920:force_original_aspect_ratio=decrease,&amp;quot;
                f&amp;quot;pad=1080:1920:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=30,&amp;quot;
                f&amp;quot;loop={total_frames-1}:size=1:start=0[v{i}]&amp;quot;
            )

            # Keep audio as-is
            filter_parts.append(f&amp;quot;[{i*2+1}:a]anull[a{i}]&amp;quot;)

        # Concatenate all video and audio streams
        video_inputs = &amp;quot;&amp;quot;.join([f&amp;quot;[v{i}]&amp;quot; for i in range(len(scenes))])
        audio_inputs = &amp;quot;&amp;quot;.join([f&amp;quot;[a{i}]&amp;quot; for i in range(len(scenes))])
        filter_parts.append(f&amp;quot;{video_inputs}concat=n={len(scenes)}:v=1:a=0[outv]&amp;quot;)
        filter_parts.append(f&amp;quot;{audio_inputs}concat=n={len(scenes)}:v=0:a=1[outa]&amp;quot;)

        # Create temporary output file
        temp_output = tempfile.NamedTemporaryFile(suffix=&amp;quot;.mp4&amp;quot;, delete=False)
        temp_output.close()
        output_path = temp_output.name
        temp_files.append(output_path)

        # Build final FFmpeg command
        ffmpeg_cmd = (
            [&amp;quot;ffmpeg&amp;quot;, &amp;quot;-y&amp;quot;]
            + input_args
            + [
                &amp;quot;-filter_complex&amp;quot;,
                &amp;quot;;&amp;quot;.join(filter_parts),
                &amp;quot;-map&amp;quot;,
                &amp;quot;[outv]&amp;quot;,
                &amp;quot;-map&amp;quot;,
                &amp;quot;[outa]&amp;quot;,
                &amp;quot;-c:v&amp;quot;,
                &amp;quot;libx264&amp;quot;,
                &amp;quot;-c:a&amp;quot;,
                &amp;quot;aac&amp;quot;,
                &amp;quot;-pix_fmt&amp;quot;,
                &amp;quot;yuv420p&amp;quot;,
                &amp;quot;-r&amp;quot;,
                &amp;quot;30&amp;quot;,
                output_path,
            ]
        )

        print(&amp;quot;  Executing FFmpeg command...&amp;quot;)
        print(&amp;quot; &amp;quot;.join(ffmpeg_cmd))

        # Execute FFmpeg
        subprocess.run(ffmpeg_cmd, capture_output=True, text=True, check=True)

        # Save final video as artifact
        with open(output_path, &amp;quot;rb&amp;quot;) as f:
            video_data = f.read()

        artifact = types.Part(
            inline_data=types.Blob(mime_type=&amp;quot;video/mp4&amp;quot;, data=video_data)
        )

        await tool_context.save_artifact(
            filename=&amp;quot;youtube_short_final.mp4&amp;quot;, artifact=artifact
        )

        total_duration = sum(scene.get(&amp;quot;duration&amp;quot;, 4) for scene in scenes)

        result_info = {
            &amp;quot;status&amp;quot;: &amp;quot;success&amp;quot;,
            &amp;quot;scenes_processed&amp;quot;: len(scenes),
            &amp;quot;total_duration&amp;quot;: total_duration,
            &amp;quot;output_file&amp;quot;: &amp;quot;youtube_short_final.mp4&amp;quot;,
            &amp;quot;resolution&amp;quot;: &amp;quot;1080x1920&amp;quot;,
            &amp;quot;format&amp;quot;: &amp;quot;MP4 (H.264/AAC)&amp;quot;,
        }

        print(f&amp;quot;✅ Video assembly complete! Created {total_duration}s YouTube Short&amp;quot;)
        return str(result_info)

    except subprocess.CalledProcessError as e:
        error_info = {
            &amp;quot;status&amp;quot;: &amp;quot;ffmpeg_error&amp;quot;,
            &amp;quot;error_message&amp;quot;: str(e),
            &amp;quot;stderr&amp;quot;: e.stderr,
            &amp;quot;stdout&amp;quot;: e.stdout,
        }
        print(f&amp;quot;❌ FFmpeg failed: {e.stderr}&amp;quot;)
        return str(error_info)

    except Exception as e:
        error_info = {&amp;quot;status&amp;quot;: &amp;quot;error&amp;quot;, &amp;quot;error_message&amp;quot;: str(e)}
        print(f&amp;quot;❌ Video assembly failed: {str(e)}&amp;quot;)
        return str(error_info)

    finally:
        # Clean up temporary files
        for temp_file in temp_files:
            try:
                if os.path.exists(temp_file):
                    os.unlink(temp_file)
                    print(f&amp;quot; ️ Cleaned up temp file: {temp_file}&amp;quot;)
            except Exception as e:
                print(f&amp;quot;⚠️ Failed to cleanup {temp_file}: {e}&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;This collection includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;19 Python files&lt;/strong&gt; organized by file path&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agent definitions&lt;/strong&gt; with Pydantic schemas&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tool implementations&lt;/strong&gt; using ToolContext&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prompt files&lt;/strong&gt; condensed to essential context and core instructions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Callback implementation&lt;/strong&gt; example&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All code is ready for copy-paste into blog posts or documentation.&lt;/p&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/36</guid>
      <comments>https://note24432.tistory.com/36#entry36comment</comments>
      <pubDate>Mon, 5 Jan 2026 16:59:57 +0900</pubDate>
    </item>
    <item>
      <title>Google ADK: Financial Advisor(4)- state, artifact, toolcontext</title>
      <link>https://note24432.tistory.com/35</link>
      <description>&lt;div&gt;
&lt;div id=&quot;model-response-message-contentr_97d235b19a019387&quot;&gt;
&lt;h1 data-path-to-node=&quot;2&quot;&gt;Step 6: Save Report (Optional)&lt;/h1&gt;
&lt;h3 data-path-to-node=&quot;3&quot; data-ke-size=&quot;size23&quot;&gt;6-1. Main Agent LLM Call #12 (Report Generation)&lt;/h3&gt;
&lt;p data-path-to-node=&quot;4&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;4&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API (LLM Response #12)&lt;/b&gt;:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;tool_calls&quot;: [
    {
      &quot;id&quot;: &quot;call_401&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;save_advice_report&quot;,
        &quot;arguments&quot;: &quot;{\&quot;summary\&quot;: \&quot;[Final Advice Text]\&quot;, \&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;6&quot; data-ke-size=&quot;size16&quot;&gt;&lt;i data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6&quot;&gt;Generator: OpenAI GPT-4o LLM (for Main Agent)&lt;/i&gt; &lt;i data-index-in-node=&quot;46&quot; data-path-to-node=&quot;6&quot;&gt;Receiver: Google ADK (Main Agent System)&lt;/i&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;7&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;7&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is the &lt;b data-index-in-node=&quot;47&quot; data-path-to-node=&quot;7&quot;&gt;result of the LLM deciding to save a report after generating the final advice&lt;/b&gt;.&lt;/p&gt;
&lt;p data-path-to-node=&quot;8&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;8&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;9&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9,0,0&quot;&gt;Report Save Trigger&lt;/b&gt;: Triggered because the user requested a report, or the LLM judged that saving a report was necessary.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9,1,0&quot;&gt;Process Conclusion&lt;/b&gt;: Permanently saves the results after all analysis and advice are complete.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9,2,0&quot;&gt;Tool Call&lt;/b&gt;: Calls the save_advice_report function to create the file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;10&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;11&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Google ADK calls the save_advice_report function.&lt;/li&gt;
&lt;li&gt;The function reads the results of all sub-agents from the state.&lt;/li&gt;
&lt;li&gt;The function creates a comprehensive report in Markdown format.&lt;/li&gt;
&lt;li&gt;The function saves it as an Artifact, storing it permanently in the file system.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;12&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;12&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;13&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13,0,0&quot;&gt;Permanent Preservation&lt;/b&gt;: The report remains as a file even after the session ends, allowing for future reference.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13,1,0&quot;&gt;User Experience&lt;/b&gt;: Provides a file that users can download or share.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13,2,0&quot;&gt;Full System Termination&lt;/b&gt;: All tasks are completed, and the system fully terminates.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;14&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;14&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;15&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;arguments contains summary and ticker. summary is the final advice text generated by the LLM.&lt;/li&gt;
&lt;li&gt;Why does the LLM decide to save the report? &amp;rarr; Although the prompt says &quot;use ONLY when user requests a report,&quot; the LLM may decide to do so based on the context.&lt;/li&gt;
&lt;li&gt;Why is all data in the state at this point? &amp;rarr; Because each sub-agent saved its results to the state using output_key.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;16&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h3 data-path-to-node=&quot;17&quot; data-ke-size=&quot;size23&quot;&gt;6-2. Report Saving Function Execution&lt;/h3&gt;
&lt;p data-path-to-node=&quot;18&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;18&quot;&gt;Function Execution&lt;/b&gt;: save_advice_report(tool_context, summary, &quot;AAPL&quot;)&lt;/p&gt;
&lt;p data-path-to-node=&quot;19&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19&quot;&gt;Python Function Execution (save_advice_report)&lt;/b&gt;:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;# Executing save_advice_report function in agent.py

# 1. Access State
state = tool_context.state  # Get state object from ToolContext

# 2. Read results of each sub-agent from State
data_analyst_result = state.get(&quot;data_analyst_result&quot;)           # Value saved via output_key=&quot;data_analyst_result&quot;
financial_analyst_result = state.get(&quot;financial_analyst_result&quot;) # Value saved via output_key=&quot;financial_analyst_result&quot;
news_analyst_result = state.get(&quot;news_analyst_analyst_result&quot;)   # Value saved via output_key=&quot;news_analyst_result&quot;

# State status at this point:
# {
#     &quot;data_analyst_result&quot;: &quot;**Company Overview:**\nApple Inc. ...&quot;,
#     &quot;financial_analyst_result&quot;: &quot;**Income Statement Analysis:**\nTotal Revenue ...&quot;,
#     &quot;news_analyst_result&quot;: &quot;**Recent News Analysis:**\n1. Strong Q4 Earnings ...&quot;
# }

# 3. Generate Comprehensive Report (Markdown String)
report = f&quot;&quot;&quot;
# Executive Summary and Advice:
{summary}

## Data Analyst Report:
{data_analyst_result}

## Financial Analyst Report:
{financial_analyst_result}

## News Analyst Report:
{news_analyst_result}
&quot;&quot;&quot;

# 4. Save to State as well (Optional - for future access)
state[&quot;report&quot;] = report

# 5. Generate Filename
filename = f&quot;{ticker}_investment_advice.md&quot;  # &quot;AAPL_investment_advice.md&quot;

# 6. Create Artifact Object
artifact = types.Part(
    inline_data=types.Blob(
        mime_type=&quot;text/markdown&quot;,  # Specify MIME type (Markdown file)
        data=report.encode(&quot;utf-8&quot;),  # Encode string to UTF-8 bytes
        # report.encode(&quot;utf-8&quot;) result: b'# Executive Summary...'
    )
)

# 7. Save Artifact (Async - Save to file system)
await tool_context.save_artifact(filename, artifact)
# &amp;rarr; Saved to path: .adk/artifacts/users/user/sessions/{session_id}/artifacts/AAPL_investment_advice.md/versions/0/

# 8. Function Return Value
return {&quot;success&quot;: True}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;21&quot; data-ke-size=&quot;size16&quot;&gt;&lt;i data-index-in-node=&quot;0&quot; data-path-to-node=&quot;21&quot;&gt;Generator: Python function save_advice_report&lt;/i&gt; &lt;i data-index-in-node=&quot;46&quot; data-path-to-node=&quot;21&quot;&gt;- Collect data from State (state.get())&lt;/i&gt; &lt;i data-index-in-node=&quot;86&quot; data-path-to-node=&quot;21&quot;&gt;- Create Artifact object (types.Part, types.Blob)&lt;/i&gt; &lt;i data-index-in-node=&quot;136&quot; data-path-to-node=&quot;21&quot;&gt;- Create file content (Markdown string)&lt;/i&gt; &lt;i data-index-in-node=&quot;176&quot; data-path-to-node=&quot;21&quot;&gt;Storage Location: Google ADK Artifact Storage&lt;/i&gt; &lt;i data-index-in-node=&quot;222&quot; data-path-to-node=&quot;21&quot;&gt;Storage Path: .adk/artifacts/users/{user_id}/sessions/{session_id}/artifacts/{filename}/versions/0/&lt;/i&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;22&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;22&quot;&gt;Result&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;23&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The AAPL_investment_advice.md file is created and stored in the Google ADK artifact storage.&lt;/li&gt;
&lt;li&gt;It is also saved in the State under the key state[&quot;report&quot;] (Optional).&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;24&quot; data-ke-size=&quot;size16&quot;&gt;&lt;i data-index-in-node=&quot;0&quot; data-path-to-node=&quot;24&quot;&gt;(For details on State and Artifacts, refer to the &quot;State Management System Detailed Description&quot; and &quot;Artifact System Detailed Description&quot; sections below)&lt;/i&gt;&lt;/p&gt;
&lt;hr data-path-to-node=&quot;25&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;26&quot; data-ke-size=&quot;size26&quot;&gt;Total LLM Call Summary&lt;/h2&gt;
&lt;p data-path-to-node=&quot;27&quot; data-ke-size=&quot;size16&quot;&gt;In this example, a total of &lt;b data-index-in-node=&quot;28&quot; data-path-to-node=&quot;27&quot;&gt;12 LLM calls&lt;/b&gt; occurred:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;28&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,0,0&quot;&gt;Main Agent LLM Call #1&lt;/b&gt;: Initial request analysis &amp;rarr; Decision to call data_analyst&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,1,0&quot;&gt;Data Analyst LLM Call #2&lt;/b&gt;: Decision to call tools (get_company_info, get_stock_price, get_financial_metrics)&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,2,0&quot;&gt;Data Analyst LLM Call #3&lt;/b&gt;: Generation of data analysis result text&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,3,0&quot;&gt;Main Agent LLM Call #4&lt;/b&gt;: Decision to call financial_analyst&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,4,0&quot;&gt;Financial Analyst LLM Call #5&lt;/b&gt;: Decision to call financial statement tools&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,5,0&quot;&gt;Financial Analyst LLM Call #6&lt;/b&gt;: Generation of financial statement analysis result text&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,6,0&quot;&gt;Main Agent LLM Call #7&lt;/b&gt;: Decision to call news_analyst&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,7,0&quot;&gt;News Analyst LLM Call #8&lt;/b&gt;: Decision to call web_search_tool&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,8,0&quot;&gt;News Analyst LLM Call #9&lt;/b&gt;: Generation of news analysis result text&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,9,0&quot;&gt;Main Agent LLM Call #10&lt;/b&gt;: Generation of user preference questions&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,10,0&quot;&gt;Main Agent LLM Call #11&lt;/b&gt;: Generation of final investment advice&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28,11,0&quot;&gt;Main Agent LLM Call #12&lt;/b&gt;: Decision to call report saving tool&lt;/li&gt;
&lt;/ol&gt;
&lt;hr data-path-to-node=&quot;29&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;30&quot; data-ke-size=&quot;size26&quot;&gt;ToolContext Detailed Description&lt;/h2&gt;
&lt;p data-path-to-node=&quot;31&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31&quot;&gt;ToolContext&lt;/b&gt; is a &lt;b data-index-in-node=&quot;17&quot; data-path-to-node=&quot;31&quot;&gt;context object automatically passed by Google ADK when calling a tool function&lt;/b&gt;. It provides information and functionality regarding the environment (context) in which the tool function is executed.&lt;/p&gt;
&lt;h3 data-path-to-node=&quot;32&quot; data-ke-size=&quot;size23&quot;&gt;Role of ToolContext&lt;/h3&gt;
&lt;p data-path-to-node=&quot;33&quot; data-ke-size=&quot;size16&quot;&gt;ToolContext performs the following important roles:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;34&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,0,0&quot;&gt;Provide State Access&lt;/b&gt;: Access session state via tool_context.state.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,1,0&quot;&gt;Artifact Saving Function&lt;/b&gt;: Save files via the tool_context.save_artifact() method.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,2,0&quot;&gt;Execution Context Information&lt;/b&gt;: Provide context information for the currently running tool function.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;35&quot; data-ke-size=&quot;size23&quot;&gt;How ToolContext is Passed&lt;/h3&gt;
&lt;p data-path-to-node=&quot;36&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;36&quot;&gt;Important&lt;/b&gt;: ToolContext is &lt;b data-index-in-node=&quot;26&quot; data-path-to-node=&quot;36&quot;&gt;automatically passed by Google ADK&lt;/b&gt;. Developers do not need to create or pass it manually.&lt;/p&gt;
&lt;p data-path-to-node=&quot;37&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;37&quot;&gt;When Defining Tool Functions&lt;/b&gt;: If you &lt;b data-index-in-node=&quot;37&quot; data-path-to-node=&quot;37&quot;&gt;specify ToolContext as the first parameter type&lt;/b&gt; when defining a tool function, Google ADK automatically passes it when the function is called:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;from google.adk.tools import ToolContext

# Specify ToolContext as the first parameter
async def save_advice_report(tool_context: ToolContext, summary: str, ticker: str):
    # tool_context is automatically passed by Google ADK
    state = tool_context.state  # Access State
    await tool_context.save_artifact(...)  # Save Artifact
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;39&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;39&quot;&gt;Google ADK Internal Operation&lt;/b&gt;:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;40&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;40,0,0&quot;&gt;LLM Decides to Call Tool Function&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;tool_calls&quot;: [{
    &quot;function&quot;: {
      &quot;name&quot;: &quot;save_advice_report&quot;,
      &quot;arguments&quot;: &quot;{\&quot;summary\&quot;: \&quot;...\&quot;, \&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
    }
  }]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;40,1,0&quot;&gt;Google ADK Calls Function&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;makefile&quot;&gt;&lt;code&gt;# Executed internally by Google ADK (Pseudocode)
tool_context = ToolContext(...)  # Google ADK creates ToolContext object
await save_advice_report(
    tool_context,  # &amp;larr; Passed automatically
    summary=&quot;...&quot;,  # Parameter decided by LLM
    ticker=&quot;AAPL&quot;   # Parameter decided by LLM
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;41&quot; data-ke-size=&quot;size23&quot;&gt;Major Properties and Methods of ToolContext&lt;/h3&gt;
&lt;h4 data-path-to-node=&quot;42&quot; data-ke-size=&quot;size20&quot;&gt;1. tool_context.state&lt;/h4&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;43&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,0,0&quot;&gt;Role&lt;/b&gt;: Access the session's state dictionary.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,1,0&quot;&gt;Features&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;43,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Behaves like a Python dictionary (dict).&lt;/li&gt;
&lt;li&gt;Data storage maintained during the session.&lt;/li&gt;
&lt;li&gt;All tool functions access the same state object (Data Sharing).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,2,0&quot;&gt;Usage Example&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;async def my_tool(tool_context: ToolContext, ...):
    state = tool_context.state  # Get State object

    # Read State
    value = state.get(&quot;key&quot;)  # Returns None if key doesn't exist
    value = state[&quot;key&quot;]      # Raises KeyError if key doesn't exist

    # Write State
    state[&quot;key&quot;] = &quot;value&quot;    # Save value to State
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 data-path-to-node=&quot;44&quot; data-ke-size=&quot;size20&quot;&gt;2. tool_context.save_artifact(filename, artifact)&lt;/h4&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;45&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,0,0&quot;&gt;Role&lt;/b&gt;: Save an Artifact (File) to Google ADK storage.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,1,0&quot;&gt;Features&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;45,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Asynchronous function (await required).&lt;/li&gt;
&lt;li&gt;Saves the file to Google ADK's artifact storage.&lt;/li&gt;
&lt;li&gt;Stored permanently (persists even after the session ends).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,2,0&quot;&gt;Usage Example&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;python&quot;&gt;&lt;code&gt;async def my_tool(tool_context: ToolContext, ...):
    # Create Artifact Object
    artifact = types.Part(
        inline_data=types.Blob(
            mime_type=&quot;text/markdown&quot;,
            data=content.encode(&quot;utf-8&quot;),
        )
    )
    # Save Artifact (Async)
    await tool_context.save_artifact(&quot;report.md&quot;, artifact)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;46&quot; data-ke-size=&quot;size23&quot;&gt;ToolContext Passing Conditions&lt;/h3&gt;
&lt;p data-path-to-node=&quot;47&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;47&quot;&gt;Function Receiving ToolContext&lt;/b&gt; (Tool Function):&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;from google.adk.tools import ToolContext

async def save_advice_report(tool_context: ToolContext, summary: str, ticker: str):
    # tool_context is available
    state = tool_context.state
    await tool_context.save_artifact(...)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;49&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;49&quot;&gt;Function Not Receiving ToolContext&lt;/b&gt; (General Tool Function):&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;ruby&quot;&gt;&lt;code&gt;def get_company_info(ticker: str):
    # ToolContext is not needed
    stock = yf.Ticker(ticker)
    return {&quot;ticker&quot;: ticker, &quot;company_name&quot;: stock.info.get(&quot;longName&quot;)}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;51&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;51&quot;&gt;Difference&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;52&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;52,0,0&quot;&gt;If State or Artifact features are needed&lt;/b&gt;: Receive ToolContext as the first parameter.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;52,1,0&quot;&gt;If only simple data lookup/processing is done&lt;/b&gt;: ToolContext is unnecessary.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;53&quot; data-ke-size=&quot;size23&quot;&gt;Lifecycle of ToolContext&lt;/h3&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;54&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;54,0,0&quot;&gt;Creation&lt;/b&gt;: Created by Google ADK when a tool function is called.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;54,1,0&quot;&gt;Passing&lt;/b&gt;: Automatically passed as the first parameter of the tool function.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;54,2,0&quot;&gt;Usage&lt;/b&gt;: Used within the tool function to access state, save artifacts, etc.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;54,3,0&quot;&gt;Destruction&lt;/b&gt;: When function execution ends, the context is maintained, but a new ToolContext is created for the next function call.&lt;/li&gt;
&lt;/ol&gt;
&lt;p data-path-to-node=&quot;55&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;55&quot;&gt;Important&lt;/b&gt;: Although a new ToolContext is created for each tool function call, the &lt;b data-index-in-node=&quot;82&quot; data-path-to-node=&quot;55&quot;&gt;state is shared throughout the session&lt;/b&gt;.&lt;/p&gt;
&lt;hr data-path-to-node=&quot;56&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;57&quot; data-ke-size=&quot;size26&quot;&gt;State Management System Detailed Description&lt;/h2&gt;
&lt;h3 data-path-to-node=&quot;58&quot; data-ke-size=&quot;size23&quot;&gt;What is State?&lt;/h3&gt;
&lt;p data-path-to-node=&quot;59&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;59&quot;&gt;State&lt;/b&gt; is the &lt;b data-index-in-node=&quot;13&quot; data-path-to-node=&quot;59&quot;&gt;central repository for sharing data between agents&lt;/b&gt; in Google ADK. It behaves similarly to a Python dictionary (dict) and persists for the duration of a session.&lt;/p&gt;
&lt;h3 data-path-to-node=&quot;60&quot; data-ke-size=&quot;size23&quot;&gt;Creation and Access of State&lt;/h3&gt;
&lt;h4 data-path-to-node=&quot;61&quot; data-ke-size=&quot;size20&quot;&gt;1. Access via ToolContext.state&lt;/h4&gt;
&lt;p data-path-to-node=&quot;62&quot; data-ke-size=&quot;size16&quot;&gt;All tool functions can access the state by receiving the ToolContext object as the first parameter:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;async def save_advice_report(tool_context: ToolContext, summary: str, ticker: str):
    state = tool_context.state  # Access state object via ToolContext
    # state can be used like a dict
    data = state.get(&quot;data_analyst_result&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;64&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;64&quot;&gt;Important&lt;/b&gt;: State can only be accessed via ToolContext. You cannot access state without ToolContext.&lt;/p&gt;
&lt;h4 data-path-to-node=&quot;65&quot; data-ke-size=&quot;size20&quot;&gt;2. Structure of State&lt;/h4&gt;
&lt;p data-path-to-node=&quot;66&quot; data-ke-size=&quot;size16&quot;&gt;State basically behaves identically to a Python dictionary:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;state = {
    &quot;data_analyst_result&quot;: &quot;...&quot;,       # Analysis result in string format
    &quot;financial_analyst_result&quot;: &quot;...&quot;,  # Analysis result in string format
    &quot;news_analyst_result&quot;: &quot;...&quot;,       # Analysis result in string format
    &quot;report&quot;: &quot;...&quot;,                    # Final report (Optional)
    # ... other key-value pairs
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 data-path-to-node=&quot;68&quot; data-ke-size=&quot;size23&quot;&gt;Auto-save via output_key&lt;/h3&gt;
&lt;p data-path-to-node=&quot;69&quot; data-ke-size=&quot;size16&quot;&gt;When a sub-agent receives a final text response from the LLM, it is automatically saved to the state with the key specified in output_key.&lt;/p&gt;
&lt;h4 data-path-to-node=&quot;70&quot; data-ke-size=&quot;size20&quot;&gt;Actual Code Example&lt;/h4&gt;
&lt;p data-path-to-node=&quot;71&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71&quot;&gt;Data Analyst Agent Definition&lt;/b&gt; (financial_advisor/sub_agents/data_analyst.py):&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;data_analyst = LlmAgent(
    name=&quot;DataAnalyst&quot;,
    model=MODEL,
    tools=[get_company_info, get_stock_price, get_financial_metrics],
    output_key=&quot;data_analyst_result&quot;,  # &amp;larr; Saved to state with this key
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;73&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;73&quot;&gt;Operational Process&lt;/b&gt;:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;74&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;74,0,0&quot;&gt;Data Analyst Agent receives text response from LLM&lt;/b&gt;: &quot;**Company Overview:**\nApple Inc. is a technology company...&quot;&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;74,1,0&quot;&gt;Google ADK automatically saves to state&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;# Automatically executed internally by Google ADK
state[&quot;data_analyst_result&quot;] = &quot;**Company Overview:**\nApple Inc. is a technology company...&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;74,2,0&quot;&gt;Main Agent or other functions can access state&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;async def save_advice_report(tool_context: ToolContext, ...):
    state = tool_context.state
    data_analyst_result = state.get(&quot;data_analyst_result&quot;)  # Read saved value
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;75&quot; data-ke-size=&quot;size23&quot;&gt;Step-by-Step State Changes&lt;/h3&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;76&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;76,0,0&quot;&gt;Initial State (Session Start)&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;state = {}  # Empty dictionary
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;76,1,0&quot;&gt;After Data Analyst Agent Execution&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;awk&quot;&gt;&lt;code&gt;state = {
  &quot;data_analyst_result&quot;: &quot;&quot;&quot;
  **Company Overview:**
  Apple Inc. is a technology company in the Consumer Electronics industry.
  ...
  &quot;&quot;&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;76,2,0&quot;&gt;After Financial Analyst Agent Execution&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;awk&quot;&gt;&lt;code&gt;state = {
  &quot;data_analyst_result&quot;: &quot;...&quot;,
  &quot;financial_analyst_result&quot;: &quot;&quot;&quot;
  **Income Statement Analysis:**
  Total Revenue (2024): $383.3 billion
  ...
  &quot;&quot;&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;76,3,0&quot;&gt;After News Analyst Agent Execution&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;awk&quot;&gt;&lt;code&gt;state = {
  &quot;data_analyst_result&quot;: &quot;...&quot;,
  &quot;financial_analyst_result&quot;: &quot;...&quot;,
  &quot;news_analyst_result&quot;: &quot;&quot;&quot;
  **Recent News Analysis:**
  1. Strong Q4 Earnings: Apple reported $89.5B revenue...
  ...
  &quot;&quot;&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;76,4,0&quot;&gt;After save_advice_report Function Execution&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;awk&quot;&gt;&lt;code&gt;state = {
  &quot;data_analyst_result&quot;: &quot;...&quot;,
  &quot;financial_analyst_result&quot;: &quot;...&quot;,
  &quot;news_analyst_result&quot;: &quot;...&quot;,
  &quot;report&quot;: &quot;&quot;&quot;
  # Executive Summary and Advice:
  [Final Advice Text]
  ## Data Analyst Report:
  [Content of data_analyst_result]
  ...
  &quot;&quot;&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;77&quot; data-ke-size=&quot;size23&quot;&gt;Characteristics of State&lt;/h3&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;78&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;78,0,0&quot;&gt;Session-based&lt;/b&gt;: State exists independently for each user session.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;78,1,0&quot;&gt;Key-Value Storage&lt;/b&gt;: Consists of string keys and string values (Agent responses are all text).&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;78,2,0&quot;&gt;Auto-save&lt;/b&gt;: If output_key is specified, the agent's final response is automatically saved.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;78,3,0&quot;&gt;Read/Write&lt;/b&gt;: Accessible in tool functions via state.get(key), state[key] = value, etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr data-path-to-node=&quot;79&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;80&quot; data-ke-size=&quot;size26&quot;&gt;Artifact System Detailed Description&lt;/h2&gt;
&lt;h3 data-path-to-node=&quot;81&quot; data-ke-size=&quot;size23&quot;&gt;What is an Artifact?&lt;/h3&gt;
&lt;p data-path-to-node=&quot;82&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;82&quot;&gt;Artifact&lt;/b&gt; is a &lt;b data-index-in-node=&quot;14&quot; data-path-to-node=&quot;82&quot;&gt;system for storing and managing files&lt;/b&gt; in Google ADK. It allows permanent storage of final deliverables generated by agents (reports, images, data files, etc.).&lt;/p&gt;
&lt;h3 data-path-to-node=&quot;83&quot; data-ke-size=&quot;size23&quot;&gt;Artifact Creation Process&lt;/h3&gt;
&lt;h4 data-path-to-node=&quot;84&quot; data-ke-size=&quot;size20&quot;&gt;1. Creating an Artifact Object&lt;/h4&gt;
&lt;p data-path-to-node=&quot;85&quot; data-ke-size=&quot;size16&quot;&gt;Google ADK uses the google.genai.types module to create Artifact objects:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;from google.genai import types

# Create Artifact (Markdown file example)
artifact = types.Part(
    inline_data=types.Blob(
        mime_type=&quot;text/markdown&quot;,  # Specify file type
        data=report.encode(&quot;utf-8&quot;),  # File content (bytes format)
    )
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;87&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;87&quot;&gt;Component Explanation&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;88&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;88,0,0&quot;&gt;types.Part&lt;/b&gt;: Container for the Artifact.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;88,1,0&quot;&gt;types.Blob&lt;/b&gt;: Object containing the actual data.
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;88,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;mime_type: MIME type of the file (e.g., &quot;text/markdown&quot;, &quot;text/plain&quot;, &quot;image/png&quot;, &quot;application/json&quot;).&lt;/li&gt;
&lt;li&gt;data: Data encoded into bytes sequence.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 data-path-to-node=&quot;89&quot; data-ke-size=&quot;size20&quot;&gt;2. Detailed Steps for Saving an Artifact (Code Analysis)&lt;/h4&gt;
&lt;p data-path-to-node=&quot;90&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;90&quot;&gt;Step 1: Collect Data&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;state = tool_context.state
data_analyst_result = state.get(&quot;data_analyst_result&quot;) # Read from State
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;92&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;92&quot;&gt;Step 2: Combine Text&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;ini&quot;&gt;&lt;code&gt;report = f&quot;&quot;&quot;
# Executive Summary and Advice:
{summary}
...
&quot;&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;94&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Use Python f-strings to combine multiple state values into a single Markdown string.&lt;/li&gt;
&lt;li&gt;summary is the value received as a function parameter.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;95&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;95&quot;&gt;Step 3: Save to State (Optional)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pf&quot;&gt;&lt;code&gt;state[&quot;report&quot;] = report
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;97&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Can be saved to state separately from the Artifact.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;98&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;98&quot;&gt;Step 4: Generate Filename&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;ini&quot;&gt;&lt;code&gt;filename = f&quot;{ticker}_investment_advice.md&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;100&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Example: &quot;AAPL_investment_advice.md&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;101&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;101&quot;&gt;Step 5: Create Artifact Object&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;artifact = types.Part(
    inline_data=types.Blob(
        mime_type=&quot;text/markdown&quot;,
        data=report.encode(&quot;utf-8&quot;),
    )
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;103&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;103,0,0&quot;&gt;Details&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;103,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;report.encode(&quot;utf-8&quot;): Converts string to bytes via UTF-8 encoding.&lt;/li&gt;
&lt;li&gt;mime_type=&quot;text/markdown&quot;: Specifies that the file is in Markdown format.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;104&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;104&quot;&gt;Step 6: Asynchronous Save&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;reasonml&quot;&gt;&lt;code&gt;await tool_context.save_artifact(filename, artifact)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;106&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;106,0,0&quot;&gt;Details&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;106,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Use await keyword as it is an asynchronous function.&lt;/li&gt;
&lt;li&gt;The file is saved to Google ADK's artifact storage.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;107&quot; data-ke-size=&quot;size23&quot;&gt;Artifact Storage Location&lt;/h3&gt;
&lt;p data-path-to-node=&quot;108&quot; data-ke-size=&quot;size16&quot;&gt;Artifacts are stored in the following directory structure:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;dust&quot;&gt;&lt;code&gt;.adk/
  artifacts/
    users/
      {user_id}/
        sessions/
          {session_id}/
            artifacts/
              {filename}/
                versions/
                  0/
                    metadata.json
                    (Actual File)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;110&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;110&quot;&gt;Example Path&lt;/b&gt;: .adk/artifacts/users/user/sessions/9122902d-0d69-4b6d-85ae-e5254418b9d0/artifacts/AAPL_investment_advice.md/versions/0/&lt;/p&gt;
&lt;h3 data-path-to-node=&quot;111&quot; data-ke-size=&quot;size23&quot;&gt;Difference between Artifact and State&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;112&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,0,0,0&quot;&gt;Feature&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,0,1,0&quot;&gt;State&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,0,2,0&quot;&gt;Artifact&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,1,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,1,0,0&quot;&gt;Storage Form&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,1,1,0&quot;&gt;In-memory Dictionary (Key-Value)&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,1,2,0&quot;&gt;Files in File System&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,2,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,2,0,0&quot;&gt;Data Type&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,2,1,0&quot;&gt;String (Text)&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,2,2,0&quot;&gt;Bytes (Binary data allowed)&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,3,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,3,0,0&quot;&gt;Persistence&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,3,1,0&quot;&gt;Maintained only during session&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,3,2,0&quot;&gt;Permanent storage (Saved as file)&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,4,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,4,0,0&quot;&gt;Access Method&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,4,1,0&quot;&gt;state.get(key), state[key]&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,4,2,0&quot;&gt;File download or path access&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,5,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,5,0,0&quot;&gt;Usage&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,5,1,0&quot;&gt;Data sharing between agents&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,5,2,0&quot;&gt;Storage of final deliverables (reports, images)&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,6,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;112,6,0,0&quot;&gt;Auto-save&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,6,1,0&quot;&gt;Can save automatically via output_key&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;112,6,2,0&quot;&gt;Requires manual save_artifact() call&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Sheets로 내보내기&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 data-path-to-node=&quot;113&quot; data-ke-size=&quot;size23&quot;&gt;Relationship between State and Artifact&lt;/h3&gt;
&lt;p data-path-to-node=&quot;114&quot; data-ke-size=&quot;size16&quot;&gt;In real usage scenarios, State and Artifact are used together:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;115&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;115,0,0&quot;&gt;State&lt;/b&gt;: Sharing intermediate results between agents.
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;115,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Data Analyst &amp;rarr; state[&quot;data_analyst_result&quot;]&lt;/li&gt;
&lt;li&gt;Financial Analyst &amp;rarr; state[&quot;financial_analyst_result&quot;]&lt;/li&gt;
&lt;li&gt;News Analyst &amp;rarr; state[&quot;news_analyst_result&quot;]&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;115,1,0&quot;&gt;Artifact&lt;/b&gt;: Saving final deliverables as files.
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;115,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The save_advice_report() function reads all data from the state,&lt;/li&gt;
&lt;li&gt;Combines it into a single Markdown file,&lt;/li&gt;
&lt;li&gt;And saves it as an Artifact.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;116&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;117&quot; data-ke-size=&quot;size26&quot;&gt;Tool Function Parameter Determination Method&lt;/h2&gt;
&lt;h3 data-path-to-node=&quot;118&quot; data-ke-size=&quot;size23&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;118&quot;&gt;Core Concept: The LLM automatically determines parameters.&lt;/b&gt;&lt;/h3&gt;
&lt;p data-path-to-node=&quot;119&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;119&quot;&gt;Question&lt;/b&gt;: In the get_stock_price(ticker: str, period: str) function used by data_analyst, who decides the period parameter value (&quot;1y&quot;, &quot;3mo&quot;, etc.)? &lt;b data-index-in-node=&quot;150&quot; data-path-to-node=&quot;119&quot;&gt;Answer&lt;/b&gt;: &lt;b data-index-in-node=&quot;158&quot; data-path-to-node=&quot;119&quot;&gt;The Agent (LLM) decides automatically!&lt;/b&gt;&lt;/p&gt;
&lt;h3 data-path-to-node=&quot;120&quot; data-ke-size=&quot;size23&quot;&gt;Operating Principle&lt;/h3&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;121&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;121,0,0&quot;&gt;At Function Registration Time&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;fortran&quot;&gt;&lt;code&gt;# data_analyst.py
data_analyst = LlmAgent(
    tools=[
        get_company_info,      # Pass function object itself
        get_stock_price,       # Pass function object itself
        get_financial_metrics,
    ],
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;121,1,0&quot;&gt;Google ADK Automatic Processing&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;121,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Google ADK parses the &lt;b data-index-in-node=&quot;22&quot; data-path-to-node=&quot;121,1,1,0,0&quot;&gt;docstring&lt;/b&gt; of the registered functions.&lt;/li&gt;
&lt;li&gt;It reads the function signature (def get_stock_price(ticker: str, period: str)) and the docstring.&lt;/li&gt;
&lt;li&gt;It sends the function description and parameter information to the LLM in JSON Schema format.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;121,2,0&quot;&gt;Example Information Sent to LLM&lt;/b&gt;:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;type&quot;: &quot;function&quot;,
  &quot;function&quot;: {
    &quot;name&quot;: &quot;get_stock_price&quot;,
    &quot;description&quot;: &quot;Fetches historical stock price data and current trading price for a given ticker.&quot;,
    &quot;parameters&quot;: {
      &quot;type&quot;: &quot;object&quot;,
      &quot;properties&quot;: {
        &quot;ticker&quot;: {
          &quot;type&quot;: &quot;string&quot;,
          &quot;description&quot;: &quot;Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&quot;
        },
        &quot;period&quot;: {
          &quot;type&quot;: &quot;string&quot;,
          &quot;description&quot;: &quot;Time period for historical data. Valid options: '1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'&quot;
        }
      },
      &quot;required&quot;: [&quot;ticker&quot;, &quot;period&quot;]
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;121,3,0&quot;&gt;LLM Determines Parameter Values&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;121,3,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The LLM determines appropriate values based on the user request, context, and function description.&lt;/li&gt;
&lt;li&gt;Example: Request &quot;Analyze AAPL stock&quot; &amp;rarr; LLM decides {&quot;ticker&quot;: &quot;AAPL&quot;, &quot;period&quot;: &quot;1y&quot;}.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;122&quot; data-ke-size=&quot;size23&quot;&gt;Actual Example&lt;/h3&gt;
&lt;p data-path-to-node=&quot;123&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;123&quot;&gt;Scenario&lt;/b&gt;: User requests &quot;Analyze AAPL stock&quot;.&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;124&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;Data Analyst agent decides it needs to use the get_stock_price tool.&lt;/li&gt;
&lt;li&gt;LLM reads and understands the function description:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;124,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;ticker is a required parameter &amp;rarr; Use &quot;AAPL&quot;.&lt;/li&gt;
&lt;li&gt;period is optional but necessary for analysis &amp;rarr; LLM selects &quot;1y&quot; (1 year) based on context.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;LLM Response:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;tool_calls&quot;: [{
    &quot;function&quot;: {
      &quot;name&quot;: &quot;get_stock_price&quot;,
      &quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;, \&quot;period\&quot;: \&quot;1y\&quot;}&quot;
    }
  }]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Google ADK parses this JSON and calls the actual Python function:&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pgsql&quot;&gt;&lt;code&gt;get_stock_price(ticker=&quot;AAPL&quot;, period=&quot;1y&quot;)  # Called with values decided by LLM
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;125&quot; data-ke-size=&quot;size23&quot;&gt;Important Points&lt;/h3&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;126&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;126,0,0&quot;&gt;Function docstrings are extremely important&lt;/b&gt;: The LLM uses them to understand the function and generate correct parameters. Detailed docstrings are essential.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;126,1,0&quot;&gt;Type Hints are also utilized&lt;/b&gt;: The str type hint in def get_stock_price(ticker: str, period: str) is passed to the LLM.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;126,2,0&quot;&gt;Intelligent Judgment by LLM&lt;/b&gt;: The LLM doesn't just call the function; it judges &lt;b data-index-in-node=&quot;79&quot; data-path-to-node=&quot;126,2,0&quot;&gt;what parameter values are appropriate&lt;/b&gt;. (e.g., &quot;3mo&quot; for short-term analysis requests, &quot;2y&quot; for long-term).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;127&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h2 data-path-to-node=&quot;128&quot; data-ke-size=&quot;size26&quot;&gt;Data Flow Diagram&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;less&quot;&gt;&lt;code&gt;User Input
    &amp;darr;
Main Agent (LLM #1)
    &amp;darr;
[Tool Call: data_analyst]
    &amp;darr;
Data Analyst Agent (LLM #2)
    &amp;darr;
[Tool Execution: get_company_info, get_stock_price, get_financial_metrics]
    &amp;darr; (Yahoo Finance API)
Data Analyst (LLM #3) &amp;rarr; state[&quot;data_analyst_result&quot;]
    &amp;darr;
Main Agent (LLM #4)
    &amp;darr;
[Tool Call: financial_analyst]
    &amp;darr;
Financial Analyst Agent (LLM #5)
    &amp;darr;
[Tool Execution: get_income_statement, get_balance_sheet, get_cash_flow]
    &amp;darr; (Yahoo Finance API)
Financial Analyst (LLM #6) &amp;rarr; state[&quot;financial_analyst_result&quot;]
    &amp;darr;
Main Agent (LLM #7)
    &amp;darr;
[Tool Call: news_analyst]
    &amp;darr;
News Analyst Agent (LLM #8)
    &amp;darr;
[Tool Execution: web_search_tool]
    &amp;darr; (Firecrawl API)
News Analyst (LLM #9) &amp;rarr; state[&quot;news_analyst_result&quot;]
    &amp;darr;
Main Agent (LLM #10, #11)
    &amp;darr;
[Final Advice Generation]
    &amp;darr;
[Optional: save_advice_report]
    &amp;darr;
Markdown File Save
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/35</guid>
      <comments>https://note24432.tistory.com/35#entry35comment</comments>
      <pubDate>Sat, 3 Jan 2026 03:12:13 +0900</pubDate>
    </item>
    <item>
      <title>Google ADK: Financial Advisor(3)- json communication between llm and adk</title>
      <link>https://note24432.tistory.com/34</link>
      <description>&lt;h2 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size26&quot; data-path-to-node=&quot;1&quot;&gt;System Overview&lt;/h2&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;2&quot;&gt;This system is a financial advisory system utilizing a&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;2&quot; data-index-in-node=&quot;55&quot;&gt;multi-agent architecture&lt;/b&gt;. The main agent (Financial Advisor) coordinates three specialized sub-agents to provide comprehensive investment analysis.&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;Financial Advisor (Main Agent)
├── Data Analyst (Basic Data Collection)
├── Financial Analyst (Financial Statement Analysis)
├── News Analyst (News Search and Analysis)
└── save_advice_report (Save Final Report)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;4&quot; /&gt;
&lt;h2 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size26&quot; data-path-to-node=&quot;5&quot;&gt;Real-world Example: AAPL Stock Analysis Request&lt;/h2&gt;
&lt;h2 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size26&quot; data-path-to-node=&quot;6&quot;&gt;Explaining the case where a user asks,&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;6&quot; data-index-in-node=&quot;39&quot;&gt;&quot;Give me investment advice for AAPL stock.&quot;&lt;/b&gt;&lt;/h2&gt;
&lt;h2 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size26&quot; data-path-to-node=&quot;7&quot;&gt;Detailed Step-by-Step Process&lt;/h2&gt;
&lt;h3 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size23&quot; data-path-to-node=&quot;8&quot;&gt;Step 1: Receiving User Request and Initial LLM Call&lt;/h3&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;9&quot;&gt;User Input&lt;/h4&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;Give me investment advice for AAPL stock&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;11&quot;&gt;Main Agent LLM Call #1&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;12&quot;&gt;&lt;b data-path-to-node=&quot;12&quot; data-index-in-node=&quot;0&quot;&gt;Call Location&lt;/b&gt;: financial_advisor agent in financial_advisor/agent.py&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;12&quot; data-index-in-node=&quot;69&quot;&gt;LLM Model&lt;/b&gt;: openai/gpt-4o (Call via LiteLlm)&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;12&quot; data-index-in-node=&quot;113&quot;&gt;Request Sent from Google ADK &amp;rarr; OpenAI GPT-4o API&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;model&quot;: &quot;openai/gpt-4o&quot;,
  &quot;messages&quot;: [
    {
      &quot;role&quot;: &quot;system&quot;,
      &quot;content&quot;: &quot;You are a Professional Financial Advisor... [Entire content of PROMPT from prompt.py]&quot;
    },
    {
      &quot;role&quot;: &quot;user&quot;,
      &quot;content&quot;: &quot;Give me investment advice for AAPL stock&quot;
    }
  ],
  &quot;tools&quot;: [
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;data_analyst&quot;,
        &quot;description&quot;: &quot;Gathers and analyzes basic stock market data...&quot;
      }
    },
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;financial_analyst&quot;,
        &quot;description&quot;: &quot;Analyzes detailed financial statements...&quot;
      }
    },
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;news_analyst&quot;,
        &quot;description&quot;: &quot;Uses Web Search tools to search and scrape real web content...&quot;
      }
    },
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;save_advice_report&quot;,
        &quot;description&quot;: &quot;Save comprehensive reports as artifacts...&quot;
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;14&quot;&gt;&lt;i data-path-to-node=&quot;14&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Google ADK (Main Agent System)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;14&quot; data-index-in-node=&quot;42&quot;&gt;Receiver: OpenAI GPT-4o API&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;15&quot;&gt;&lt;b data-path-to-node=&quot;15&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON serves as the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;15&quot; data-index-in-node=&quot;54&quot;&gt;Entry Point&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;of the system, passing the user request to the LLM for the first time.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;16&quot;&gt;&lt;b data-path-to-node=&quot;16&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;17&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;17,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Context Setting&lt;/b&gt;: Provides the LLM with the Financial Advisor role and behavioral guidelines (prompt).&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;17,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Tool List Provision&lt;/b&gt;: Introduces the 4 tools available to the LLM (3 Sub-agents + save_advice_report).&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;17,2,0&quot; data-index-in-node=&quot;0&quot;&gt;User Intent Delivery&lt;/b&gt;: Conveys the actual user request (&quot;Give me investment advice for AAPL stock&quot;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;18&quot;&gt;&lt;b data-path-to-node=&quot;18&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;19&quot;&gt;
&lt;li&gt;OpenAI GPT-4o API receives this request and passes it to the LLM model.&lt;/li&gt;
&lt;li&gt;The LLM reads the prompt to understand the Financial Advisor role.&lt;/li&gt;
&lt;li&gt;The LLM analyzes the user request and reviews the available tools.&lt;/li&gt;
&lt;li&gt;The LLM secures all information needed to decide the next step (which tool to call).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;20&quot;&gt;&lt;b data-path-to-node=&quot;20&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;21&quot;&gt;
&lt;li&gt;Directly influences the LLM's next decision (which sub-agent to call).&lt;/li&gt;
&lt;li&gt;The content of the prompt determines the LLM's behavior pattern.&lt;/li&gt;
&lt;li&gt;Tools not in the list cannot be used by the LLM (provides constraints).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;22&quot;&gt;&lt;b data-path-to-node=&quot;22&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;23&quot;&gt;
&lt;li&gt;The tools array does not show parameter schemas here because Google ADK handles sub-agents internally.&lt;/li&gt;
&lt;li&gt;system.content actually contains the entire 55 lines from prompt.py, but is abbreviated in the documentation for readability.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;24&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;25&quot;&gt;&lt;b data-path-to-node=&quot;25&quot; data-index-in-node=&quot;0&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;tool_calls&quot;: [
    {
      &quot;id&quot;: &quot;call_123&quot;,
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;data_analyst&quot;,
        &quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
      }
    }
  ],
  &quot;finish_reason&quot;: &quot;tool_calls&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;27&quot;&gt;&lt;i data-path-to-node=&quot;27&quot; data-index-in-node=&quot;0&quot;&gt;Generator: OpenAI GPT-4o LLM&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;27&quot; data-index-in-node=&quot;29&quot;&gt;Receiver: Google ADK (Main Agent System)&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;28&quot;&gt;&lt;b data-path-to-node=&quot;28&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;28&quot; data-index-in-node=&quot;47&quot;&gt;result of the LLM's decision-making&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;after analyzing the initial request.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;29&quot;&gt;&lt;b data-path-to-node=&quot;29&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;30&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;30,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Decision Result&lt;/b&gt;: Expresses the LLM's decision to &quot;call the data_analyst first.&quot;&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;30,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Next Step Trigger&lt;/b&gt;: When Google ADK receives this response, it initiates the execution of the data_analyst sub-agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;30,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Chain Start Point&lt;/b&gt;: Signal to start the first step of the entire multi-agent process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;31&quot;&gt;&lt;b data-path-to-node=&quot;31&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;32&quot;&gt;
&lt;li&gt;Google ADK parses the tool_calls array to recognize the need to call data_analyst.&lt;/li&gt;
&lt;li&gt;Google ADK extracts the ticker: &quot;AAPL&quot; parameter from arguments.&lt;/li&gt;
&lt;li&gt;Google ADK executes the Data Analyst sub-agent, passing ticker=&quot;AAPL&quot;.&lt;/li&gt;
&lt;li&gt;The Data Analyst sub-agent begins its task.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;33&quot;&gt;&lt;b data-path-to-node=&quot;33&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;34&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;34,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Branching Point&lt;/b&gt;: At this point, the flow of the main agent branches into the Data Analyst sub-agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;34,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Sequential Execution Decision&lt;/b&gt;: The LLM decided to execute sequentially rather than calling multiple tools at once (influenced by &quot;ANALYSIS METHODOLOGY&quot; in the prompt).&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;34,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Context Transfer&lt;/b&gt;: &quot;AAPL&quot; from the user input is passed to the sub-agent, clarifying the analysis target.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;35&quot;&gt;&lt;b data-path-to-node=&quot;35&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;36&quot;&gt;
&lt;li&gt;finish_reason: &quot;tool_calls&quot; means the LLM finished responding with a tool call instead of generating text.&lt;/li&gt;
&lt;li&gt;The reason arguments is in JSON string format (&quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;) is that it is the standard format for OpenAI API.&lt;/li&gt;
&lt;li&gt;Why call only data_analyst? &amp;rarr; Because the LLM read the prompt and selected a sequential approach.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;37&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;38&quot;&gt;&lt;b data-path-to-node=&quot;38&quot; data-index-in-node=&quot;0&quot;&gt;Detailed Explanation of the arguments Field Generation Process&lt;/b&gt;: arguments: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot; was&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;38&quot; data-index-in-node=&quot;104&quot;&gt;automatically generated by the LLM&lt;/b&gt;. The process is as follows:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-ke-list-type=&quot;decimal&quot; data-path-to-node=&quot;39&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;39,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Google ADK passes sub-agent information to the LLM&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;39,0,1&quot;&gt;
&lt;li&gt;When registering AgentTool(agent=data_analyst) as a tool, Google ADK passes the data_analyst agent's description and name to the LLM.&lt;/li&gt;
&lt;li&gt;In code: data_analyst = LlmAgent(name=&quot;DataAnalyst&quot;, description=&quot;Gathers and analyzes basic stock market data...&quot;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;39,1,0&quot; data-index-in-node=&quot;0&quot;&gt;LLM analyzes User Input&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;39,1,1&quot;&gt;
&lt;li&gt;User Input: &quot;Give me investment advice for AAPL stock&quot;&lt;/li&gt;
&lt;li&gt;The LLM recognizes &quot;AAPL&quot; as a stock ticker symbol.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;39,2,0&quot; data-index-in-node=&quot;0&quot;&gt;LLM selects tool and generates parameters&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;39,2,1&quot;&gt;
&lt;li&gt;The LLM reads &quot;ANALYSIS METHODOLOGY&quot; in the prompt and determines that data must be gathered first.&lt;/li&gt;
&lt;li&gt;It understands that the data_analyst tool collects stock data.&lt;/li&gt;
&lt;li&gt;It extracts &quot;AAPL&quot; from the user input to use as the ticker parameter.&lt;/li&gt;
&lt;li&gt;Google ADK automatically infers standard parameters like ticker or identifies necessary parameters based on the agent's description when calling sub-agents.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;39,3,0&quot; data-index-in-node=&quot;0&quot;&gt;LLM generates arguments in JSON format&lt;/b&gt;:
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;39,3,2&quot;&gt;
&lt;li&gt;The LLM generates the parameters required for the function call in a JSON string format.&lt;/li&gt;
&lt;li&gt;ticker is recognized as a standard parameter meaning stock ticker symbol.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;40&quot;&gt;&lt;b data-path-to-node=&quot;40&quot; data-index-in-node=&quot;0&quot;&gt;Summary&lt;/b&gt;: arguments are not explicitly stated in the prompt but are&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;40&quot; data-index-in-node=&quot;67&quot;&gt;automatically generated by the LLM by analyzing user input, referencing the description of available tools, and extracting necessary parameter values.&lt;/b&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;41&quot;&gt;&lt;b data-path-to-node=&quot;41&quot; data-index-in-node=&quot;0&quot;&gt;Interpretation&lt;/b&gt;:&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-ke-list-type=&quot;decimal&quot; data-path-to-node=&quot;42&quot;&gt;
&lt;li&gt;LLM reads the prompt and understands the analysis process.&lt;/li&gt;
&lt;li&gt;Based on &quot;ANALYSIS METHODOLOGY&quot; in the PROMPT, it decides to collect basic data first.&lt;/li&gt;
&lt;li&gt;It extracts &quot;AAPL&quot; from the user input to use as the ticker parameter.&lt;/li&gt;
&lt;li&gt;Decides to call data_analyst sub-agent and generates arguments.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;43&quot; /&gt;
&lt;h3 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size23&quot; data-path-to-node=&quot;44&quot;&gt;Step 2: Executing Data Analyst Sub-agent&lt;/h3&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;45&quot;&gt;2-1. Data Analyst Agent Initialization and LLM Call #2&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;46&quot;&gt;&lt;b data-path-to-node=&quot;46&quot; data-index-in-node=&quot;0&quot;&gt;Call Location&lt;/b&gt;: data_analyst agent in financial_advisor/sub_agents/data_analyst.py&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;46&quot; data-index-in-node=&quot;82&quot;&gt;Request Sent from Google ADK &amp;rarr; OpenAI GPT-4o API&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;model&quot;: &quot;openai/gpt-4o&quot;,
  &quot;messages&quot;: [
    {
      &quot;role&quot;: &quot;system&quot;,
      &quot;content&quot;: &quot;You are a Data Analyst who gathers stock information using 4 specialized tools:\n\n1. **get_company_info(ticker)** - Learn about the company...\n2. **get_stock_price(ticker, period)** - Get current pricing...\n3. **get_financial_metrics(ticker)** - Check key financial ratios...&quot;
    },
    {
      &quot;role&quot;: &quot;user&quot;,
      &quot;content&quot;: &quot;Analyze ticker: AAPL&quot;
    }
  ],
  &quot;tools&quot;: [
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_company_info&quot;,
        &quot;description&quot;: &quot;Retrieves basic company information for a given stock ticker...&quot;
      }
    },
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_stock_price&quot;,
        &quot;description&quot;: &quot;Fetches historical stock price data...&quot;
      }
    },
    {
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_financial_metrics&quot;,
        &quot;description&quot;: &quot;Retrieves key financial metrics and valuation ratios...&quot;
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;48&quot;&gt;&lt;i data-path-to-node=&quot;48&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Google ADK (Data Analyst Sub-agent System)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;48&quot; data-index-in-node=&quot;54&quot;&gt;Receiver: OpenAI GPT-4o API&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;49&quot;&gt;&lt;b data-path-to-node=&quot;49&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is the request where the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;49&quot; data-index-in-node=&quot;65&quot;&gt;Data Analyst sub-agent calls its own dedicated LLM upon initial activation&lt;/b&gt;.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;50&quot;&gt;&lt;b data-path-to-node=&quot;50&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;51&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;51,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Sub-agent Activation&lt;/b&gt;: The Data Analyst starts working independently after receiving delegation from the Main Agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;51,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Specialization&lt;/b&gt;: Provides only the Data Analyst-specific prompt and tools, ensuring focus solely on data collection.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;51,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Domain Separation&lt;/b&gt;: Unlike the Main Agent's complex prompt, this provides simple and clear data collection instructions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;52&quot;&gt;&lt;b data-path-to-node=&quot;52&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;53&quot;&gt;
&lt;li&gt;The Data Analyst-dedicated LLM instance is activated (separate from the Main Agent).&lt;/li&gt;
&lt;li&gt;The LLM understands the Data Analyst role and grasps the functions of the 3 tools.&lt;/li&gt;
&lt;li&gt;The LLM receives the task instruction &quot;Analyze AAPL&quot;.&lt;/li&gt;
&lt;li&gt;The LLM is ready to decide the next step (which tool to call).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;54&quot;&gt;&lt;b data-path-to-node=&quot;54&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;55&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;55,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Expertise&lt;/b&gt;: The Main Agent doesn't need to do everything; it delegates to an agent specialized in data collection.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;55,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Work Distribution&lt;/b&gt;: Reduces the burden on the Main Agent, allowing each sub-agent to focus on its area of expertise.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;55,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Scalability&lt;/b&gt;: Adding new data collection tools only requires modifying this agent.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;56&quot;&gt;&lt;b data-path-to-node=&quot;56&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;57&quot;&gt;
&lt;li&gt;user.content: &quot;Analyze ticker: AAPL&quot; is the natural language conversion of the ticker: &quot;AAPL&quot; parameter passed by the Main Agent.&lt;/li&gt;
&lt;li&gt;system.content is the content specified in the instruction parameter when defining the data_analyst agent (different from the Main Agent's prompt).&lt;/li&gt;
&lt;li&gt;description in the tools array is automatically parsed from the Python function's docstring.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;58&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;59&quot;&gt;&lt;b data-path-to-node=&quot;59&quot; data-index-in-node=&quot;0&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API (LLM Response #2)&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;tool_calls&quot;: [
    {
      &quot;id&quot;: &quot;call_456&quot;,
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_company_info&quot;,
        &quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
      }
    },
    {
      &quot;id&quot;: &quot;call_457&quot;,
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_stock_price&quot;,
        &quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;, \&quot;period\&quot;: \&quot;1y\&quot;}&quot;
      }
    },
    {
      &quot;id&quot;: &quot;call_458&quot;,
      &quot;type&quot;: &quot;function&quot;,
      &quot;function&quot;: {
        &quot;name&quot;: &quot;get_financial_metrics&quot;,
        &quot;arguments&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;}&quot;
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;61&quot;&gt;&lt;i data-path-to-node=&quot;61&quot; data-index-in-node=&quot;0&quot;&gt;Generator: OpenAI GPT-4o LLM (for Data Analyst Agent)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;61&quot; data-index-in-node=&quot;54&quot;&gt;Receiver: Google ADK (Data Analyst Sub-agent System)&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;62&quot;&gt;&lt;b data-path-to-node=&quot;62&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is the result of the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;62&quot; data-index-in-node=&quot;61&quot;&gt;Data Analyst LLM deciding to collect all 3 required data points&lt;/b&gt;.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;63&quot;&gt;&lt;b data-path-to-node=&quot;63&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;64&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;64,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Tool Call Decision&lt;/b&gt;: The LLM determines that company_info, stock_price, and financial_metrics are all needed.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;64,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Parallel Execution Instruction&lt;/b&gt;: Calls multiple tools at once for efficient data collection.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;64,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Parameter Decision&lt;/b&gt;: Determines parameter values to pass to each tool (ticker: &quot;AAPL&quot;, period: &quot;1y&quot;, etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;65&quot;&gt;&lt;b data-path-to-node=&quot;65&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;66&quot;&gt;
&lt;li&gt;Google ADK parses the tool_calls array and recognizes 3 tool calls.&lt;/li&gt;
&lt;li&gt;Google ADK executes each tool&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;66,1,0&quot; data-index-in-node=&quot;30&quot;&gt;in parallel&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;(improving efficiency).&lt;/li&gt;
&lt;li&gt;Each Python function (get_company_info, get_stock_price, get_financial_metrics) calls the Yahoo Finance API.&lt;/li&gt;
&lt;li&gt;Actual data is collected and returned to Google ADK.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;67&quot;&gt;&lt;b data-path-to-node=&quot;67&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;68&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;68,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Efficiency&lt;/b&gt;: Parallel calls reduce time compared to sequential calls.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;68,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Data Completeness&lt;/b&gt;: The LLM decides to collect all necessary data at once, preventing incomplete analysis.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;68,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Parameter Optimization&lt;/b&gt;: The LLM selecting period: &quot;1y&quot; indicates it judged this as an appropriate period for analysis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;69&quot;&gt;&lt;b data-path-to-node=&quot;69&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;70&quot;&gt;
&lt;li&gt;Why call 3 at the same time? &amp;rarr; Because the LLM judged that all 3 pieces of information are needed (influenced by instruction).&lt;/li&gt;
&lt;li&gt;How was period: &quot;1y&quot; decided? &amp;rarr; The LLM looked at the function docstring explanation (&quot;1y: 1 year&quot;) and judged it suitable for general analysis.&lt;/li&gt;
&lt;li&gt;Is sequential calling possible? &amp;rarr; Yes, but in this case, the LLM judged parallel calling to be more efficient.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;71&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;72&quot;&gt;&lt;b data-path-to-node=&quot;72&quot; data-index-in-node=&quot;0&quot;&gt;Interpretation&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;73&quot;&gt;
&lt;li&gt;Data Analyst LLM decided to call 3 tools simultaneously (parallel execution).&lt;/li&gt;
&lt;li&gt;Each tool is executed as an actual Python function.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;74&quot; /&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;75&quot;&gt;2-2. Actual Tool Function Execution (No LLM Call, Direct Execution)&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;76&quot;&gt;&lt;b data-path-to-node=&quot;76&quot; data-index-in-node=&quot;0&quot;&gt;Function Execution 1&lt;/b&gt;: get_company_info(&quot;AAPL&quot;)&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;# Actual API call using yfinance library
stock = yf.Ticker(&quot;AAPL&quot;)
info = stock.info  # Yahoo Finance API call occurs
# Return Value (Python Function &amp;rarr; Returned to Google ADK)
{
  &quot;ticker&quot;: &quot;AAPL&quot;,
  &quot;success&quot;: True,
  &quot;company_name&quot;: &quot;Apple Inc.&quot;,
  &quot;industry&quot;: &quot;Consumer Electronics&quot;,
  &quot;sector&quot;: &quot;Technology&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;78&quot;&gt;&lt;i data-path-to-node=&quot;78&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Python function get_company_info (Receiving data from Yahoo Finance API)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;78&quot; data-index-in-node=&quot;84&quot;&gt;Receiver: Google ADK (Data Analyst Sub-agent System)&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;79&quot;&gt;&lt;b data-path-to-node=&quot;79&quot; data-index-in-node=&quot;0&quot;&gt;Function Execution 2&lt;/b&gt;: get_stock_price(&quot;AAPL&quot;, &quot;1y&quot;)&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;stock = yf.Ticker(&quot;AAPL&quot;)
history = stock.history(period=&quot;1y&quot;)  # Requesting 1 year of price data
# Return Value (Python Function &amp;rarr; Returned to Google ADK)
{
  &quot;ticker&quot;: &quot;AAPL&quot;,
  &quot;success&quot;: True,
  &quot;history&quot;: &quot;{\&quot;Open\&quot;: {...}, \&quot;High\&quot;: {...}, \&quot;Low\&quot;: {...}, \&quot;Close\&quot;: {...}, \&quot;Volume\&quot;: {...}}&quot;,
  &quot;current_price&quot;: 175.43
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;81&quot;&gt;&lt;i data-path-to-node=&quot;81&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Python function get_stock_price (Receiving data from Yahoo Finance API)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;81&quot; data-index-in-node=&quot;83&quot;&gt;Receiver: Google ADK (Data Analyst Sub-agent System)&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;82&quot;&gt;&lt;b data-path-to-node=&quot;82&quot; data-index-in-node=&quot;0&quot;&gt;Function Execution 3&lt;/b&gt;: get_financial_metrics(&quot;AAPL&quot;)&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;Python&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;stock = yf.Ticker(&quot;AAPL&quot;)
info = stock.info
# Return Value (Python Function &amp;rarr; Returned to Google ADK)
{
  &quot;ticker&quot;: &quot;AAPL&quot;,
  &quot;success&quot;: True,
  &quot;market_cap&quot;: 2700000000000,  # 2.7 Trillion USD
  &quot;pe_ratio&quot;: 28.5,
  &quot;dividend_yield&quot;: 0.0052,  # 0.52%
  &quot;beta&quot;: 1.23
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;84&quot;&gt;&lt;i data-path-to-node=&quot;84&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Python function get_financial_metrics (Receiving data from Yahoo Finance API)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;84&quot; data-index-in-node=&quot;89&quot;&gt;Receiver: Google ADK (Data Analyst Sub-agent System)&lt;/i&gt;&lt;/p&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;85&quot;&gt;2-3. Data Analyst LLM Call #3 (Result Analysis)&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;86&quot;&gt;&lt;b data-path-to-node=&quot;86&quot; data-index-in-node=&quot;0&quot;&gt;Request Sent from Google ADK &amp;rarr; OpenAI GPT-4o API&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;(Previous conversation + Tool execution results):&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;messages&quot;: [
    {
      &quot;role&quot;: &quot;system&quot;,
      &quot;content&quot;: &quot;You are a Data Analyst...&quot;
    },
    {
      &quot;role&quot;: &quot;user&quot;,
      &quot;content&quot;: &quot;Analyze ticker: AAPL&quot;
    },
    {
      &quot;role&quot;: &quot;assistant&quot;,
      &quot;content&quot;: null,
      &quot;tool_calls&quot;: [...]
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;, \&quot;success\&quot;: true, \&quot;company_name\&quot;: \&quot;Apple Inc.\&quot;, ...}&quot;
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;, \&quot;success\&quot;: true, \&quot;history\&quot;: \&quot;{...}\&quot;, \&quot;current_price\&quot;: 175.43}&quot;
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;{\&quot;ticker\&quot;: \&quot;AAPL\&quot;, \&quot;success\&quot;: true, \&quot;market_cap\&quot;: 2700000000000, ...}&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;88&quot;&gt;&lt;i data-path-to-node=&quot;88&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Google ADK (Data Analyst Sub-agent System - Includes previous chat history and tool execution results)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;88&quot; data-index-in-node=&quot;114&quot;&gt;Receiver: OpenAI GPT-4o API&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;89&quot;&gt;&lt;b data-path-to-node=&quot;89&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is a request for the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;89&quot; data-index-in-node=&quot;61&quot;&gt;Data Analyst to analyze the collected raw data and convert it into meaningful text&lt;/b&gt;.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;90&quot;&gt;&lt;b data-path-to-node=&quot;90&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;91&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;91,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Maintaining Conversation History&lt;/b&gt;: Includes previous requests (user) and responses (assistant's tool_calls) so the LLM understands context.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;91,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Data Delivery&lt;/b&gt;: Provides the LLM with the actual data (JSON) collected from the 3 tools.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;91,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Analysis Task Instruction&lt;/b&gt;: Requests the LLM to &quot;analyze this data and convert it into text the user can understand.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;92&quot;&gt;&lt;b data-path-to-node=&quot;92&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;93&quot;&gt;
&lt;li&gt;The LLM checks the tools it previously called (tool_calls) and their results (tool messages).&lt;/li&gt;
&lt;li&gt;The LLM comprehensively analyzes the collected data (company info, stock price, financial metrics).&lt;/li&gt;
&lt;li&gt;The LLM interprets the raw data and generates structured analysis text.&lt;/li&gt;
&lt;li&gt;The generated text is returned to Google ADK and automatically saved to the state based on the output_key setting.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;94&quot;&gt;&lt;b data-path-to-node=&quot;94&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;95&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;95,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Data &amp;rarr; Insight Conversion&lt;/b&gt;: Converts raw JSON data into a human-readable analysis report.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;95,1,0&quot; data-index-in-node=&quot;0&quot;&gt;State Storage&lt;/b&gt;: The analysis result is saved in state[&quot;data_analyst_result&quot;], making it available for the Main Agent later.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;95,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Progression&lt;/b&gt;: The Data Analyst's task is complete, allowing the Main Agent to proceed to the next step (calling Financial Analyst).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;96&quot;&gt;&lt;b data-path-to-node=&quot;96&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;97&quot;&gt;
&lt;li&gt;The role: &quot;tool&quot; message is the way tool function return values are passed to the LLM (OpenAI API standard format).&lt;/li&gt;
&lt;li&gt;Reason content is a JSON string: The dictionary returned by the tool function is serialized into JSON.&lt;/li&gt;
&lt;li&gt;Why call the LLM again? &amp;rarr; Raw data has no meaning on its own; the LLM must interpret it to derive insights.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;98&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;99&quot;&gt;&lt;b data-path-to-node=&quot;99&quot; data-index-in-node=&quot;0&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API (LLM Response #3 - Final Analysis Text)&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;**Company Overview:**
Apple Inc. is a technology company in the Consumer Electronics industry...
**Current Pricing:**
Current price: $175.43
Market Cap: $2.7 trillion
P/E Ratio: 28.5 (indicating premium valuation)
1-year price range: $164.08 - $198.23
**Financial Metrics:**
Dividend Yield: 0.52% (moderate income component)
Beta: 1.23 (slightly more volatile than market)&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;101&quot;&gt;&lt;i data-path-to-node=&quot;101&quot; data-index-in-node=&quot;0&quot;&gt;Generator: OpenAI GPT-4o LLM (for Data Analyst Agent)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;101&quot; data-index-in-node=&quot;54&quot;&gt;Receiver: Google ADK&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;101&quot; data-index-in-node=&quot;75&quot;&gt;State Storage: Google ADK automatically saves to state[&quot;data_analyst_result&quot;] according to output_key=&quot;data_analyst_result&quot; setting&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;102&quot;&gt;&lt;b data-path-to-node=&quot;102&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON (Text Response)&lt;/b&gt;: This text is the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;102&quot; data-index-in-node=&quot;63&quot;&gt;final output of the Data Analyst sub-agent&lt;/b&gt;, the result of analyzing the raw data.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;103&quot;&gt;&lt;b data-path-to-node=&quot;103&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;104&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;104,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Analysis Result Output&lt;/b&gt;: Generates structured analysis text by interpreting collected data.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;104,1,0&quot; data-index-in-node=&quot;0&quot;&gt;State Storage&lt;/b&gt;: Automatically saved to state according to output_key setting, making it usable by other agents.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;104,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Task Completion Signal&lt;/b&gt;: The Data Analyst's task is complete, and control is returned to the Main Agent.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;105&quot;&gt;&lt;b data-path-to-node=&quot;105&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this text&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;106&quot;&gt;
&lt;li&gt;Google ADK receives this text and checks the output_key=&quot;data_analyst_result&quot; setting.&lt;/li&gt;
&lt;li&gt;Google ADK automatically saves state[&quot;data_analyst_result&quot;] = &quot;Text Content&quot;.&lt;/li&gt;
&lt;li&gt;The Data Analyst sub-agent's task is finished.&lt;/li&gt;
&lt;li&gt;The Main Agent sees this result and decides the next step (calling Financial Analyst).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;107&quot;&gt;&lt;b data-path-to-node=&quot;107&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;108&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;108,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Data Sharing&lt;/b&gt;: Saved in state so the Main Agent and other functions (save_advice_report) can access it.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;108,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Chain&lt;/b&gt;: The Main Agent looks at this result to decide whether to call the next sub-agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;108,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Final Report Composition&lt;/b&gt;: Later, the save_advice_report function will include this text to create the comprehensive report.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;109&quot;&gt;&lt;b data-path-to-node=&quot;109&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;110&quot;&gt;
&lt;li&gt;Why is it in text format? &amp;rarr; LLM output is always text, and state can only store strings.&lt;/li&gt;
&lt;li&gt;Why is it automatically saved to State? &amp;rarr; Because the output_key parameter is set (Code: data_analyst = LlmAgent(..., output_key=&quot;data_analyst_result&quot;)).&lt;/li&gt;
&lt;li&gt;How is this text passed to the Main Agent? &amp;rarr; Indirectly via State (The Main Agent reads from the state).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;111&quot; /&gt;
&lt;h3 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size23&quot; data-path-to-node=&quot;112&quot;&gt;Step 5: Main Agent's Final Analysis and Advice&lt;/h3&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;113&quot;&gt;5-1. Main Agent LLM Call #10 (Comprehensive Analysis)&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;114&quot;&gt;&lt;b data-path-to-node=&quot;114&quot; data-index-in-node=&quot;0&quot;&gt;Request Sent from Google ADK &amp;rarr; OpenAI GPT-4o API&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;messages&quot;: [
    {
      &quot;role&quot;: &quot;system&quot;,
      &quot;content&quot;: &quot;[PROMPT content - including asking for user preferences]&quot;
    },
    {
      &quot;role&quot;: &quot;user&quot;,
      &quot;content&quot;: &quot;Give me investment advice for AAPL stock&quot;
    },
    {
      &quot;role&quot;: &quot;assistant&quot;,
      &quot;content&quot;: null,
      &quot;tool_calls&quot;: [{&quot;name&quot;: &quot;data_analyst&quot;, ...}]
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;[data_analyst result]&quot;
    },
    {
      &quot;role&quot;: &quot;assistant&quot;,
      &quot;content&quot;: null,
      &quot;tool_calls&quot;: [{&quot;name&quot;: &quot;financial_analyst&quot;, ...}]
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;[financial_analyst result]&quot;
    },
    {
      &quot;role&quot;: &quot;assistant&quot;,
      &quot;content&quot;: null,
      &quot;tool_calls&quot;: [{&quot;name&quot;: &quot;news_analyst&quot;, ...}]
    },
    {
      &quot;role&quot;: &quot;tool&quot;,
      &quot;content&quot;: &quot;[news_analyst result]&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;116&quot;&gt;&lt;i data-path-to-node=&quot;116&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Google ADK (Main Agent System - Includes results from all sub-agents)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;116&quot; data-index-in-node=&quot;81&quot;&gt;Receiver: OpenAI GPT-4o API&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;117&quot;&gt;&lt;b data-path-to-node=&quot;117&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON represents the stage where the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;117&quot; data-index-in-node=&quot;71&quot;&gt;Main Agent synthesizes the analysis results from all sub-agents before generating the final advice&lt;/b&gt;.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;118&quot;&gt;&lt;b data-path-to-node=&quot;118&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;119&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;119,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Conversation History Accumulation&lt;/b&gt;: Full conversation record from user request to all sub-agent calls and results.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;119,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Context Integration&lt;/b&gt;: Enables comprehensive judgment by including results from Data Analyst, Financial Analyst, and News Analyst.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;119,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Preparation for Final Decision&lt;/b&gt;: Preparation to generate advice tailored to the user based on all analysis data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;120&quot;&gt;&lt;b data-path-to-node=&quot;120&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;121&quot;&gt;
&lt;li&gt;The LLM reviews the entire conversation history to understand the situation.&lt;/li&gt;
&lt;li&gt;The LLM checks the analysis results of all 3 sub-agents.&lt;/li&gt;
&lt;li&gt;The LLM checks &quot;INVESTMENT RECOMMENDATION PROCESS&quot; in the prompt.&lt;/li&gt;
&lt;li&gt;The LLM determines that user preferences (investment goal, risk tolerance, time horizon) are needed.&lt;/li&gt;
&lt;li&gt;The LLM generates text to ask the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;122&quot;&gt;&lt;b data-path-to-node=&quot;122&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;123&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;123,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Tailored Advice&lt;/b&gt;: By asking for user preferences first, personalized investment advice can be provided.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;123,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Delay&lt;/b&gt;: The process is paused as it must wait for the user's additional response.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;123,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Conversational Interaction&lt;/b&gt;: Provides a personalized service through dialogue rather than simple one-way advice.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;124&quot;&gt;&lt;b data-path-to-node=&quot;124&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;125&quot;&gt;
&lt;li&gt;[data_analyst result] in the role: &quot;tool&quot; message is the return value of the sub-agent call, not the value read from the state.&lt;/li&gt;
&lt;li&gt;Why ask the user at this point? &amp;rarr; Because there is an instruction in the prompt: &quot;Before providing any BUY/SELL/HOLD recommendation, you MUST: Ask about...&quot;&lt;/li&gt;
&lt;li&gt;Reason for including all sub-agent results: The LLM needs all information to make a comprehensive judgment.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;126&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;127&quot;&gt;&lt;b data-path-to-node=&quot;127&quot; data-index-in-node=&quot;0&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API (LLM Response #10 - User Preference Question)&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;Before providing investment advice, I need some information:
1. **Investment Goal**: Do you want growth investing, income investing, or short-term trading?
2. **Risk Tolerance**: Do you have a conservative, neutral, or aggressive investment preference?
3. **Time Horizon**: Short-term (under 1 year), Medium-term (1-3 years), or Long-term (over 3 years)?
If you provide this information, I will provide a tailored investment recommendation for AAPL.&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;129&quot;&gt;&lt;i data-path-to-node=&quot;129&quot; data-index-in-node=&quot;0&quot;&gt;Generator: OpenAI GPT-4o LLM (for Main Agent)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;129&quot; data-index-in-node=&quot;46&quot;&gt;Receiver: Google ADK &amp;rarr; Displayed to User&lt;/i&gt;&lt;/p&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;130&quot;&gt;5-2. User Response (Example)&lt;/h4&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;Investment Goal: Growth Investing
Risk Tolerance: Neutral
Time Horizon: Long-term (over 3 years)&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;132&quot; /&gt;
&lt;h4 style=&quot;color: #000000; text-align: start;&quot; data-ke-size=&quot;size20&quot; data-path-to-node=&quot;133&quot;&gt;5-3. Main Agent LLM Call #11 (Final Advice Generation)&lt;/h4&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;134&quot;&gt;&lt;b data-path-to-node=&quot;134&quot; data-index-in-node=&quot;0&quot;&gt;Request Sent from Google ADK &amp;rarr; OpenAI GPT-4o API&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;(Including User Response):&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;{
  &quot;messages&quot;: [
    ... (Entire previous conversation),
    {
      &quot;role&quot;: &quot;user&quot;,
      &quot;content&quot;: &quot;Investment Goal: Growth Investing\nRisk Tolerance: Neutral\nTime Horizon: Long-term (over 3 years)&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;136&quot;&gt;&lt;i data-path-to-node=&quot;136&quot; data-index-in-node=&quot;0&quot;&gt;Generator: Google ADK (Main Agent System - User response added)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;136&quot; data-index-in-node=&quot;64&quot;&gt;Receiver: OpenAI GPT-4o API&lt;/i&gt;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;137&quot;&gt;&lt;b data-path-to-node=&quot;137&quot; data-index-in-node=&quot;0&quot;&gt;Role and Impact of this JSON&lt;/b&gt;: This JSON is the request to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b data-path-to-node=&quot;137&quot; data-index-in-node=&quot;58&quot;&gt;generate the final investment advice by adding the user's preference information&lt;/b&gt;.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;138&quot;&gt;&lt;b data-path-to-node=&quot;138&quot; data-index-in-node=&quot;0&quot;&gt;Role in the Overall Process&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;139&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;139,0,0&quot; data-index-in-node=&quot;0&quot;&gt;User Input Addition&lt;/b&gt;: Adds the preference information provided by the user to the conversation history.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;139,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Preparation for Comprehensive Judgment&lt;/b&gt;: Preparation to generate final advice based on all analysis data (sub-agent results) + user preferences.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;139,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Completion Phase&lt;/b&gt;: Generating the final output with all information collected.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;140&quot;&gt;&lt;b data-path-to-node=&quot;140&quot; data-index-in-node=&quot;0&quot;&gt;What happens via this JSON&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;141&quot;&gt;
&lt;li&gt;The LLM checks the user's preference information (Growth, Neutral, Long-term).&lt;/li&gt;
&lt;li&gt;The LLM synthesizes the analysis results of the 3 sub-agents and the user preferences.&lt;/li&gt;
&lt;li&gt;The LLM decides BUY/SELL/HOLD according to &quot;RECOMMENDATION REQUIREMENTS&quot; in the prompt.&lt;/li&gt;
&lt;li&gt;The LLM generates specific advice text (including strengths, risk factors, target price, etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;142&quot;&gt;&lt;b data-path-to-node=&quot;142&quot; data-index-in-node=&quot;0&quot;&gt;Impact&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;143&quot;&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;143,0,0&quot; data-index-in-node=&quot;0&quot;&gt;Final Output Generation&lt;/b&gt;: The investment advice, the core purpose of the system, is completed.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;143,1,0&quot; data-index-in-node=&quot;0&quot;&gt;Tailored Result&lt;/b&gt;: Provides personalized advice tailored to the user's preferences.&lt;/li&gt;
&lt;li&gt;&lt;b data-path-to-node=&quot;143,2,0&quot; data-index-in-node=&quot;0&quot;&gt;Process Completion&lt;/b&gt;: Major analysis tasks are completed, and the result is provided to the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;144&quot;&gt;&lt;b data-path-to-node=&quot;144&quot; data-index-in-node=&quot;0&quot;&gt;Confusing Parts&lt;/b&gt;:&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot; data-path-to-node=&quot;145&quot;&gt;
&lt;li&gt;... (Entire previous conversation) actually includes hundreds of lines of conversation history (abbreviated here).&lt;/li&gt;
&lt;li&gt;Why is the entire previous conversation needed? &amp;rarr; So the LLM can understand the context and generate a consistent response.&lt;/li&gt;
&lt;li&gt;Reason user response is added as role: &quot;user&quot;: To maintain the continuity of the conversation.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-ke-style=&quot;style1&quot; data-path-to-node=&quot;146&quot; /&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;147&quot;&gt;&lt;b data-path-to-node=&quot;147&quot; data-index-in-node=&quot;0&quot;&gt;Response received by Google ADK from OpenAI GPT-4o API (LLM Response #11 - Final Investment Advice)&lt;/b&gt;:&lt;/p&gt;
&lt;div style=&quot;color: #333333; text-align: start;&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #f8f8f8; color: #383a42;&quot;&gt;&lt;code&gt;&quot;**AAPL (Apple Inc.) Investment Recommendation: BUY**
**Comprehensive Analysis Summary:**
**Strengths:**
- Strong Financial Health: Free Cash Flow $99.6B, Good Debt Ratio
- Stable Profitability: Operating Margin 30.2%, Net Income $97B
- Services Segment Growth: 15% YoY increase
- Premium Valuation: P/E 28.5 (Reflecting growth expectations)
**Risk Factors:**
- Exposure to the Chinese market
- Potential short-term volatility due to premium valuation
**Investment Recommendation (Neutral Risk, Long-term Growth):**
BUY - Target Price: $210 (12 months)
AAPL is suitable for long-term growth investment. Strong financial health and growth in the services sector are expected to continue.&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot; data-path-to-node=&quot;149&quot;&gt;&lt;i data-path-to-node=&quot;149&quot; data-index-in-node=&quot;0&quot;&gt;Generator: OpenAI GPT-4o LLM (for Main Agent)&lt;/i&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;i data-path-to-node=&quot;149&quot; data-index-in-node=&quot;46&quot;&gt;Receiver: Google ADK &amp;rarr; Displayed to User&lt;/i&gt;&lt;/p&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/34</guid>
      <comments>https://note24432.tistory.com/34#entry34comment</comments>
      <pubDate>Sat, 3 Jan 2026 03:09:26 +0900</pubDate>
    </item>
    <item>
      <title>Google ADK: Financial Advisor(2)- full code</title>
      <link>https://note24432.tistory.com/33</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;agent.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;genai &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; types&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tools &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; ToolContext&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent_tool &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; AgentTool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;models&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;lite_llm &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; LiteLlm&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sub_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data_analyst &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; data_analyst&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sub_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;financial_analyst &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; financial_analyst&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sub_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;news_analyst &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; news_analyst&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;prompt &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; PROMPT&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;LiteLlm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;openai/gpt-4o&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;save_advice_report&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;tool_context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ToolContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; state &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; tool_context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;state&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; data_analyst_result &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;data_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; financial_analyst_result &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;financial_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; news_analyst_analyst_result &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;news_analyst_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; report &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Excetuve Summary and Advice:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ## Data Analyst Report:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data_analyst_result&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ## Financial Analyst Report:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;financial_analyst_result&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ## News Analyst Report:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;news_analyst_analyst_result&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;report&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; report&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; filename &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;_investment_advice.md&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; artifact &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; types&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Part&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;inline_data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;types&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Blob&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;mime_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;text/markdown&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;report&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;encode&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; tool_context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;save_artifact&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;filename&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; artifact&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;financial_advisor &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;FinancialAdvisor&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instruction&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;PROMPT&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;AgentTool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;financial_analyst&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;AgentTool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;news_analyst&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;AgentTool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data_analyst&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; save_advice_report&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;root_agent &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; financial_advisor&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;promt.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;PROMPT &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;You are a Professional Financial Advisor specializing in equity analysis and investment recommendations. You ONLY provide advice on stocks, trading, and investment decisions.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**STRICT SCOPE LIMITATIONS:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- ONLY answer questions about stocks, trading, investments, financial markets, and company analysis&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- REFUSE to answer questions about: general knowledge, technology help, personal advice unrelated to finance, or any non-financial topics&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- If asked about non-financial topics, politely redirect: &quot;I'm a specialized financial advisor. I can only help with stock analysis and investment decisions.&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**INVESTMENT RECOMMENDATION PROCESS:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;Before providing any BUY/SELL/HOLD recommendation, you MUST:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;1. Ask about the user's investment goals (growth, income, speculation, etc.)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;2. Ask about their risk tolerance (conservative, moderate, aggressive)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;3. Ask about their investment timeline (short-term, medium-term, long-term)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**RECOMMENDATION REQUIREMENTS:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;After gathering user preferences, you MUST provide a clear recommendation:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **BUY**: Strong positive outlook with specific price targets and rationale&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **SELL**: Negative outlook with clear reasons to exit&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **HOLD**: Neutral position with conditions for future action&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**Available Specialized Tools:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **data_analyst**: Gathers market data, company info, pricing, and financial metrics&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **news_analyst**: Searches current news and industry information using web tools&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **financial_analyst**: Analyzes detailed financial statements including income, balance sheet, and cash flow&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**Direct Tools:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- **save_company_report()**: Save comprehensive reports as artifacts (use ONLY when user requests a report and you have all the data you need for it.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**ANALYSIS METHODOLOGY:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;For thorough analysis, you should:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;1. Gather quantitative data (financial metrics, performance, valuation)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;2. Research current news and market sentiment&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;3. Analyze financial statements for fundamental strength&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;4. Consider user's specific goals and risk profile&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;5. Provide confident recommendation with clear reasoning&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**REPORT REQUIREMENTS:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;When creating reports, include:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Executive Summary with clear BUY/SELL/HOLD recommendation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Fundamental Analysis (financial health, valuation metrics)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Technical Analysis (price trends, momentum)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- News and Market Sentiment Analysis&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Risk Assessment specific to user's tolerance&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Price Targets and Timeline&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Action Plan with entry/exit strategies&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**Communication Style:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Be confident and decisive in recommendations&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Use specific data points and metrics&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Explain reasoning clearly with supporting evidence&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Provide actionable investment guidance&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;- Show conviction in your analysis&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;You are an expert who makes money for clients through sound investment decisions. Be opinionated and confident.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;__init__.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agent&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;data_analyst.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yfinance &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; LlmAgent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;models&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;lite_llm &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; LiteLlm&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;LiteLlm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;openai/gpt-4o&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_company_info&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Retrieves basic company information for a given stock ticker.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool fetches fundamental company details including the official company name,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; industry classification, and sector categorization from Yahoo Finance.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): The stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - company_name (str): Full legal name of the company&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - industry (str): Specific industry classification&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - sector (str): Broader sector categorization&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_company_info('MSFT')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'MSFT',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'company_name': 'Microsoft Corporation',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'industry': 'Software - Infrastructure',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'sector': 'Technology'&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; info &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;info&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;company_name&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;longName&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;industry&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;industry&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;sector&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;sector&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_stock_price&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;period&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Fetches historical stock price data and current trading price for a given ticker.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool retrieves both the current market price and historical price data&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; over a specified time period, including open, high, low, close prices and volume.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; period (str): Time period for historical data. Valid options:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '1d': 1 day&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '5d': 5 days&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '1mo': 1 month (default)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '3mo': 3 months&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '6mo': 6 months&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '1y': 1 year&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '2y': 2 years&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '5y': 5 years&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - '10y': 10 years&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - 'ytd': Year to date&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - 'max': Maximum available data&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - history (str): JSON-formatted historical price data with OHLCV&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - current_price (float): Current market price of the stock&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_stock_price('TSLA', '3mo')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'TSLA',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'history': '{&quot;Open&quot;: {...}, &quot;High&quot;: {...}, ...}',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'current_price': 245.67&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; info &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;info&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; history &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;history&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;period&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;period&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;history&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: history&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;to_json&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;current_price&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;currentPrice&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_financial_metrics&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Retrieves key financial metrics and valuation ratios for stock analysis.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool fetches essential financial indicators that help assess a company's&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; valuation, profitability, dividend policy, and market risk characteristics.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - market_cap (float): Total market capitalization in USD&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - pe_ratio (float): Trailing Price-to-Earnings ratio (price/earnings per share)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - dividend_yield (float): Annual dividend yield as a percentage (0.02 = 2%)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - beta (float): Stock's beta coefficient measuring volatility vs market&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Notes:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Market Cap: Represents company's total value (shares * price)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - P/E Ratio: Lower may indicate undervalued; higher may indicate growth expectations&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Dividend Yield: Annual dividends as percentage of stock price&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Beta: &amp;lt;1 means less volatile than market; &amp;gt;1 means more volatile&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_financial_metrics('JNJ')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'JNJ',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'market_cap': 385000000000,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'pe_ratio': 15.2,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'dividend_yield': 0.031,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'beta': 0.65&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; info &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;info&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;market_cap&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;marketCap&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;pe_ratio&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;trailingPE&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;dividend_yield&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;dividendYield&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;beta&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;beta&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NA&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data_analyst &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;LlmAgent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;DataAnalyst&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;description&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Gathers and analyzes basic stock market data using multiple focused tools&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instruction&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You are a Data Analyst who gathers stock information using 4 specialized tools:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 1. **get_company_info(ticker)** - Learn about the company (name, sector, industry)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 2. **get_stock_price(ticker, period)** - Get current pricing and trading ranges&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 3. **get_financial_metrics(ticker)** - Check key financial ratios &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Use multiple focused tools to gather different types of data.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Explain what each tool provides and present the information clearly.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_company_info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_stock_price&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_financial_metrics&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_key&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;data_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;financial_analyst.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yfinance &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;models&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;lite_llm &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; LiteLlm&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;LiteLlm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;openai/gpt-4o&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_income_statement&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Retrieves the income statement for comprehensive revenue and profitability analysis.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool fetches detailed income statement data showing a company's financial&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; performance over recent reporting periods, including revenues, expenses, and&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; profit margins at various levels.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - income_statement (str): JSON-formatted income statement data including:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Total Revenue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Cost of Revenue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Gross Profit&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Operating Expenses&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Operating Income&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * EBITDA&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Net Income&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Earnings Per Share (EPS)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Notes:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Data typically covers the last 4 quarters and annual periods&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - All financial figures are in the company's reporting currency&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Useful for analyzing revenue growth, margin trends, and profitability&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_income_statement('GOOGL')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'GOOGL',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'income_statement': '{&quot;Total Revenue&quot;: {...}, &quot;Net Income&quot;: {...}}'&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# return stock.income_stmt.to_json()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;income_statement&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;income_stmt&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;to_json&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_balance_sheet&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Retrieves the balance sheet for analyzing financial position and capital structure.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool fetches comprehensive balance sheet data showing a company's assets,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; liabilities, and shareholders' equity at specific points in time, providing&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; insight into financial health and capital efficiency.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - balance_sheet (str): JSON-formatted balance sheet data including:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Current Assets (cash, receivables, inventory)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Non-Current Assets (PP&amp;amp;E, intangibles, investments)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Current Liabilities (payables, short-term debt)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Non-Current Liabilities (long-term debt, deferred items)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Total Shareholders' Equity&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Working Capital components&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Notes:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Provides snapshot of financial position at quarter/year end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Essential for calculating liquidity ratios (current ratio, quick ratio)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Used to assess debt levels, asset efficiency, and book value&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - All values in company's reporting currency&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_balance_sheet('AMZN')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'AMZN',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'balance_sheet': '{&quot;Total Assets&quot;: {...}, &quot;Total Liabilities&quot;: {...}}'&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# return stock.balance_sheet.to_json()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;balance_sheet&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;balance_sheet&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;to_json&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;get_cash_flow&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Retrieves the cash flow statement for analyzing cash generation and capital allocation.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; This tool fetches detailed cash flow data showing how a company generates and&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; uses cash across operating, investing, and financing activities, crucial for&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; assessing financial sustainability and growth capacity.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ticker (str): Stock ticker symbol (e.g., 'AAPL' for Apple Inc.)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Returns:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dict: A dictionary containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - ticker (str): The input ticker symbol&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - success (bool): True if the operation was successful&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - cash_flow (str): JSON-formatted cash flow statement including:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Operating Cash Flow (cash from core business)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Capital Expenditures (CapEx)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Free Cash Flow (Operating CF - CapEx)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Investing Activities (acquisitions, investments)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Financing Activities (debt, dividends, buybacks)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Net Change in Cash&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Notes:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Operating cash flow indicates core business cash generation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Free cash flow shows cash available for shareholders/growth&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Negative investing CF often indicates growth investment&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Financing CF reveals capital structure decisions&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Critical for assessing dividend sustainability and growth funding&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Example:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;get_cash_flow('META')&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'ticker': 'META',&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'success': True,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'cash_flow': '{&quot;Operating Cash Flow&quot;: {...}, &quot;Free Cash Flow&quot;: {...}}'&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; stock &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; yf&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# return stock.balance_sheet.to_json()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ticker&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: ticker&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: True&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;cash_flow&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: stock&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;cash_flow&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;to_json&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;financial_analyst &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;FinancialAnalyst&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;description&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Analyzes detailed financial statements including income, balance sheet, and cash flow&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instruction&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You are a Financial Analyst who performs deep financial statement analysis. Your job:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 1. **Income Analysis**: Use get_income_statement() to analyze revenue, profitability, and margins&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 2. **Balance Sheet Analysis**: Use get_balance_sheet() to examine assets, liabilities, and financial position&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 3. **Cash Flow Analysis**: Use get_cash_flow() to assess cash generation and capital allocation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; **Your Financial Tools:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - **get_income_statement(ticker)**: Revenue, profit margins, and profitability analysis&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - **get_balance_sheet(ticker)**: Assets, debt, equity, and financial strength ratios&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - **get_cash_flow(ticker)**: Operating cash flow, free cash flow, and capital expenditure&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Analyze the financial health and performance of companies using comprehensive financial statement data.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Focus on key financial ratios, trends, and indicators that reveal the company's financial strength.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_income_statement&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_balance_sheet&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get_cash_flow&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_key&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;financial_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;news_analyst.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; google&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;adk&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;models&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;lite_llm &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; LiteLlm&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; tools &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; web_search_tool&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;LiteLlm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;openai/gpt-4o&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;news_analyst &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;NewsAnalyst&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;MODEL&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;description&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Uses Web Search tools to search and scrape real web content from the web.&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instruction&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You are a News Analyst Specialist who uses web tools to find current information. Your job:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 1. **Web Search**: Use web_search_tool() to find recent news about a company.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 3. **Summarize Findings**: Explain what you found and its relevance&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; **Your Web Tools:**&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - **web_search_tool()**: Firecrawl web search for company news&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Use external APIs to search and scrape web content for current information.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_key&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;news_analyst_result&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; web_search_tool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/33</guid>
      <comments>https://note24432.tistory.com/33#entry33comment</comments>
      <pubDate>Sat, 3 Jan 2026 02:43:00 +0900</pubDate>
    </item>
    <item>
      <title>Google ADK: Financial Advisor(1)- setup</title>
      <link>https://note24432.tistory.com/32</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;Now we learn about google adk.&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;By using this wonderful tool, you don't have to code frontend ui when your goal is just debugging and checking if code is alright as developer.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;First of all, you set up files like this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;221&quot; data-origin-height=&quot;603&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/z2Y41/dJMcahXoQCb/CKgKa37iMikrz5W1m922n1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/z2Y41/dJMcahXoQCb/CKgKa37iMikrz5W1m922n1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/z2Y41/dJMcahXoQCb/CKgKa37iMikrz5W1m922n1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fz2Y41%2FdJMcahXoQCb%2FCKgKa37iMikrz5W1m922n1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;221&quot; height=&quot;603&quot; data-origin-width=&quot;221&quot; data-origin-height=&quot;603&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;And pyproject.toml file is&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;[project] &lt;br /&gt;name&amp;nbsp;=&amp;nbsp;&quot;financial-analyst&quot; &lt;br /&gt;version&amp;nbsp;=&amp;nbsp;&quot;0.1.0&quot; &lt;br /&gt;description&amp;nbsp;=&amp;nbsp;&quot;Add&amp;nbsp;your&amp;nbsp;description&amp;nbsp;here&quot; &lt;br /&gt;readme&amp;nbsp;=&amp;nbsp;&quot;README.md&quot; &lt;br /&gt;requires-python&amp;nbsp;=&amp;nbsp;&quot;&amp;gt;=3.12&quot; &lt;br /&gt;dependencies&amp;nbsp;=&amp;nbsp;[ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;firecrawl-py==2.16.3&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;google-adk&amp;gt;=1.11.0&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;google-genai&amp;gt;=1.31.0&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;litellm&amp;gt;=1.75.8&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;python-dotenv&amp;gt;=1.1.1&quot;, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;yfinance&amp;gt;=0.2.65&quot;, &lt;br /&gt;] &lt;br /&gt;&lt;br /&gt;[dependency-groups] &lt;br /&gt;dev&amp;nbsp;=&amp;nbsp;[ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;watchdog&amp;gt;=6.0.0&quot;, &lt;br /&gt;]&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;then, you run &lt;b&gt;uv sync&amp;nbsp;&lt;/b&gt;in terminal at out folder(big project), not in inside folder.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;586&quot; data-origin-height=&quot;686&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bcKNSz/dJMcaiornbs/xIixzfJqugiVKKbBTKcark/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bcKNSz/dJMcaiornbs/xIixzfJqugiVKKbBTKcark/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bcKNSz/dJMcaiornbs/xIixzfJqugiVKKbBTKcark/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbcKNSz%2FdJMcaiornbs%2FxIixzfJqugiVKKbBTKcark%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;586&quot; height=&quot;686&quot; data-origin-width=&quot;586&quot; data-origin-height=&quot;686&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;then if you run terminl&lt;b&gt; &quot;uv run adk web&quot;&lt;/b&gt; , you can recieve local page url.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;877&quot; data-origin-height=&quot;697&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/5CSe9/dJMcaacSGtp/Avkwdgv6184uVR99sSt1lK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/5CSe9/dJMcaacSGtp/Avkwdgv6184uVR99sSt1lK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/5CSe9/dJMcaacSGtp/Avkwdgv6184uVR99sSt1lK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F5CSe9%2FdJMcaacSGtp%2FAvkwdgv6184uVR99sSt1lK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;877&quot; height=&quot;697&quot; data-origin-width=&quot;877&quot; data-origin-height=&quot;697&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1910&quot; data-origin-height=&quot;851&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/oGUbB/dJMcaaYgnA5/o4KitONGJfHSubDrKXyEU0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/oGUbB/dJMcaaYgnA5/o4KitONGJfHSubDrKXyEU0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/oGUbB/dJMcaaYgnA5/o4KitONGJfHSubDrKXyEU0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FoGUbB%2FdJMcaaYgnA5%2Fo4KitONGJfHSubDrKXyEU0%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1910&quot; height=&quot;851&quot; data-origin-width=&quot;1910&quot; data-origin-height=&quot;851&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/32</guid>
      <comments>https://note24432.tistory.com/32#entry32comment</comments>
      <pubDate>Sat, 3 Jan 2026 02:38:38 +0900</pubDate>
    </item>
    <item>
      <title>OPEN AI SDK - Customer support agent(5) - Output_gaurdrail</title>
      <link>https://note24432.tistory.com/26</link>
      <description>&lt;h4 data-path-to-node=&quot;3&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;3&quot;&gt;1. Purpose and Concept of Output Guardrail&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;4&quot; data-ke-size=&quot;size16&quot;&gt;The Output Guardrail validates the response generated by the agent to check if it contains inappropriate content. Specifically, it ensures the &lt;b data-index-in-node=&quot;143&quot; data-path-to-node=&quot;4&quot;&gt;Technical Support Agent&lt;/b&gt; does not include content unrelated to technical support (such as billing, orders, account management, etc.).&lt;/p&gt;
&lt;p data-path-to-node=&quot;5&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;5&quot;&gt;Core Concepts:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;6&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6,0,0&quot;&gt;Automated Verification:&lt;/b&gt; Checks immediately after response generation.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6,1,0&quot;&gt;Role Separation:&lt;/b&gt; Maintains strict role boundaries for the agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6,2,0&quot;&gt;Blocking:&lt;/b&gt; Prevents inappropriate responses from reaching the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;7&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;8&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;8&quot;&gt;2. Data Model Definition&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;9&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9&quot;&gt;A. TechnicalOutputGuardRailOutput Model&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;angelscript&quot;&gt;&lt;code&gt;class TechnicalOutputGuardRailOutput(BaseModel):

    contains_off_topic: bool
    contains_billing_data: bool
    contains_account_data: bool
    reason: str
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;12&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;12&quot;&gt;Field Explanations:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;13&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;contains_off_topic: Whether the response contains off-topic content.&lt;/li&gt;
&lt;li&gt;contains_billing_data: Whether the response contains billing-related content.&lt;/li&gt;
&lt;li&gt;contains_account_data: Whether the response contains account management-related content.&lt;/li&gt;
&lt;li&gt;reason: The reason for the validation result.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;14&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;15&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;15&quot;&gt;3. Guardrail Agent Definition&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;16&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;16&quot;&gt;A. technical_output_guardrail_agent&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;sql&quot;&gt;&lt;code&gt;technical_output_guardrail_agent = Agent(
    name=&quot;Technical Support Guardrail&quot;,
    instructions=&quot;&quot;&quot;
    Analyze the technical support response to check if it inappropriately contains:
    
    - Billing information (payments, refunds, charges, subscriptions)
    - Order information (shipping, tracking, delivery, returns)
    - Account management info (passwords, email changes, account settings)
    
    Technical agents should ONLY provide technical troubleshooting, diagnostics, and product support.
    Return true for any field that contains inappropriate content for a technical support response.
    &quot;&quot;&quot;,
    output_type=TechnicalOutputGuardRailOutput,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;19&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19&quot;&gt;Role:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;20&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Analyzes the response from the Technical Support Agent.&lt;/li&gt;
&lt;li&gt;Inspects for inappropriate content.&lt;/li&gt;
&lt;li&gt;Returns the result in the form of TechnicalOutputGuardRailOutput.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;21&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;22&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;22&quot;&gt;4. Output Guardrail Function Definition&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;23&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;23&quot;&gt;A. @output_guardrail Decorator&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pgsql&quot;&gt;&lt;code&gt;@output_guardrail
async def technical_output_guardrail(
    wrapper: RunContextWrapper[UserAccountContext],
    agent: Agent,
    output: str,
):
    result = await Runner.run(
        technical_output_guardrail_agent,
        output,
        context=wrapper.context,
    )

    validation = result.final_output

    triggered = (
        validation.contains_off_topic
        or validation.contains_billing_data
        or validation.contains_account_data
    )

    return GuardrailFunctionOutput(
        output_info=validation,
        tripwire_triggered=triggered,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;26&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;26&quot;&gt;Step-by-Step Explanation:&lt;/b&gt;&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;27&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,0,0&quot;&gt;Function Signature&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,0,2&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;@output_guardrail: Registers the function as an output guardrail.&lt;/li&gt;
&lt;li&gt;agent: The agent that generated the response.&lt;/li&gt;
&lt;li&gt;output: The response text to be validated.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;python&quot;&gt;&lt;code&gt;@output_guardrail
async def technical_output_guardrail(..., output: str):
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,1,0&quot;&gt;Execution of Guardrail Agent&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,1,2&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The technical_output_guardrail_agent analyzes the output.&lt;/li&gt;
&lt;li&gt;Passes the context.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;result = await Runner.run(technical_output_guardrail_agent, output, ...)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,2,0&quot;&gt;Extraction of Validation Results&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,2,2&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;validation is an instance of TechnicalOutputGuardRailOutput.
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;TechnicalOutputGuardRailOutput(
    contains_billing_data=True,  # Issue found!
    reason=&quot;Response contains billing information...&quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;ini&quot;&gt;&lt;code&gt;validation = result.final_output
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,3,0&quot;&gt;Tripwire Decision&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,3,2&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;If any condition is True, then triggered = True.&lt;/li&gt;
&lt;li&gt;Uses OR logic to handle complex conditions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;ini&quot;&gt;&lt;code&gt;triggered = (validation.contains_off_topic or ...)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,4,0&quot;&gt;Return GuardrailFunctionOutput&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;return GuardrailFunctionOutput(
    output_info=validation,       # Detailed info
    tripwire_triggered=triggered, # True or False
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr data-path-to-node=&quot;28&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;29&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29&quot;&gt;5. GuardrailFunctionOutput Structure&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;30&quot; data-ke-size=&quot;size16&quot;&gt;GuardrailFunctionOutput is the standard return type for Guardrail functions.&lt;/p&gt;
&lt;p data-path-to-node=&quot;31&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31&quot;&gt;Structure:&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;mipsasm&quot;&gt;&lt;code&gt;GuardrailFunctionOutput(
    output_info: BaseModel,      # Detailed validation info
    tripwire_triggered: bool      # Whether the Tripwire was triggered
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;33&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;33&quot;&gt;Field Explanations:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;output_info: Detailed information about the validation result (Pydantic model).
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Example: Instance of TechnicalOutputGuardRailOutput.&lt;/li&gt;
&lt;li&gt;The reason field explains the failure.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;tripwire_triggered: Guardrail violation status (boolean).
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;True: Guardrail violated, exception raised.&lt;/li&gt;
&lt;li&gt;False: Normal, processing continues.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;35&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;36&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;36&quot;&gt;6. Registering Guardrail to Technical Agent&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;makefile&quot;&gt;&lt;code&gt;technical_agent = Agent(
    name=&quot;Technical Support Agent&quot;,
    # ...
    output_guardrails=[
        technical_output_guardrail,
    ],
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;39&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;output_guardrails: A list of guardrails to execute after response generation.&lt;/li&gt;
&lt;li&gt;Registers technical_output_guardrail.&lt;/li&gt;
&lt;li&gt;Automatically executes after the agent generates a response.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;40&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;41&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;41&quot;&gt;7. Exception Handling&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;vim&quot;&gt;&lt;code&gt;        except OutputGuardrailTripwireTriggered:
            st.write(&quot;Cant show you that answer.&quot;)
            st.session_state[&quot;text_placeholder&quot;].empty()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;44&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;44,0,0&quot;&gt;When OutputGuardrailTripwireTriggered occurs:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;44,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The response is judged as inappropriate.&lt;/li&gt;
&lt;li&gt;Displays &quot;Cant show you that answer.&quot;&lt;/li&gt;
&lt;li&gt;Clears the existing response placeholder.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;45&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;46&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;46&quot;&gt;8. Full Execution Flow&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;47&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;47&quot;&gt;Scenario 1: Normal Response (No Tripwire)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;[Step 1] User Request
   User: &quot;The app isn't working&quot;
   &amp;darr;
[Step 2] Technical Agent Execution
   Runner.run_streamed(technical_agent, ...)
   &amp;rarr; LLM Generates Response: &quot;To fix the app issue, try these steps...&quot;
   &amp;darr;
[Step 3] Output Guardrail Auto-Execution
   Runner checks technical_agent.output_guardrails
   &amp;rarr; Calls technical_output_guardrail()
   &amp;darr;
[Step 4] Guardrail Agent Execution
   Runner.run(technical_output_guardrail_agent, output, ...)
   &amp;rarr; LLM Analyzes response
   &amp;rarr; Generates TechnicalOutputGuardRailOutput:
     {
       &quot;contains_off_topic&quot;: false,
       &quot;contains_billing_data&quot;: false,
       &quot;reason&quot;: &quot;Response contains only technical troubleshooting...&quot;
     }
   &amp;darr;
[Step 5] Tripwire Decision
   triggered = false || false || false = false
   &amp;rarr; Tripwire NOT triggered
   &amp;darr;
[Step 6] Return GuardrailFunctionOutput
   { tripwire_triggered: false }
   &amp;darr;
[Step 7] Runner Processing
   tripwire_triggered == False
   &amp;rarr; No Exception
   &amp;rarr; Display Response ✅
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;49&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;49&quot;&gt;Scenario 2: Inappropriate Response (Tripwire Triggered)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;[Step 1] User Request
   User: &quot;The app isn't working&quot;
   &amp;darr;
[Step 2] Technical Agent Generates Inappropriate Response
   LLM Generates: &quot;To fix the app... Also, I checked your billing info...&quot;
   &amp;darr;
[Step 3] Output Guardrail Auto-Execution
   Calls technical_output_guardrail()
   &amp;darr;
[Step 4] Guardrail Agent Execution
   LLM Analyzes response
   &amp;rarr; Generates TechnicalOutputGuardRailOutput:
     {
       &quot;contains_billing_data&quot;: true,  &amp;larr; Issue Found!
       &quot;reason&quot;: &quot;Response contains billing information...&quot;
     }
   &amp;darr;
[Step 5] Tripwire Decision
   triggered = false || true || false = true
   &amp;rarr; Tripwire Triggered!
   &amp;darr;
[Step 6] Return GuardrailFunctionOutput
   { tripwire_triggered: true }
   &amp;darr;
[Step 7] Runner Processing
   tripwire_triggered == True
   &amp;rarr; OutputGuardrailTripwireTriggered Exception Raised
   &amp;darr;
[Step 8] Exception Handling (main.py)
   except OutputGuardrailTripwireTriggered:
       st.write(&quot;Cant show you that answer.&quot;)
   &amp;rarr; Inappropriate response is hidden from user ❌
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr data-path-to-node=&quot;51&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;52&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;52&quot;&gt;9. Comparison: Input Guardrail vs Output Guardrail&lt;/b&gt;&lt;/h4&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;53&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Feature&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Input Guardrail&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Output Guardrail&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,1,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,1,0,0&quot;&gt;Execution Time&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,1,1,0&quot;&gt;After user input, before agent execution&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,1,2,0&quot;&gt;After agent generates response&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,2,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,2,0,0&quot;&gt;Validation Target&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,2,1,0&quot;&gt;User Request&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,2,2,0&quot;&gt;Agent Response&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,3,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,3,0,0&quot;&gt;Purpose&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,3,1,0&quot;&gt;Block inappropriate requests&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,3,2,0&quot;&gt;Block inappropriate responses&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,4,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,4,0,0&quot;&gt;Decorator&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,4,1,0&quot;&gt;@input_guardrail&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,4,2,0&quot;&gt;@output_guardrail&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,5,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,5,0,0&quot;&gt;Parameter&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,5,1,0&quot;&gt;input: str&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,5,2,0&quot;&gt;output: str&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,6,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,6,0,0&quot;&gt;Exception&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,6,1,0&quot;&gt;InputGuardrailTripwireTriggered&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,6,2,0&quot;&gt;OutputGuardrailTripwireTriggered&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,7,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,7,0,0&quot;&gt;Guardrail Agent&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,7,1,0&quot;&gt;input_guardrail_agent&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,7,2,0&quot;&gt;technical_output_guardrail_agent&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,8,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,8,0,0&quot;&gt;Output Type&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,8,1,0&quot;&gt;InputGuardRailOutput&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,8,2,0&quot;&gt;TechnicalOutputGuardRailOutput&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,9,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;53,9,0,0&quot;&gt;Tripwire Decision&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,9,1,0&quot;&gt;Single field (is_off_topic)&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;53,9,2,0&quot;&gt;Complex conditions (OR logic)&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr data-path-to-node=&quot;54&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;55&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;55&quot;&gt;10. Summary of Core Components&lt;/b&gt;&lt;/h4&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;56&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Component&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Role&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Location&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,1,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,1,0,0&quot;&gt;TechnicalOutputGuardRailOutput&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,1,1,0&quot;&gt;Data model for validation results&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,1,2,0&quot;&gt;models.py&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,2,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,2,0,0&quot;&gt;technical_output_guardrail_agent&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,2,1,0&quot;&gt;Agent that analyzes the response&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,2,2,0&quot;&gt;my_agents/technical_agent.py&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,3,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,3,0,0&quot;&gt;@output_guardrail&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,3,1,0&quot;&gt;Decorator for Guardrail functions&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,3,2,0&quot;&gt;agents package&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,4,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,4,0,0&quot;&gt;technical_output_guardrail&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,4,1,0&quot;&gt;The Guardrail function itself&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,4,2,0&quot;&gt;my_agents/technical_agent.py&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,5,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,5,0,0&quot;&gt;GuardrailFunctionOutput&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,5,1,0&quot;&gt;Return type for Guardrail functions&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,5,2,0&quot;&gt;agents package&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,6,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,6,0,0&quot;&gt;output_guardrails&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,6,1,0&quot;&gt;List of Guardrails registered to an Agent&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,6,2,0&quot;&gt;technical_agent definition&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,7,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;56,7,0,0&quot;&gt;OutputGuardrailTripwireTriggered&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,7,1,0&quot;&gt;Exception raised when Tripwire is triggered&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,7,2,0&quot;&gt;agents package&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr data-path-to-node=&quot;57&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;58&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;58&quot;&gt;11. Full System Diagram&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;┌─────────────────────────────────────────┐
│  User Request                           │
│  &quot;The app isn't working&quot;                │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Runner.run_streamed(technical_agent)   │
│  - Execute Technical Agent              │
│  - LLM Generates Response               │
│  - Response: &quot;To fix the app...&quot;        │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Output Guardrail Auto-Execution        │
│  Runner checks output_guardrails        │
│  &amp;rarr; Calls technical_output_guardrail()   │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  technical_output_guardrail() Runs      │
│  - Execute Guardrail Agent              │
│  - Analyze Response Text                │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Guardrail Agent Execution              │
│  Runner.run(technical_output_guardrail_agent) │
│  - LLM analyzes response                │
│  - Checks for inappropriate content     │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Generate Validation Result             │
│  TechnicalOutputGuardRailOutput:        │
│  {                                      │
│    contains_off_topic: false,           │
│    contains_billing_data: false,        │
│    reason: &quot;Response contains only...&quot;  │
│  }                                      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Tripwire Decision                      │
│  triggered = false || false || false    │
│  = false                                │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Return GuardrailFunctionOutput         │
│  {                                      │
│    output_info: TechnicalOutput...(),   │
│    tripwire_triggered: false            │
│  }                                      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Runner Processing                      │
│  if tripwire_triggered == False:        │
│    &amp;rarr; No Exception                       │
│    &amp;rarr; Display Response ✅                │
│  else:                                  │
│    &amp;rarr; OutputGuardrailTripwireTriggered   │
│    &amp;rarr; &quot;Cant show you that answer.&quot; ❌    │
└─────────────────────────────────────────┘&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/26</guid>
      <comments>https://note24432.tistory.com/26#entry26comment</comments>
      <pubDate>Fri, 2 Jan 2026 02:40:53 +0900</pubDate>
    </item>
    <item>
      <title>OPEN AI SDK - Customer support agent(4)- tools</title>
      <link>https://note24432.tistory.com/25</link>
      <description>&lt;div id=&quot;model-response-message-contentr_568f94c489eb5aa8&quot;&gt;
&lt;h3 data-path-to-node=&quot;2&quot; data-ke-size=&quot;size23&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;2&quot;&gt;Tool System Integration Explanation&lt;/b&gt;&lt;/h3&gt;
&lt;h4 data-path-to-node=&quot;3&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;3&quot;&gt;1. Tool Definition - @function_tool Decorator&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;python&quot;&gt;&lt;code&gt;@function_tool
def run_diagnostic_check(
    context: UserAccountContext, product_name: str, issue_description: str
) -&amp;gt; str:
    &quot;&quot;&quot;
    Run a diagnostic check on the customer's product to identify potential issues.

    Args:
        product_name: Name of the product experiencing issues
        issue_description: Description of the problem
    &quot;&quot;&quot;
    diagnostics = [
        &quot;✅ Server connectivity: Normal&quot;,
        &quot;✅ API endpoints: Responsive&quot;,
        &quot;⚠️  Cache memory: 85% full (recommend clearing)&quot;,
        &quot;✅ Database connections: Stable&quot;,
        &quot;⚠️  Last update: 7 days ago (update available)&quot;,
    ]

    return f&quot;  Diagnostic results for {product_name}:\n&quot; + &quot;\n&quot;.join(diagnostics)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;6&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6,0,0&quot;&gt;@function_tool&lt;/b&gt;: A decorator that registers a function as a tool.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;6,1,0&quot;&gt;Key Features:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;6,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;The first parameter is context: UserAccountContext (&lt;b data-index-in-node=&quot;52&quot; data-path-to-node=&quot;6,1,1,0,0&quot;&gt;automatically injected&lt;/b&gt;).&lt;/li&gt;
&lt;li&gt;The remaining parameters are provided by the LLM.&lt;/li&gt;
&lt;li&gt;The &lt;b data-index-in-node=&quot;4&quot; data-path-to-node=&quot;6,1,1,2,0&quot;&gt;Docstring&lt;/b&gt; is used as the tool description.&lt;/li&gt;
&lt;li&gt;The return value is a string.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;7&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;8&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;8&quot;&gt;2. How the LLM Understands Tools&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;9&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9&quot;&gt;A. Tool Schema Generation&lt;/b&gt; The @function_tool decorator analyzes the function to generate a schema that the LLM can understand:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;python&quot;&gt;&lt;code&gt;# Function Definition
@function_tool
def lookup_order_status(context: UserAccountContext, order_number: str) -&amp;gt; str:
    &quot;&quot;&quot;
    Look up the current status and details of an order.
    Args:
        order_number: Customer's order number
    &quot;&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;11&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;11&quot;&gt;Generated Tool Schema (Internally):&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;name&quot;: &quot;lookup_order_status&quot;,
  &quot;description&quot;: &quot;Look up the current status and details of an order.&quot;,
  &quot;parameters&quot;: {
    &quot;type&quot;: &quot;object&quot;,
    &quot;properties&quot;: {
      &quot;order_number&quot;: {
        &quot;type&quot;: &quot;string&quot;,
        &quot;description&quot;: &quot;Customer's order number&quot;
      }
    },
    &quot;required&quot;: [&quot;order_number&quot;]
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-path-to-node=&quot;13&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13&quot;&gt;B. Providing the Tool List&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;order_agent = Agent(
    name=&quot;Order Management Agent&quot;,
    instructions=dynamic_order_agent_instructions,
    tools=[
        lookup_order_status,
        initiate_return_process,
        schedule_redelivery,
        expedite_shipping,
    ],
    hooks=AgentToolUsageLoggingHooks(),
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;16&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;16,0,0&quot;&gt;tools&lt;/b&gt;: A list of tools available to the agent.&lt;/li&gt;
&lt;li&gt;The &lt;b data-index-in-node=&quot;4&quot; data-path-to-node=&quot;16,1,0&quot;&gt;Runner&lt;/b&gt; generates a schema for each tool and provides it to the LLM.&lt;/li&gt;
&lt;li&gt;The LLM selects a tool by referencing this list and schema.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;17&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;18&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;18&quot;&gt;3. Context Automatic Injection Mechanism&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;19&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19&quot;&gt;A. Context Delivery Path&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;            stream = Runner.run_streamed(
                st.session_state[&quot;agent&quot;],
                message,
                session=session,
                context=user_account_ctx,
            )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;22&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Pass context=user_account_ctx to Runner.run_streamed().&lt;/li&gt;
&lt;li&gt;The Runner internally wraps and manages it using RunContextWrapper.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;23&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;23&quot;&gt;B. Context Injection During Tool Calls&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;julia&quot;&gt;&lt;code&gt;@function_tool
def lookup_order_status(context: UserAccountContext, order_number: str) -&amp;gt; str:
    &quot;&quot;&quot;
    Look up the current status and details of an order.

    Args:
        order_number: Customer's order number
    &quot;&quot;&quot;
    statuses = [&quot;processing&quot;, &quot;shipped&quot;, &quot;in_transit&quot;, &quot;delivered&quot;]
    # ... implementation details ...
    return f&quot;&quot;&quot;
  Order Status: {order_number}
  Shipping to: {context.email}
    &quot;&quot;&quot;.strip()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;26&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;If the first parameter is of type UserAccountContext, the Runner &lt;b data-index-in-node=&quot;65&quot; data-path-to-node=&quot;26,0,0&quot;&gt;automatically injects&lt;/b&gt; it.&lt;/li&gt;
&lt;li&gt;The LLM does &lt;b data-index-in-node=&quot;13&quot; data-path-to-node=&quot;26,1,0&quot;&gt;not&lt;/b&gt; provide the context parameter.&lt;/li&gt;
&lt;li&gt;Inside the tool, properties like context.email, context.customer_id, context.tier, etc., can be used.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;27&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;28&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28&quot;&gt;4. Parameter Generation Process by LLM&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;29&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29&quot;&gt;A. User Request Analysis&lt;/b&gt;&lt;/p&gt;
&lt;blockquote data-path-to-node=&quot;30&quot; data-ke-style=&quot;style1&quot;&gt;
&lt;p data-path-to-node=&quot;30,0&quot; data-ke-size=&quot;size16&quot;&gt;User: &quot;Check the status of order number ORD-123&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p data-path-to-node=&quot;31&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31&quot;&gt;B. Tool Selection&lt;/b&gt;&lt;/p&gt;
&lt;blockquote data-path-to-node=&quot;32&quot; data-ke-style=&quot;style1&quot;&gt;
&lt;p data-path-to-node=&quot;32,0&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;32,0&quot;&gt;LLM Analysis:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;32,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Request: &quot;Check order status&quot;&lt;/li&gt;
&lt;li&gt;Check available tools: lookup_order_status, initiate_return_process, etc.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;32,1,2,0&quot;&gt;Selection:&lt;/b&gt; lookup_order_status&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p data-path-to-node=&quot;33&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;33&quot;&gt;C. Tool Schema Analysis&lt;/b&gt;&lt;/p&gt;
&lt;blockquote data-path-to-node=&quot;34&quot; data-ke-style=&quot;style1&quot;&gt;
&lt;p data-path-to-node=&quot;34,0&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,0&quot;&gt;LLM Checks Schema for lookup_order_status:&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;name: &quot;lookup_order_status&quot;&lt;/li&gt;
&lt;li&gt;description: &quot;Look up the current status and details of an order.&quot;&lt;/li&gt;
&lt;li&gt;parameters: order_number (string, required)&lt;/li&gt;
&lt;li&gt;&lt;i data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,1,3,0&quot;&gt;context is ignored as it is automatically injected.&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p data-path-to-node=&quot;35&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;35&quot;&gt;D. Parameter Extraction&lt;/b&gt;&lt;/p&gt;
&lt;blockquote data-path-to-node=&quot;36&quot; data-ke-style=&quot;style1&quot;&gt;
&lt;p data-path-to-node=&quot;36,0&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;36,0&quot;&gt;LLM Extracts Parameters from Request:&lt;/b&gt; &quot;Check the status of order number ORD-123&quot; &amp;rarr; order_number=&quot;ORD-123&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p data-path-to-node=&quot;37&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;37&quot;&gt;E. Tool Call Generation&lt;/b&gt;&lt;/p&gt;
&lt;blockquote data-path-to-node=&quot;38&quot; data-ke-style=&quot;style1&quot;&gt;
&lt;p data-path-to-node=&quot;38,0&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;38,0&quot;&gt;LLM Generates Tool Call:&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;JSON&lt;/span&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;json&quot;&gt;&lt;code&gt;{
  &quot;tool_name&quot;: &quot;lookup_order_status&quot;,
  &quot;parameters&quot;: {
    &quot;order_number&quot;: &quot;ORD-123&quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;hr data-path-to-node=&quot;39&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;40&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;40&quot;&gt;5. Full Tool Execution Flow&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;[Step 1] User Request
   User: &quot;Check the status of order number ORD-123&quot;
   &amp;darr;
[Step 2] Call Runner.run_streamed()
   Runner.run_streamed(
       order_agent,
       &quot;...&quot;,
       context=user_account_ctx  &amp;larr; Context Passed
   )
   &amp;darr;
[Step 3] Runner Generates Tool Schema
   Runner checks order_agent.tools list
   &amp;rarr; Analyzes @function_tool decorators
   &amp;rarr; Prepares tool list for LLM
   &amp;darr;
[Step 4] Order Agent's LLM Execution
   Information provided to LLM:
   - Instructions, Tools (Schema), Request, History
   &amp;darr;
[Step 5] LLM Selects Tool &amp;amp; Extracts Parameters
   - Tool: lookup_order_status
   - Parameter: order_number=&quot;ORD-123&quot;
   &amp;darr;
[Step 6] LLM Generates Tool Call
   Output: { &quot;function&quot;: { &quot;name&quot;: &quot;lookup_order_status&quot;, ... } }
   &amp;darr;
[Step 7] on_tool_start Hook Called
   Displays &quot;  Order Management Agent starting tool...&quot; in sidebar
   &amp;darr;
[Step 8] Runner Executes Tool
   Runner calls function:
   lookup_order_status(
       context=wrapper.context,  &amp;larr; Auto Injected
       order_number=&quot;ORD-123&quot;    &amp;larr; Provided by LLM
   )
   &amp;darr;
[Step 9] Tool Function Logic Execution
   Inside lookup_order_status():
   - Use context.email, context.tier
   - Query order logic
   - Return result string
   &amp;darr;
[Step 10] on_tool_end Hook Called
   Displays tool result in sidebar
   &amp;darr;
[Step 11] LLM Delivers Result to User
   LLM receives tool result &amp;rarr; Converts to friendly message
   &amp;rarr; &quot;Order ORD-123 is currently in transit...&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr data-path-to-node=&quot;42&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;43&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43&quot;&gt;6. Handling Parameter Types&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;groovy&quot;&gt;&lt;code&gt;def lookup_order_status(context: UserAccountContext, order_number: str) -&amp;gt; str:
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;46&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;No default value &amp;rarr; &lt;b data-index-in-node=&quot;19&quot; data-path-to-node=&quot;46,0,0&quot;&gt;Required&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;The LLM must extract this from the user request. If missing, it asks the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;47&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;47&quot;&gt;B. Optional Parameters (Default Values)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;groovy&quot;&gt;&lt;code&gt;def lookup_billing_history(context: UserAccountContext, months_back: int = 6) -&amp;gt; str:
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;49&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Default value = 6 exists &amp;rarr; &lt;b data-index-in-node=&quot;27&quot; data-path-to-node=&quot;49,0,0&quot;&gt;Optional&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;If the LLM cannot extract it, the default value is used.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;50&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;50&quot;&gt;C. Multiple Parameters&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;reasonml&quot;&gt;&lt;code&gt;def initiate_return_process(..., order_number: str, return_reason: str, items: str) -&amp;gt; str:
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;52&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Extract multiple parameters from the user request.&lt;/li&gt;
&lt;li&gt;The LLM maps each parameter accordingly.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;53&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;54&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;54&quot;&gt;7. Context Usage Examples&lt;/b&gt;&lt;/h4&gt;
&lt;p data-path-to-node=&quot;55&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;55&quot;&gt;A. Reading Info from Context&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;mipsasm&quot;&gt;&lt;code&gt;  Shipping to: {context.email}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;57&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;context.email: Customer Email&lt;/li&gt;
&lt;li&gt;context.customer_id: Customer ID&lt;/li&gt;
&lt;li&gt;context.tier: Customer Tier&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;58&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;58&quot;&gt;B. Context-based Conditional Logic&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;angelscript&quot;&gt;&lt;code&gt;processing_days = 3 if context.is_premium_customer() else 5
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;60&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;context.is_premium_customer(): Check if premium.&lt;/li&gt;
&lt;li&gt;Premium customers get faster processing (3 days vs 5 days).&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;61&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;61&quot;&gt;C. Context-based Access Control&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;xquery&quot;&gt;&lt;code&gt;if not context.is_premium_customer():
    return &quot;❌ Expedited shipping upgrade requires Premium membership&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;63&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Feature available &lt;b data-index-in-node=&quot;18&quot; data-path-to-node=&quot;63,0,0&quot;&gt;only&lt;/b&gt; to premium customers.&lt;/li&gt;
&lt;li&gt;Check permissions via Context.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;64&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;65&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;65&quot;&gt;8. Tool Usage Logging - AgentHooks&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;class AgentToolUsageLoggingHooks(AgentHooks):
    async def on_tool_start(self, ...):
        # ... Log tool start ...

    async def on_tool_end(self, ...):
        # ... Log tool result ...

    async def on_handoff(self, ...):
        # ... Log handoff ...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;68&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;68,0,0&quot;&gt;AgentHooks&lt;/b&gt;: Lifecycle event hooks for the agent.&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;68,1,0&quot;&gt;Major Methods:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;68,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;on_tool_start: Called when a tool starts execution.&lt;/li&gt;
&lt;li&gt;on_tool_end: Called when a tool completes execution (includes result).&lt;/li&gt;
&lt;li&gt;on_handoff: Called when a handoff occurs.&lt;/li&gt;
&lt;li&gt;on_start / on_end: Agent activation/completion.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr data-path-to-node=&quot;69&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;70&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;70&quot;&gt;9. Key Concepts Summary&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;71&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,0,0,0&quot;&gt;Concept&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,0,1,0&quot;&gt;Description&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,1,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,1,0,0&quot;&gt;@function_tool&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,1,1,0&quot;&gt;Decorator that registers a function as a tool.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,2,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,2,0,0&quot;&gt;context&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,2,1,0&quot;&gt;UserAccountContext automatically injected as the first parameter.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,3,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,3,0,0&quot;&gt;Tool Schema&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,3,1,0&quot;&gt;Metadata generated for the tool so the LLM can understand it.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,4,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,4,0,0&quot;&gt;tools&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,4,1,0&quot;&gt;List of tools to register with the agent.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,5,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,5,0,0&quot;&gt;AgentHooks&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,5,1,0&quot;&gt;Class that handles agent lifecycle events.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,6,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,6,0,0&quot;&gt;on_tool_start&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,6,1,0&quot;&gt;Hook called when tool execution begins.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,7,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;71,7,0,0&quot;&gt;on_tool_end&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;71,7,1,0&quot;&gt;Hook called when tool execution completes.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr data-path-to-node=&quot;72&quot; data-ke-style=&quot;style1&quot; /&gt;
&lt;h4 data-path-to-node=&quot;73&quot; data-ke-size=&quot;size20&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;73&quot;&gt;10. Full System Diagram&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;┌─────────────────────────────────────────┐
│  User Request                           │
│  &quot;Check the status of order ORD-123&quot;    │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Runner.run_streamed(order_agent, ...)  │
│  Pass context=user_account_ctx          │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Runner Generates Tool Schema           │
│  - Analyze @function_tool decorator     │
│  - Parse function signature             │
│  - Parse Docstring                      │
│  - Generate JSON Schema                 │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Provide Tool Info to LLM               │
│  - Agent instructions                   │
│  - Tool List (with Schema)              │
│  - User Request                         │
│  - Conversation History                 │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  LLM Selects Tool &amp;amp; Extracts Params     │
│  - Analyze User Request                 │
│  - Select appropriate Tool              │
│  - Check Tool Schema                    │
│  - Extract: order_number=&quot;ORD-123&quot;      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  LLM Generates Tool Call                │
│  {                                      │
│    &quot;tool_calls&quot;: [{                     │
│      &quot;function&quot;: {                      │
│        &quot;name&quot;: &quot;lookup_order_status&quot;,   │
│        &quot;arguments&quot;: &quot;{\&quot;order_number\&quot;: \&quot;ORD-123\&quot;}&quot; │
│      }                                  │
│    }]                                   │
│  }                                      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Call on_tool_start Hook                │
│  - Display tool start in sidebar        │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Runner Executes Tool                   │
│  lookup_order_status(                   │
│    context=wrapper.context,  &amp;larr; Auto     │
│    order_number=&quot;ORD-123&quot;    &amp;larr; From LLM │
│  )                                      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Tool Function Execution                │
│  - Use context.email, id, tier          │
│  - Query order status                   │
│  - Return result string                 │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Call on_tool_end Hook                  │
│  - Display tool result in sidebar       │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  LLM Delivers Result to User            │
│  &quot;Order ORD-123 is currently...&quot;        │
└─────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/25</guid>
      <comments>https://note24432.tistory.com/25#entry25comment</comments>
      <pubDate>Thu, 1 Jan 2026 21:02:53 +0900</pubDate>
    </item>
    <item>
      <title>OPEN AI SDK - Customer support agent(3) - handoff</title>
      <link>https://note24432.tistory.com/24</link>
      <description>&lt;h3 data-path-to-node=&quot;2&quot; data-ke-size=&quot;size23&quot;&gt;1. Handoff Data Model Definition&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;angelscript&quot;&gt;&lt;code&gt;class HandoffData(BaseModel):
    to_agent_name: str
    issue_type: str
    issue_description: str
    reason: str
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;4&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;4,0,0&quot;&gt;HandoffData:&lt;/b&gt; Pydantic model containing handoff information&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;4,1,0&quot;&gt;Fields:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;4,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;to_agent_name: Name of the target agent to hand off to&lt;/li&gt;
&lt;li&gt;issue_type: Type of issue&lt;/li&gt;
&lt;li&gt;issue_description: Description of the issue&lt;/li&gt;
&lt;li&gt;reason: Reason for the handoff&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;5&quot; data-ke-size=&quot;size23&quot;&gt;2. Handoff Handler Function&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pony&quot;&gt;&lt;code&gt;def handle_handoff(
    wrapper: RunContextWrapper[UserAccountContext],
    input_data: HandoffData,
):
    with st.sidebar:
        st.write(
            f&quot;&quot;&quot;
            Handing off to {input_data.to_agent_name}
            Reason: {input_data.reason}
            Issue Type: {input_data.issue_type}
            Description: {input_data.issue_description}
        &quot;&quot;&quot;
        )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;7&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;7,0,0&quot;&gt;handle_handoff:&lt;/b&gt; Callback function called when a handoff occurs&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;7,1,0&quot;&gt;Parameters:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;7,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;wrapper: Execution context wrapper (access UserAccountContext via wrapper.context)&lt;/li&gt;
&lt;li&gt;input_data: HandoffData instance&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;7,2,0&quot;&gt;Behavior:&lt;/b&gt; Displays handoff information in the sidebar&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;8&quot; data-ke-size=&quot;size23&quot;&gt;3. Handoff Factory Function&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;def make_handoff(agent):
    return handoff(
        agent=agent,
        on_handoff=handle_handoff,
        input_type=HandoffData, 
        input_filter=handoff_filters.remove_all_tools,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;10&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10,0,0&quot;&gt;make_handoff:&lt;/b&gt; Factory function that creates a Handoff object&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10,1,0&quot;&gt;Parameter:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;10,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;agent: Target agent to hand off to&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10,2,0&quot;&gt;Returns:&lt;/b&gt; Handoff object created by handoff()&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10,3,0&quot;&gt;Configuration:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;10,3,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;agent: Target agent&lt;/li&gt;
&lt;li&gt;on_handoff: Callback when handoff occurs (handle_handoff)&lt;/li&gt;
&lt;li&gt;input_type: Handoff data type (HandoffData)&lt;/li&gt;
&lt;li&gt;input_filter: Input filter (handoff_filters.remove_all_tools to remove tools)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;11&quot; data-ke-size=&quot;size23&quot;&gt;4. Role of input_type&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;elm&quot;&gt;&lt;code&gt;        input_type=HandoffData, 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;13&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13,0,0&quot;&gt;input_type=HandoffData:&lt;/b&gt; Triggers handoff when LLM output matches HandoffData format&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;13,1,0&quot;&gt;Behavior:&lt;/b&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;13,1,1&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;Runner parses LLM output&lt;/li&gt;
&lt;li&gt;Checks if it matches HandoffData structure&lt;/li&gt;
&lt;li&gt;If it matches, executes handoff&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;14&quot; data-ke-size=&quot;size23&quot;&gt;5. Role of RECOMMENDED_PROMPT_PREFIX&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;vim&quot;&gt;&lt;code&gt;    return f&quot;&quot;&quot;
    {RECOMMENDED_PROMPT_PREFIX}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;16&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;16,0,0&quot;&gt;RECOMMENDED_PROMPT_PREFIX:&lt;/b&gt; Prompt prefix that guides the LLM on how to perform handoffs&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;16,1,0&quot;&gt;Content:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;16,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;How to output in HandoffData format when a handoff is needed&lt;/li&gt;
&lt;li&gt;How to fill to_agent_name, issue_type, issue_description, reason&lt;/li&gt;
&lt;li&gt;When to perform a handoff&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;17&quot; data-ke-size=&quot;size23&quot;&gt;6. Registering Handoff with Main Agent&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;lisp&quot;&gt;&lt;code&gt;triage_agent = Agent(
    name=&quot;Triage Agent&quot;,
    instructions=dynamic_triage_agent_instructions,
    input_guardrails=[
        off_topic_guardrail,
    ],
    handoffs=[
        make_handoff(technical_agent),
        make_handoff(billing_agent),
        make_handoff(account_agent),
        make_handoff(order_agent),
    ],
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;19&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19,0,0&quot;&gt;handoffs:&lt;/b&gt; List to register multiple handoffs&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19,1,0&quot;&gt;Registered agents:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;19,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;technical_agent: Technical support&lt;/li&gt;
&lt;li&gt;billing_agent: Billing/payment&lt;/li&gt;
&lt;li&gt;account_agent: Account management&lt;/li&gt;
&lt;li&gt;order_agent: Order management&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;20&quot; data-ke-size=&quot;size23&quot;&gt;7. Target Agent Example&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;stata&quot;&gt;&lt;code&gt;def dynamic_order_agent_instructions(
    wrapper: RunContextWrapper[UserAccountContext],
    agent: Agent[UserAccountContext],
):
    return f&quot;&quot;&quot;
    You are an Order Management specialist helping {wrapper.context.name}.
    Customer tier: {wrapper.context.tier} {&quot;(Premium Shipping)&quot; if wrapper.context.tier != &quot;basic&quot; else &quot;&quot;}
    
    YOUR ROLE: Handle order status, shipping, returns, and delivery issues.
    
    ORDER MANAGEMENT PROCESS:
    1. Look up order details by order number
    2. Provide current status and tracking information
    3. Resolve shipping or delivery issues
    4. Process returns and exchanges
    5. Update shipping preferences if needed
    
    ORDER INFORMATION TO PROVIDE:
    - Current order status (processing, shipped, delivered)
    - Tracking numbers and carrier information
    - Expected delivery dates
    - Return/exchange options and policies
    
    RETURN POLICY:
    - 30-day return window for most items
    - Free returns for premium customers
    - Exchange options available
    - Refund processing time: 3-5 business days
    
    {&quot;PREMIUM PERKS: Free expedited shipping and returns, priority processing.&quot; if wrapper.context.tier != &quot;basic&quot; else &quot;&quot;}
    &quot;&quot;&quot;

order_agent = Agent(
    name=&quot;Order Management Agent&quot;,
    instructions=dynamic_order_agent_instructions,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;22&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;22,0,0&quot;&gt;Target agents&lt;/b&gt; also use Context&lt;/li&gt;
&lt;li&gt;Generate personalized responses using wrapper.context.name, wrapper.context.tier, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;23&quot; data-ke-size=&quot;size23&quot;&gt;8. Complete Execution Flow (Detailed)&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;sql&quot;&gt;&lt;code&gt;[Step 1] User Input
   User: &quot;Check my order status&quot;
   &amp;darr;
[Step 2] Call Runner.run_streamed()
   Runner.run_streamed(
       triage_agent,
       &quot;Check my order status&quot;,
       session=session,
       context=user_account_ctx
   )
   &amp;darr;
[Step 3] Input Guardrail Validation
   off_topic_guardrail() executes
   &amp;rarr; Not off-topic (passes)
   &amp;darr;
[Step 4] Triage Agent Execution Starts
   dynamic_triage_agent_instructions() called
   &amp;rarr; Includes {RECOMMENDED_PROMPT_PREFIX}
   &amp;rarr; Uses wrapper.context.name, tier
   &amp;rarr; &quot;The customer's name is nico.&quot;
   &amp;rarr; &quot;The customer's tier is basic.&quot;
   &amp;darr;
[Step 5] Triage Agent's LLM Execution
   LLM processes conversation
   &amp;rarr; Analyzes issue: &quot;Order-related inquiry&quot;
   &amp;rarr; Classifies: &quot;ORDER MANAGEMENT&quot;
   &amp;darr;
[Step 6A] Normal Response Case
   LLM responds with normal text
   &amp;rarr; &quot;I'll help you with that...&quot;
   &amp;rarr; input_type doesn't match
   &amp;rarr; Handoff not triggered
   &amp;rarr; Conversation continues
   &amp;darr;
[Step 6B] HandoffData Format Case
   LLM responds in HandoffData format:
   {
     &quot;to_agent_name&quot;: &quot;Order Management Agent&quot;,
     &quot;issue_type&quot;: &quot;ORDER MANAGEMENT&quot;,
     &quot;issue_description&quot;: &quot;Order status check request&quot;,
     &quot;reason&quot;: &quot;Route to order-related specialist agent&quot;
   }
   &amp;darr;
[Step 7] Runner Detects HandoffData Format
   Runner parses LLM output
   &amp;rarr; Detects HandoffData format
   &amp;rarr; Checks triage_agent.handoffs list
   &amp;rarr; Finds handoff with input_type=HandoffData
   &amp;rarr; Finds handoff object matching &quot;Order Management Agent&quot;
   &amp;darr;
[Step 8] Handoff Validation and Preparation
   - input_type validation: Checks if output is HandoffData format
   - Applies input_filter: handoff_filters.remove_all_tools
     &amp;rarr; Removes unnecessary tools
   - Verifies target agent: order_agent exists
   &amp;darr;
[Step 9] on_handoff Callback Called
   handle_handoff(wrapper, input_data) executes
   - wrapper: Current RunContextWrapper (includes context)
   - input_data: Parsed HandoffData instance
   &amp;rarr; Displays handoff information in sidebar:
     &quot;Handing off to Order Management Agent
      Reason: Route to order-related specialist agent
      Issue Type: ORDER MANAGEMENT
      Description: Order status check request&quot;
   &amp;darr;
[Step 10] Context Wrapping Maintained
   Existing wrapper.context maintained as-is
   &amp;rarr; user_account_ctx is passed through
   &amp;darr;
[Step 11] Recursive Execution to Target Agent
   Inside Runner.run_streamed():
   Runner.run_streamed(
       order_agent,              &amp;larr; Target agent
       input_data.issue_description,  &amp;larr; Issue description from Handoff data as input
       session=session,          &amp;larr; Same session maintained
       context=wrapper.context,   &amp;larr; Context passed
   )
   &amp;darr;
[Step 12] Order Agent Execution Starts
   - Creates new RunContextWrapper (uses same context)
   - Calls dynamic_order_agent_instructions(wrapper, agent)
   - Can access wrapper.context.name, tier, etc.
   - &quot;You are an Order Management specialist helping nico.&quot;
   - &quot;Customer tier: basic&quot;
   &amp;darr;
[Step 13] Order Agent Processes
   Order Agent's LLM processes order status check
   &amp;rarr; Context information continues to be available
   &amp;rarr; Generates personalized response
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 data-path-to-node=&quot;25&quot; data-ke-size=&quot;size23&quot;&gt;9. Internal Transfer Mechanism&lt;/h3&gt;
&lt;p data-path-to-node=&quot;26&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;26&quot;&gt;A. Handoff Detection Mechanism&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,0,0&quot;&gt;Triage Agent LLM Output:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,0,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&quot;I'll connect you with our Order Management specialist...&quot; + Structured output in HandoffData format&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27,1,0&quot;&gt;Inside Runner:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;27,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Parses LLM output&lt;/li&gt;
&lt;li&gt;Checks if output_type is HandoffData&lt;/li&gt;
&lt;li&gt;Finds matching handoff from handoffs list&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;28&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28&quot;&gt;B. Context Passing Mechanism&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;29&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29,0,0&quot;&gt;Triage Agent Execution:&lt;/b&gt; context=user_account_ctx &amp;rarr; wrapper.context = user_account_ctx&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29,1,0&quot;&gt;Handoff Occurs:&lt;/b&gt; handle_handoff(wrapper, input_data) &amp;rarr; wrapper.context is maintained as-is&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29,2,0&quot;&gt;Order Agent Execution:&lt;/b&gt; Runner.run_streamed(order_agent, ..., context=wrapper.context) &amp;rarr; Same context is passed&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;29,3,0&quot;&gt;Inside Order Agent:&lt;/b&gt; dynamic_order_agent_instructions(wrapper, agent) &amp;rarr; Can access wrapper.context.name, tier, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;30&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;30&quot;&gt;C. Session Maintenance Mechanism&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;31&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31,0,0&quot;&gt;Triage Agent Execution:&lt;/b&gt; session=session (SQLiteSession)&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31,1,0&quot;&gt;Handoff Occurs:&lt;/b&gt; Same session object maintained&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31,2,0&quot;&gt;Order Agent Execution:&lt;/b&gt; session=session (same session)&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31,3,0&quot;&gt;Result:&lt;/b&gt; Conversation history is stored continuously. Conversations from both Triage Agent and Order Agent are recorded in the same session.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;32&quot; data-ke-size=&quot;size23&quot;&gt;10. input_type vs output_type Comparison&lt;/h3&gt;
&lt;p data-path-to-node=&quot;33&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;33&quot;&gt;A. output_type (Guardrail Agent)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;makefile&quot;&gt;&lt;code&gt;input_guardrail_agent = Agent(
    # ...
    output_type=InputGuardRailOutput,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;35&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;35,0,0&quot;&gt;output_type:&lt;/b&gt; Forces the agent to &lt;i data-index-in-node=&quot;33&quot; data-path-to-node=&quot;35,0,0&quot;&gt;always&lt;/i&gt; output in this format.&lt;/li&gt;
&lt;li&gt;Restricts LLM to respond only in InputGuardRailOutput format.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;36&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;36&quot;&gt;B. input_type (Handoff)&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;elm&quot;&gt;&lt;code&gt;        input_type=HandoffData, 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;38&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;38,0,0&quot;&gt;input_type:&lt;/b&gt; Triggers handoff &lt;i data-index-in-node=&quot;29&quot; data-path-to-node=&quot;38,0,0&quot;&gt;only when&lt;/i&gt; output is in this format.&lt;/li&gt;
&lt;li&gt;Triage Agent can also output normal text.&lt;/li&gt;
&lt;li&gt;If output is in HandoffData format, handoff is executed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;39&quot; data-ke-size=&quot;size23&quot;&gt;11. Input Filtering Process&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;        input_filter=handoff_filters.remove_all_tools,
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;41&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;41,0,0&quot;&gt;input_filter:&lt;/b&gt; Filters input during handoff&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;41,1,0&quot;&gt;remove_all_tools:&lt;/b&gt; Removes all tools&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;41,2,0&quot;&gt;Effects:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;41,2,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Tools from Triage Agent are not passed to Order Agent&lt;/li&gt;
&lt;li&gt;Order Agent uses only its own tools&lt;/li&gt;
&lt;li&gt;Clean transfer&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;42&quot; data-ke-size=&quot;size23&quot;&gt;12. Roles and Benefits of Handoff&lt;/h3&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;43&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,0,0&quot;&gt;Specialist Agent Routing:&lt;/b&gt; Routes issues to appropriate specialist agents&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,1,0&quot;&gt;Context Maintenance:&lt;/b&gt; Customer information is maintained after handoff&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,2,0&quot;&gt;Traceability:&lt;/b&gt; Displays handoff information in sidebar&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,3,0&quot;&gt;Extensibility:&lt;/b&gt; Multiple agents can be registered&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,4,0&quot;&gt;Filtering:&lt;/b&gt; Removes unnecessary tools with input_filter&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;43,5,0&quot;&gt;Flexibility:&lt;/b&gt; Conditional handoff trigger with input_type&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;44&quot; data-ke-size=&quot;size23&quot;&gt;13. Key Concepts Summary&lt;/h3&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;45&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Concept&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,1,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,1,0,0&quot;&gt;HandoffData&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,1,1,0&quot;&gt;Pydantic model containing handoff information&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,2,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,2,0,0&quot;&gt;handoff()&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,2,1,0&quot;&gt;Function that creates a Handoff object&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,3,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,3,0,0&quot;&gt;on_handoff&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,3,1,0&quot;&gt;Callback function called when handoff occurs&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,4,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,4,0,0&quot;&gt;input_type&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,4,1,0&quot;&gt;Output data type that triggers handoff&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,5,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,5,0,0&quot;&gt;input_filter&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,5,1,0&quot;&gt;Input filtering option during handoff&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,6,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,6,0,0&quot;&gt;handoffs&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,6,1,0&quot;&gt;List that connects handoffs to agent&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,7,0,0&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;45,7,0,0&quot;&gt;RECOMMENDED_PROMPT_PREFIX&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;45,7,1,0&quot;&gt;Prompt that guides LLM on how to perform handoffs&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 data-path-to-node=&quot;46&quot; data-ke-size=&quot;size23&quot;&gt;14. Complete System Integration Diagram&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;sas&quot;&gt;&lt;code&gt;┌─────────────────────────────────────────┐
│  Runner.run_streamed(triage_agent, ...) │
│  context=user_account_ctx               │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  Input Guardrail Validation             │
│  off_topic_guardrail()                  │
└──────────────┬──────────────────────────┘
               │ Passes
               ▼
┌─────────────────────────────────────────┐
│  Triage Agent Execution                 │
│  - Includes RECOMMENDED_PROMPT_PREFIX   │
│  - Uses wrapper.context.name, tier      │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│  LLM Output Generation                  │
│  - Normal text or HandoffData format    │
└──────────────┬──────────────────────────┘
               │
        ┌──────┴──────┐
        │             │
        ▼             ▼
┌──────────────┐  ┌──────────────────────┐
│ Normal Text  │  │ HandoffData Format   │
│              │  │ {                    │
│ Continue     │  │   to_agent_name:     │
│ Conversation │  │   issue_type:        │
│              │  │   ...                │
│              │  │ }                    │
└──────────────┘  └──────┬───────────────┘
                         │
                         ▼
            ┌────────────────────────────┐
            │ Runner Detects HandoffData │
            │ - input_type matches       │
            │ - Checks handoffs list     │
            └──────────────┬─────────────┘
                           │
                           ▼
            ┌────────────────────────────┐
            │ Apply input_filter         │
            │ - remove_all_tools         │
            └──────────────┬─────────────┘
                           │
                           ▼
            ┌────────────────────────────┐
            │ Call on_handoff Callback   │
            │ handle_handoff(wrapper,    │
            │              input_data)   │
            │ - Display info in sidebar  │
            └──────────────┬─────────────┘
                           │
                           ▼
            ┌────────────────────────────┐
            │ Maintain Context           │
            │ Pass wrapper.context as-is │
            └──────────────┬─────────────┘
                           │
                           ▼
            ┌────────────────────────────┐
            │ Runner.run_streamed(       │
            │   order_agent,             │
            │   issue_description,       │
            │   context=wrapper.context  │
            │ )                          │
            │ (Recursive call)           │
            └──────────────┬─────────────┘
                           │
                           ▼
            ┌────────────────────────────┐
            │ Order Agent Execution      │
            │ - dynamic_order_agent_     │
            │   instructions()           │
            │ - Uses wrapper.context.name,│
            │   tier                     │
            │ - Processes order status   │
            │   check                    │
            └────────────────────────────┘&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/24</guid>
      <comments>https://note24432.tistory.com/24#entry24comment</comments>
      <pubDate>Thu, 1 Jan 2026 15:00:27 +0900</pubDate>
    </item>
    <item>
      <title>OPEN AI SDK - Customer support agent(2) - Inputgaurdrail &amp;amp; context</title>
      <link>https://note24432.tistory.com/23</link>
      <description>&lt;h1 data-path-to-node=&quot;1&quot;&gt;Context and Input Guardrail System&lt;/h1&gt;
&lt;h3 data-path-to-node=&quot;2&quot; data-ke-size=&quot;size23&quot;&gt;1. Context Model Definition&lt;/h3&gt;
&lt;p data-path-to-node=&quot;3&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;3&quot;&gt;models.py Lines 5-9&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;angelscript&quot;&gt;&lt;code&gt;class UserAccountContext(BaseModel):
    customer_id: int
    name: str
    tier: str = &quot;basic&quot;
    email: Optional[str] = None  # premium enterprise
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;5&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;5,0,0&quot;&gt;UserAccountContext:&lt;/b&gt; Pydantic model containing customer account information&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;5,1,0&quot;&gt;Fields:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;5,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;customer_id: Customer ID&lt;/li&gt;
&lt;li&gt;name: Customer name&lt;/li&gt;
&lt;li&gt;tier: Tier (default &quot;basic&quot;, can be &quot;premium&quot;, &quot;enterprise&quot;)&lt;/li&gt;
&lt;li&gt;email: Email (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;6&quot; data-ke-size=&quot;size23&quot;&gt;2. Context Instance Creation and Passing&lt;/h3&gt;
&lt;p data-path-to-node=&quot;7&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;7&quot;&gt;main.py Lines 13-17&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;user_account_ctx = UserAccountContext(
    customer_id=1,
    name=&quot;nico&quot;,
    tier=&quot;basic&quot;,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;9&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;9,0,0&quot;&gt;user_account_ctx:&lt;/b&gt; Creates a customer information instance&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;10&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;10&quot;&gt;main.py Lines 53-58&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;            stream = Runner.run_streamed(
                triage_agent,
                message,
                session=session,
                context=user_account_ctx,
            )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;12&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Passes context=user_account_ctx to Runner.run_streamed()&lt;/li&gt;
&lt;li&gt;This context is passed when the agent runs&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;13&quot; data-ke-size=&quot;size23&quot;&gt;3. Accessing Context via RunContextWrapper&lt;/h3&gt;
&lt;p data-path-to-node=&quot;14&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;14&quot;&gt;A. Using Context in Guardrail Function&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;15&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;15&quot;&gt;triage_agent.py Lines 20-35&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pgsql&quot;&gt;&lt;code&gt;@input_guardrail
async def off_topic_guardrail(
    wrapper: RunContextWrapper[UserAccountContext],
    agent: Agent[UserAccountContext],
    input: str,
):
    result = await Runner.run(
        input_guardrail_agent,
        input,
        context=wrapper.context,
    )

    return GuardrailFunctionOutput(
        output_info=result.final_output,
        tripwire_triggered=result.final_output.is_off_topic,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;17&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;wrapper: RunContextWrapper[UserAccountContext]: Wrapper object for context&lt;/li&gt;
&lt;li&gt;wrapper.context: Access to the actual UserAccountContext instance&lt;/li&gt;
&lt;li&gt;The same context is passed to the guardrail agent (line 29)&lt;/li&gt;
&lt;li&gt;you should use @input_gaurdrail decorater to registers this function as input guardrail.&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;18&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;18&quot;&gt;B. Using Context in Dynamic Prompt&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;19&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;19&quot;&gt;triage_agent.py Lines 38-48&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pgsql&quot;&gt;&lt;code&gt;def dynamic_triage_agent_instructions(
    wrapper: RunContextWrapper[UserAccountContext],
    agent: Agent[UserAccountContext],
):
    return f&quot;&quot;&quot;
    You are a customer support agent. You ONLY help customers with their questions about their User Account, Billing, Orders, or Technical Support.
    You call customers by their name.
    
    The customer's name is {wrapper.context.name}.
    The customer's email is {wrapper.context.email}.
    The customer's tier is {wrapper.context.tier}.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;21&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;21,0,0&quot;&gt;dynamic_triage_agent_instructions:&lt;/b&gt; Function called at runtime&lt;/li&gt;
&lt;li&gt;Inserts customer information into the prompt using wrapper.context.name, wrapper.context.email, wrapper.context.tier&lt;/li&gt;
&lt;li&gt;The prompt is generated based on context for each execution&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;22&quot; data-ke-size=&quot;size23&quot;&gt;4. Input Guardrail System&lt;/h3&gt;
&lt;p data-path-to-node=&quot;23&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;23&quot;&gt;A. Guardrail Output Model&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;24&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;24&quot;&gt;models.py Lines 12-15&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;angelscript&quot;&gt;&lt;code&gt;class InputGuardRailOutput(BaseModel):

    is_off_topic: bool
    reason: str
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;26&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;26,0,0&quot;&gt;InputGuardRailOutput:&lt;/b&gt; Model for guardrail validation results&lt;/li&gt;
&lt;li&gt;is_off_topic: Whether the request is off-topic (True blocks the request)&lt;/li&gt;
&lt;li&gt;reason: Reason for blocking&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;27&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;27&quot;&gt;B. Guardrail Dedicated Agent&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;28&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;28&quot;&gt;triage_agent.py Lines 10-18&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;smalltalk&quot;&gt;&lt;code&gt;input_guardrail_agent = Agent(
    name=&quot;Input Guardrail Agent&quot;,
    instructions=&quot;&quot;&quot;
    Ensure the user's request specifically pertains to User Account details, Billing inquiries, Order information, or Technical Support issues, and is not off-topic. 
    If the request is off-topic, return a reason for the tripwire.You can make small conversation with the user, specially at the beginning of the conversation, 
    but don't help with requests that are not related to User Account details, Billing inquiries, Order information, or Technical Support issues.
    &quot;&quot;&quot;,
    output_type=InputGuardRailOutput,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;30&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;30,0,0&quot;&gt;Purpose:&lt;/b&gt; Determines if user input is within allowed scope (Account/Billing/Orders/Technical Support)&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;30,1,0&quot;&gt;Output:&lt;/b&gt; Returns InputGuardRailOutput format&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;30,2,0&quot;&gt;Rules:&lt;/b&gt; Allows brief greetings at conversation start, but blocks requests that are fundamentally off-topic&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;31&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;31&quot;&gt;C. Guardrail Function Implementation&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;32&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;32&quot;&gt;triage_agent.py Lines 20-35&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;pgsql&quot;&gt;&lt;code&gt;@input_guardrail
async def off_topic_guardrail(
    wrapper: RunContextWrapper[UserAccountContext],
    agent: Agent[UserAccountContext],
    input: str,
):
    result = await Runner.run(
        input_guardrail_agent,
        input,
        context=wrapper.context,
    )

    return GuardrailFunctionOutput(
        output_info=result.final_output,
        tripwire_triggered=result.final_output.is_off_topic,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;@input_guardrail: Decorator that registers the function as a guardrail&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,1,0&quot;&gt;Parameters:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;wrapper: Execution context wrapper (access UserAccountContext via wrapper.context)&lt;/li&gt;
&lt;li&gt;agent: Current agent instance (for extensibility/logging)&lt;/li&gt;
&lt;li&gt;input: User input string to validate&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;34,2,0&quot;&gt;Behavior:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;34,2,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Runs input validation with input_guardrail_agent (passes context=wrapper.context on line 29)&lt;/li&gt;
&lt;li&gt;Returns GuardrailFunctionOutput&lt;/li&gt;
&lt;li&gt;tripwire_triggered: True if is_off_topic is True&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;35&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;35&quot;&gt;D. Registering Guardrail with Main Agent&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;36&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;36&quot;&gt;triage_agent.py Lines 96-102&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;routeros&quot;&gt;&lt;code&gt;triage_agent = Agent(
    name=&quot;Triage Agent&quot;,
    instructions=dynamic_triage_agent_instructions,
    input_guardrails=[
        off_topic_guardrail,
    ],
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;38&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;input_guardrails: List to register multiple guardrails&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;38,1,0&quot;&gt;Execution order:&lt;/b&gt; User input &amp;rarr; Guardrail validation &amp;rarr; Main agent execution (if passed)&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;39&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;39&quot;&gt;E. Guardrail Exception Handling&lt;/b&gt;&lt;/p&gt;
&lt;p data-path-to-node=&quot;40&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;40&quot;&gt;main.py Lines 51-67&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class=&quot;cs&quot;&gt;&lt;code&gt;        try:

            stream = Runner.run_streamed(
                triage_agent,
                message,
                session=session,
                context=user_account_ctx,
            )

            async for event in stream.stream_events():
                if event.type == &quot;raw_response_event&quot;:

                    if event.data.type == &quot;response.output_text.delta&quot;:
                        response += event.data.delta
                        text_placeholder.write(response.replace(&quot;$&quot;, &quot;\$&quot;))
        except InputGuardrailTripwireTriggered:
            st.write(&quot;I can't help you with that.&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;42&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;InputGuardrailTripwireTriggered: Exception raised when guardrail is triggered&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;42,1,0&quot;&gt;Handling:&lt;/b&gt; Displays &quot;I can't help you with that.&quot; when blocked&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;43&quot; data-ke-size=&quot;size23&quot;&gt;5. Integrated Usage of Context and Guardrail&lt;/h3&gt;
&lt;p data-path-to-node=&quot;44&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;44&quot;&gt;How Context is Passed to Guardrail&lt;/b&gt;&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;45&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;In main.py: Pass context=user_account_ctx&lt;/li&gt;
&lt;li&gt;Inside Runner.run_streamed(): Wrap user_account_ctx with RunContextWrapper&lt;/li&gt;
&lt;li&gt;Call off_topic_guardrail() function: Access via wrapper.context&lt;/li&gt;
&lt;li&gt;Execute input_guardrail_agent: Pass context=wrapper.context (line 29) -&amp;gt; Guardrail agent can also access customer information&lt;/li&gt;
&lt;/ol&gt;
&lt;p data-path-to-node=&quot;46&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;46&quot;&gt;How Context is Used in Dynamic Prompt&lt;/b&gt;&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal;&quot; data-path-to-node=&quot;47&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li&gt;Inside Runner.run_streamed(): Call dynamic_triage_agent_instructions(wrapper, agent)&lt;/li&gt;
&lt;li&gt;Access wrapper.context.name, email, tier&lt;/li&gt;
&lt;li&gt;Insert customer information into prompt:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;47,2,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&quot;The customer's name is nico.&quot;&lt;/li&gt;
&lt;li&gt;&quot;The customer's tier is basic.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Call LLM with personalized prompt&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 data-path-to-node=&quot;48&quot; data-ke-size=&quot;size23&quot;&gt;6. Complete Execution Flow (Context + Guardrail)&lt;/h3&gt;
&lt;p data-path-to-node=&quot;49&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;49&quot;&gt;[Step 1] Context Creation&lt;/b&gt;&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;50&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Create user_account_ctx in main.py&lt;/li&gt;
&lt;li&gt;UserAccountContext(customer_id=1, name=&quot;nico&quot;, tier=&quot;basic&quot;)[Step 2] User Input&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;User: &quot;What's the weather like today?&quot;[Step 3] Call Runner.run_streamed()&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Runner.run_streamed(triage_agent, &quot;What's the weather like today?&quot;, context=user_account_ctx) &amp;larr; Pass Context[Step 4] Context Wrapping&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Wrap user_account_ctx with RunContextWrapper&lt;/li&gt;
&lt;li&gt;Accessible via wrapper.context[Step 5] Input Guardrail Validation Starts&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Check triage_agent's input_guardrails list&lt;/li&gt;
&lt;li&gt;&amp;rarr; Find off_topic_guardrail function[Step 6] Execute off_topic_guardrail()&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;@input_guardrail decorator calls the function&lt;/li&gt;
&lt;li&gt;wrapper: RunContextWrapper[UserAccountContext] (includes context)&lt;/li&gt;
&lt;li&gt;agent: triage_agent instance&lt;/li&gt;
&lt;li&gt;input: &quot;What's the weather like today?&quot;[Step 7] Execute Guardrail Agent (with Context)&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Runner.run(input_guardrail_agent, &quot;What's the weather like today?&quot;, context=wrapper.context) &amp;larr; Pass Context&lt;/li&gt;
&lt;li&gt;&amp;rarr; input_guardrail_agent analyzes input with LLM&lt;/li&gt;
&lt;li&gt;&amp;rarr; Determines &quot;weather question is off-topic&quot;&lt;/li&gt;
&lt;li&gt;&amp;rarr; Returns InputGuardRailOutput(is_off_topic=True, reason=&quot;...&quot;)[Step 8] Create GuardrailFunctionOutput&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;return GuardrailFunctionOutput(output_info=InputGuardRailOutput(...), tripwire_triggered=True)[Step 9] Exception Raised&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Since tripwire_triggered=True&lt;/li&gt;
&lt;li&gt;&amp;rarr; InputGuardrailTripwireTriggered exception raised[Step 10] Exception Handling&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Caught in except block in main.py&lt;/li&gt;
&lt;li&gt;&amp;rarr; Display &quot;I can't help you with that.&quot;[Step 11] Main Agent Not Executed&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;triage_agent is not executed (cost savings)&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;51&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;51&quot;&gt;Example with Allowed Input (Context Usage)&lt;/b&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;[Steps 1-6] Same&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;darr;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;[Step 7] Execute Guardrail Agent&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;53&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Input: &quot;Check my account information&quot;&lt;/li&gt;
&lt;li&gt;&amp;rarr; Determines &quot;account-related request&quot;&lt;/li&gt;
&lt;li&gt;&amp;rarr; Returns InputGuardRailOutput(is_off_topic=False, reason=&quot;&quot;)[Step 8] Guardrail Passed&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;tripwire_triggered=False&lt;/li&gt;
&lt;li&gt;&amp;rarr; No exception raised[Step 9] Execute Main Agent&lt;/li&gt;
&lt;li&gt;&amp;darr;&lt;/li&gt;
&lt;li&gt;Call dynamic_triage_agent_instructions(wrapper, agent)&lt;/li&gt;
&lt;li&gt;&amp;rarr; Access wrapper.context.name, email, tier&lt;/li&gt;
&lt;li&gt;&amp;rarr; Generate prompt:
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;53,7,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&quot;The customer's name is nico.&quot;&lt;/li&gt;
&lt;li&gt;&quot;The customer's tier is basic.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&amp;rarr; Call LLM with personalized prompt&lt;/li&gt;
&lt;li&gt;&amp;rarr; &quot;Hello nico, I'll check your account information...&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-path-to-node=&quot;54&quot; data-ke-size=&quot;size23&quot;&gt;7. Key Concepts Summary&lt;/h3&gt;
&lt;p data-path-to-node=&quot;55&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;55&quot;&gt;Context Related&lt;/b&gt;&lt;/p&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;56&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Concept&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,1,0,0&quot;&gt;UserAccountContext&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,1,1,0&quot;&gt;Pydantic model containing customer account information&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,2,0,0&quot;&gt;RunContextWrapper&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,2,1,0&quot;&gt;Object that wraps context at execution time&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,3,0,0&quot;&gt;wrapper.context&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,3,1,0&quot;&gt;Access to actual UserAccountContext instance&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,4,0,0&quot;&gt;context=user_account_ctx&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;56,4,1,0&quot;&gt;Pass context to Runner&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p data-path-to-node=&quot;57&quot; data-ke-size=&quot;size16&quot;&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;57&quot;&gt;Input Guardrail Related&lt;/b&gt;&lt;/p&gt;
&lt;table style=&quot;border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-path-to-node=&quot;58&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Concept&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,1,0,0&quot;&gt;@input_guardrail&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,1,1,0&quot;&gt;Decorator that registers function as guardrail&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,2,0,0&quot;&gt;input_guardrails&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,2,1,0&quot;&gt;List that connects guardrails to agent&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,3,0,0&quot;&gt;GuardrailFunctionOutput&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,3,1,0&quot;&gt;Object that returns validation result and trigger status&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,4,0,0&quot;&gt;InputGuardrailTripwireTriggered&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,4,1,0&quot;&gt;Exception raised when blocked&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,5,0,0&quot;&gt;tripwire_triggered&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span data-path-to-node=&quot;58,5,1,0&quot;&gt;Whether guardrail was triggered&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 data-path-to-node=&quot;59&quot; data-ke-size=&quot;size23&quot;&gt;8. Interaction Between Context and Guardrail&lt;/h3&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;60&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;60,0,0&quot;&gt;Context Passing Path:&lt;/b&gt; main.py &amp;rarr; Runner.run_streamed() &amp;rarr; RunContextWrapper &amp;rarr; wrapper.context&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;60,1,0&quot;&gt;Using Context in Guardrail:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;60,1,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Access customer information via wrapper.context&lt;/li&gt;
&lt;li&gt;Pass context=wrapper.context to guardrail agent&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;60,2,0&quot;&gt;Using Context in Main Agent:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;60,2,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Insert into prompt using wrapper.context in dynamic_triage_agent_instructions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b data-index-in-node=&quot;0&quot; data-path-to-node=&quot;60,3,0&quot;&gt;Personalization:&lt;/b&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-path-to-node=&quot;60,3,1&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Personalize responses using customer name, tier, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p data-path-to-node=&quot;61&quot; data-ke-size=&quot;size16&quot;&gt;This structure validates user input before processing and uses context to generate personalized responses.&lt;/p&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/23</guid>
      <comments>https://note24432.tistory.com/23#entry23comment</comments>
      <pubDate>Tue, 30 Dec 2025 19:07:20 +0900</pubDate>
    </item>
    <item>
      <title>OPEN AI SDK - Customer support agent(1) -setup &amp;amp; full code</title>
      <link>https://note24432.tistory.com/22</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;Now we make customer support ai agent. we want cooperating multiagent and input&amp;amp;output gaurdrail.&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;First, you should setup files like this.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;214&quot; data-origin-height=&quot;497&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/WJzW9/dJMcabbMGqB/OrkklkE2cdb6zWbSwaKnkK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/WJzW9/dJMcabbMGqB/OrkklkE2cdb6zWbSwaKnkK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/WJzW9/dJMcabbMGqB/OrkklkE2cdb6zWbSwaKnkK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FWJzW9%2FdJMcabbMGqB%2FOrkklkE2cdb6zWbSwaKnkK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;214&quot; height=&quot;497&quot; data-origin-width=&quot;214&quot; data-origin-height=&quot;497&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1)main.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; dotenv&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;dotenv&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;load_dotenv&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; openai &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; OpenAI&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; asyncio&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; streamlit &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; SQLiteSession&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; InputGuardrailTripwireTriggered&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; OutputGuardrailTripwireTriggered&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; models &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; UserAccountContext&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; my_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;triage_agent &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; triage_agent&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;client &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;OpenAI&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;user_account_ctx &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;customer_id&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;nico&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tier&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;basic&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;session&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;session&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;SQLiteSession&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;chat-history&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;customer-support-memory.db&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;session&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; triage_agent&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;paint_history&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;():&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; messages &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get_items&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; message &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; messages:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; message:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;chat_message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;])&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;$&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;$&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# Streamlit 실행 모델에 맞게 수정&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; asyncio&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;paint_history&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;())&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;except&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; RuntimeError:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# 이미 실행 중인 이벤트 루프가 있는 경우 스킵&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# (Streamlit이 재실행할 때 발생할 수 있음)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;pass&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;except&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Exception &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; e:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# 다른 에러는 무시하고 계속 진행&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Error loading history: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;run_agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;chat_message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ai&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text_placeholder &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;empty&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;text_placeholder&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; text_placeholder&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stream &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run_streamed&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;user_account_ctx&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; stream&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;stream_events&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;raw_response_event&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;response.output_text.delta&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;delta&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text_placeholder&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;$&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;\$&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;elif&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent_updated_stream_event&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;new_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  Transfered from &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; to &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;new_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;new_agent&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text_placeholder &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;empty&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;text_placeholder&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; text_placeholder&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;except&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; InputGuardrailTripwireTriggered:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;I can't help you with that.&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;except&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; OutputGuardrailTripwireTriggered:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Cant show you that answer.&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session_state&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;text_placeholder&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;empty&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;chat_input&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Write a message for your assistant&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; message:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;chat_message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;human&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; asyncio&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; reset &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Reset memory&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; reset:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; asyncio&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;clear_session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;())&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;asyncio&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;session&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get_items&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()))&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2) models.py&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; pydantic &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; BaseModel&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; typing &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Optional&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #87c3ff;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;BaseModel&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; customer_id: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; name: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; tier: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;basic&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; email: Optional&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; None &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# premium entreprise&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #87c3ff;&quot;&gt;InputGuardRailOutput&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;BaseModel&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; is_off_topic: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; reason: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #87c3ff;&quot;&gt;HandoffData&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;BaseModel&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; to_agent_name: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; issue_type: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; issue_description: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; reason: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #87c3ff;&quot;&gt;TechnicalOutputGuardRailOutput&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;BaseModel&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; contains_off_topic: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; contains_billing_data: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; contains_account_data: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; reason: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3)my_agents/triage_agent.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; streamlit &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; input_guardrail&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; output_guardrail&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; GuardrailFunctionOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;extensions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;handoff_prompt &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; RECOMMENDED_PROMPT_PREFIX&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;extensions &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; handoff_filters&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; models &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; InputGuardRailOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; HandoffData&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; my_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;account_agent &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; account_agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; my_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;order_agent &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; order_agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; my_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;billing_agent &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; billing_agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; my_agents&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;technical_agent &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; technical_agent&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;input_guardrail_agent &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Input Guardrail Agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Ensure the user's request specifically pertains to User Account details, Billing inquiries, Order information, or Technical Support issues, and is not off-topic. If the request is off-topic, return a reason for the tripwire. You can make small conversation with the user, specially at the beginning of the conversation, but don't help with requests that are not related to User Account details, Billing inquiries, Order information, or Technical Support issues.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;InputGuardRailOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@input_guardrail&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;off_topic_guardrail&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; result &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input_guardrail_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;GuardrailFunctionOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;final_output&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tripwire_triggered&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;final_output&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;is_off_topic&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;dynamic_triage_agent_instructions&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;RECOMMENDED_PROMPT_PREFIX&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You are a customer support agent. You ONLY help customers with their questions about their User Account, Billing, Orders, or Technical Support.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You call customers by their name.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; The customer's name is &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; The customer's email is &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; The customer's tier is &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tier&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; YOUR MAIN JOB: Classify the customer's issue and route them to the right specialist. 절대로 technical_agent를 질문내용에 상관없이 라우팅하지 마세요. 반드시 기술관련 질문이어야 technical_agent로 라우팅하세요.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; ISSUE CLASSIFICATION GUIDE:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp;   TECHNICAL SUPPORT - Route here for:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Product not working, errors, bugs&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - App crashes, loading issues, performance problems&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Feature questions, how-to help&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Integration or setup problems&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - &quot;The app won't load&quot;, &quot;Getting error message&quot;, &quot;How do I...&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp;   BILLING SUPPORT - Route here for:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Payment issues, failed charges, refunds&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Subscription questions, plan changes, cancellations&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Invoice problems, billing disputes&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Credit card updates, payment method changes&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - &quot;I was charged twice&quot;, &quot;Cancel my subscription&quot;, &quot;Need a refund&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp;   ORDER MANAGEMENT - Route here for:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Order status, shipping, delivery questions&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Returns, exchanges, missing items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Tracking numbers, delivery problems&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Product availability, reorders&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - &quot;Where's my order?&quot;, &quot;Want to return this&quot;, &quot;Wrong item shipped&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp;   ACCOUNT MANAGEMENT - Route here for:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Login problems, password resets, account access&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Profile updates, email changes, account settings&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Account security, two-factor authentication&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Account deletion, data export requests&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - &quot;Can't log in&quot;, &quot;Forgot password&quot;, &quot;Change my email&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; CLASSIFICATION PROCESS:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 1. Listen to the customer's issue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 2. Ask clarifying questions if the category isn't clear&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 3. Classify into ONE of the four categories above&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 4. Explain why you're routing them: &quot;I'll connect you with our [category] specialist who can help with [specific issue]&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 5. Route to the appropriate specialist agent&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; SPECIAL HANDLING:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Premium/Enterprise customers: Mention their priority status when routing&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Multiple issues: Handle the most urgent first, note others for follow-up&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Unclear issues: Ask 1-2 clarifying questions before routing&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;handle_handoff&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;input_data&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: HandoffData,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Handing off to &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;input_data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;to_agent_name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Reason: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;input_data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Issue Type: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;input_data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;issue_type&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Description: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;input_data&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;issue_description&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;make_handoff&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;on_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;handle_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;input_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;HandoffData&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;input_filter&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;handoff_filters&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;remove_all_tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;triage_agent &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Triage Agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;dynamic_triage_agent_instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;input_guardrails&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; off_topic_guardrail&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;handoffs&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;make_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;technical_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;make_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;billing_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;make_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;account_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;make_handoff&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;order_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;4) tools.py&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; streamlit &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; function_tool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; AgentHooks&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Tool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; RunContextWrapper&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; models &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; UserAccountContext&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; random&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; datetime &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; datetime&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; timedelta&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# TECHNICAL SUPPORT TOOLS&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;run_diagnostic_check&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;product_name&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;issue_description&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Run a diagnostic check on the customer's product to identify potential issues.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; product_name: Name of the product experiencing issues&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; issue_description: Description of the problem&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; diagnostics &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;✅ Server connectivity: Normal&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;✅ API endpoints: Responsive&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;⚠️ &amp;nbsp;Cache memory: 85&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;% f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;ull (recommend clearing)&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;✅ Database connections: Stable&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;⚠️ &amp;nbsp;Last update: 7 days ago (update available)&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  Diagnostic results for &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;product_name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;diagnostics&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;provide_troubleshooting_steps&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;issue_type&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Provide step-by-step troubleshooting instructions for common issues.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; issue_type: Type of issue (connection, login, performance, crash, etc.)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; steps_map &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;connection&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1. Check internet connectivity&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2. Clear browser cache and cookies&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;3. Disable browser extensions temporarily&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;4. Try incognito/private browsing mode&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;5. Restart your router/modem&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;login&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1. Verify username and password&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2. Check caps lock is off&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;3. Clear browser cache&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;4. Try password reset if needed&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;5. Disable VPN temporarily&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;performance&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1. Close unnecessary browser tabs&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2. Clear browser cache&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;3. Check available RAM and storage&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;4. Update your browser&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;5. Restart the application&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;crash&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1. Update to latest version&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2. Restart the application&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;3. Check system requirements&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;4. Disable conflicting software&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;5. Run in safe mode&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; steps &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; steps_map&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; issue_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1. Restart the application&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2. Check for updates&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;3. Contact support with error details&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;add_troubleshooting_step&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Provided &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;issue_type&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; troubleshooting steps&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot; ️ Troubleshooting steps for &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;issue_type&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;steps&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;escalate_to_engineering&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;issue_summary&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;priority&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;medium&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Escalate a technical issue to the engineering team.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; issue_summary: Brief summary of the technical issue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; priority: Priority level (low, medium, high, critical)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ticket_id &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ENG-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;10000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;99999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Issue escalated to Engineering Team&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Ticket ID: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;ticket_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⚡ Priority: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;priority&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;upper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Summary: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;issue_summary&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Expected response: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;is_premium_customer&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; hours&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# BILLING SUPPORT TOOLS&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;lookup_billing_history&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;months_back&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Look up customer's billing history and payment records.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; months_back: Number of months to look back (default 6)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; payments &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;months_back&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; datetime&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;timedelta&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;days&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; amount &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;choice&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;29.99&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;49.99&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;99.99&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;])&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; status &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;choice&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Paid&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Paid&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Paid&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Failed&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;])&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; payments&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&amp;bull; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strftime&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;%b&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; %Y'&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;: $&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;amount&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; - &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;status&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  Billing History (Last &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;months_back&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; months):&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;payments&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;process_refund_request&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;refund_amount&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Process a refund request for the customer.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; refund_amount: Amount to refund&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reason: Reason for the refund&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; processing_days &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;is_premium_customer&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;5&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; refund_id &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;REF-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;✅ Refund request processed&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Refund ID: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;refund_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Amount: $&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;refund_amount&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Reason: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏱️ Processing time: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;processing_days&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; business days&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Refund will appear on original payment method&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;update_payment_method&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;payment_type&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Help customer update their payment method.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; payment_type: Type of payment method (credit_card, paypal, bank_transfer)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Payment method update initiated&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Type: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;payment_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;'_'&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;' '&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Secure link sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏰ Link expires in: 24 hours&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;✅ No interruption to current service&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;apply_billing_credit&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;credit_amount&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Apply account credit for billing issues or compensation.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; credit_amount: Amount of credit to apply&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reason: Reason for the credit&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Account credit applied&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Credit amount: $&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;credit_amount&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Reason: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⚡ Applied to account: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;customer_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Confirmation sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# ORDER MANAGEMENT TOOLS&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;lookup_order_status&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Look up the current status and details of an order.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; order_number: Customer's order number&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; statuses &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;processing&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;shipped&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;in_transit&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;delivered&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; current_status &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;choice&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;statuses&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; tracking_number &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;1Z&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; estimated_delivery &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; datetime&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;timedelta&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;days&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Order Status: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; ️ Status: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;current_status&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Tracking: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tracking_number&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Estimated delivery: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;estimated_delivery&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strftime&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;'%B &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;, %Y'&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Shipping to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;initiate_return_process&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;return_reason&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;items&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Start the return process for an order.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; order_number: Order number to return&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return_reason: Reason for return&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; items: Items being returned&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; return_id &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;RET-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; return_label_fee &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;is_premium_customer&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;5.99&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Return initiated&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Return ID: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;return_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Order: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Items: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;items&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Return label fee: $&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;return_label_fee&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Return label sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏰ Return window: 30 days&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;schedule_redelivery&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;tracking_number&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;preferred_date&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Schedule a redelivery for a failed delivery attempt.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tracking_number: Package tracking number&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; preferred_date: Customer's preferred delivery date&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Redelivery scheduled&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Tracking: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tracking_number&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  New delivery date: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;preferred_date&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Address confirmed: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Driver will call 30 minutes before delivery&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;expedite_shipping&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Upgrade shipping speed for an order (premium customers only).&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; order_number: Order to expedite&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;is_premium_customer&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;❌ Expedited shipping upgrade requires Premium membership&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⚡ Shipping expedited&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Order: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;order_number&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Upgraded to: Next-day delivery&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  No additional charge (Premium benefit)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Updated tracking sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# ACCOUNT MANAGEMENT TOOLS&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;# =============================================================================&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;reset_user_password&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Send password reset instructions to the customer's email.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; email: Email address to send reset instructions&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; reset_token &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;RST-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Password reset initiated&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Reset link sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Reset token: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;reset_token&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏰ Link expires in: 1 hour&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; ️ For security, link is single-use only&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;enable_two_factor_auth&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;method&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;app&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Help customer set up two-factor authentication.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; method: 2FA method (app, sms, email)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; setup_code &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;2FA-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Two-Factor Authentication Setup&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Method: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;method&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;upper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Setup code: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;setup_code&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Instructions sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⚡ Enhanced security activated&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;update_account_email&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;old_email&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;new_email&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Process account email address change.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; old_email: Current email address&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new_email: New email address&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; verification_code &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;VER-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Email update requested&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  From: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;old_email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  To: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;new_email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Verification code: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;verification_code&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏰ Code expires in: 30 minutes&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;✅ Change will be activated after verification&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;deactivate_account&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;feedback&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Process account deactivation request.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reason: Reason for account deactivation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; feedback: Optional feedback from customer&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⚠️ Account deactivation initiated&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Account: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;customer_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Reason: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;reason&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Feedback: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;feedback &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; feedback &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;'None provided'&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏰ Account will be deactivated in 24 hours&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Can be reactivated within 30 days&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Confirmation sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@function_tool&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;export_account_data&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: UserAccountContext, &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;data_types&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;) -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Generate export of customer's account data.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Args:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data_types: Types of data to export (profile, orders, billing, etc.)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; export_id &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;EXP-&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;randint&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ebc88d;&quot;&gt;999999&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Data export requested&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Export ID: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;export_id&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Data types: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;data_types&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;⏱️ Processing time: 2-4 hours&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Download link will be sent to: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;  Link expires in: 7 days&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #87c3ff;&quot;&gt;AgentToolUsageLoggingHooks&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;AgentHooks&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;on_tool_start&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;tool&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Tool,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;** starting tool: `&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;`&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;on_tool_end&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;tool&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Tool,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;** used tool: `&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tool&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;`&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;code&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;result&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;on_handoff&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  Handoff: **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;** &amp;rarr; **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;**&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;on_start&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;** activated&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;on_end&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;output&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; ):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;sidebar:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; st&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;  **&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;** completed&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;5) my_agents.technical_agent&lt;/p&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #181818; color: #e4e4e4;&quot;&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; agents &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; output_guardrail&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; GuardrailFunctionOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; models &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; UserAccountContext&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; tools &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; run_diagnostic_check&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; provide_troubleshooting_steps&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; escalate_to_engineering&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; AgentToolUsageLoggingHooks&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; models &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; TechnicalOutputGuardRailOutput&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;technical_output_guardrail_agent &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Technical Support Guardrail&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Analyze the technical support response to check if it inappropriately contains:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Billing information (payments, refunds, charges, subscriptions)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Order information (shipping, tracking, delivery, returns)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Account management info (passwords, email changes, account settings)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Technical agents should ONLY provide technical troubleshooting, diagnostics, and product support.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Return true for any field that contains inappropriate content for a technical support response.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_type&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;TechnicalOutputGuardRailOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;@output_guardrail&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;technical_output_guardrail&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;output&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; result &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; Runner&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; technical_output_guardrail_agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; validation &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;final_output&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; triggered &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; validation&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;contains_off_topic&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;or&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; validation&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;contains_billing_data&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;or&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; validation&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;contains_account_data&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;GuardrailFunctionOutput&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_info&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;validation&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tripwire_triggered&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;triggered&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;dynamic_technical_agent_instructions&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: RunContextWrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;agent&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;: Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;UserAccountContext&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; You are a Technical Support specialist helping &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; Customer tier: &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tier&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;(Premium Support)&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tier &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;basic&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; YOUR ROLE: Solve technical issues with our products and services.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; TECHNICAL SUPPORT PROCESS:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 1. Gather specific details about the technical issue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 2. Ask for error messages, steps to reproduce, system info&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 3. Provide step-by-step troubleshooting solutions&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 4. Test solutions with the customer&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; 5. Escalate to engineering if needed (especially for premium customers)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; INFORMATION TO COLLECT:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - What product/feature they're using&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Exact error message (if any)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Operating system and browser&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Steps they took before the issue occurred&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - What they've already tried&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; TROUBLESHOOTING APPROACH:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Start with simple solutions first&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Be patient and explain technical steps clearly&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Confirm each step works before moving to the next&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; - Document solutions for future reference&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;PREMIUM PRIORITY: Offer direct escalation to senior engineers if standard solutions don't work.&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; wrapper&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;tier &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;basic&quot;&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;technical_agent &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;Agent&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Technical Support Agent&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;dynamic_technical_agent_instructions&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;tools&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run_diagnostic_check&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; provide_troubleshooting_steps&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; escalate_to_engineering&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;hooks&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #aaa0fa;&quot;&gt;AgentToolUsageLoggingHooks&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;(),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;output_guardrails&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;=[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; technical_output_guardrail&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #e4e4e4;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <author>hyunsoo CHUNG</author>
      <guid isPermaLink="true">https://note24432.tistory.com/22</guid>
      <comments>https://note24432.tistory.com/22#entry22comment</comments>
      <pubDate>Tue, 30 Dec 2025 19:00:43 +0900</pubDate>
    </item>
  </channel>
</rss>