fix(agent): align generate_wearing_sweater tool call with MCP schema#2
Open
GRayMillerDes wants to merge 4 commits into
Open
fix(agent): align generate_wearing_sweater tool call with MCP schema#2GRayMillerDes wants to merge 4 commits into
GRayMillerDes wants to merge 4 commits into
Conversation
There was a strict schema validation mismatch crashing the agent framework when an image was uploaded. Root cause: The system prompt in \`backend/agent.py\` previously instructed the LLM to pass \`pattern_description\` as a kwarg to \[generate_wearing_sweater()\](cci:1://file:///Users/graymiller/Downloads/GitHub/holiday_workshop/03-Connect-ADK-MCP-UI/01-starter/backend/mcp_server.py:142:0-178:48). However, the corresponding tool defined in \`backend/mcp_server.py\` solely accepts an \`image_path\` argument. Resolution: - Removed the invalid \`pattern_description\` argument from the prompt examples and instructions. - Enforced a sequential tool execution pipeline within the agent instructions, ensuring the model explicitly calls \`generate_sweater_pattern\` to create the static pattern image before subsequently calling \`generate_wearing_sweater\`.
…ma in chapter 4 Root cause: The starter code in chapter 04 (04-Adding-Memory-Bank) had the same outdated schema definition bug, instructing the LLM to pass \`pattern_description\` to \[generate_wearing_sweater()\](cci:1://file:///Users/graymiller/Downloads/GitHub/holiday_workshop/04-Adding-Memory-Bank/01-starter/backend/mcp_server.py:142:0-178:48), which predictably crashed the agent when users requested to generate a sweater. Resolution: - Removed the invalid parameter from instructions in chapter 4. - Handled sequential tool execution to explicitly require calling \`generate_sweater_pattern\` before generating the selfie.
Root Cause: The starter code for deploy_agent.py was missing its mandatory Vertex AI Memory Bank types (e.g. GenerateMemoriesExample, CustomizationConfig) and the actual Agent Engine registration logic, causing it to crash with NameError. Resolution: Complete the starter deploy_agent.py by integrating the proper Vertex AI SDK class typings and the MemoryTopic customization configuration necessary for the deployment script (use_memory_bank.sh) to succeed and return an AGENT_ENGINE_ID.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Overview
This Pull Request addresses four critical blockers found in the
01-startercodebases across both03-Connect-ADK-MCP-UIand04-Adding-Memory-Bank. These issues completely broke the image generation tool pipeline, multi-turn LLM sessions, and the Vertex AI Memory Bank deployment scripts.🛠️ Fixes Applied
1. FastMCP Schema Validation Crash (agent.py)
agent_instructionprompt instructed the LLM to passpattern_descriptioninto the generate_wearing_sweater() tool. However, the MCP server exclusively accepts animage_pathargument, triggering a strict Pydantic validation error downstream.2.
TrafficTypeEnum Deepcopy Crash (main.py)AttributeError: ON_DEMAND_PRIORITY.InMemorySessionServiceattempts to use Python's nativecopy.deepcopy()to isolate session history. However, the latestgoogle-genaiSDK embeds custom Enum objects likeTrafficType.ON_DEMAND_PRIORITYinside event metadata, which lack robust pickling support and cause deepcopy to aggressively fail when reconstructing the Enum attribute.copy.deepcopyto gracefully skip deepcopyingTrafficTypeobjects without mutating the original structure. (Applied to both chapters 03 and 04).3. Missing Vertex AI Types & Engine Initialization (deploy_agent.py)
NameError: name 'GenerateMemoriesExample' is not defined.MemoryBankConfig,GenerateMemoriesExample) andCustomizationConfig, leaving the shell script to die blindly.vertexai.typesand explicitly initializing the Agent Engine deployment block to properly align with02-solution.4. Memory Bank Retrieval Tool Missing (agent.py)