Skip to content

Changed example to use the Global Instruction Plugin (#1244) - #2177

Open
JuanCaCoder wants to merge 1 commit into
mainfrom
GlobalInstructionPlugin_example
Open

Changed example to use the Global Instruction Plugin (#1244)#2177
JuanCaCoder wants to merge 1 commit into
mainfrom
GlobalInstructionPlugin_example

Conversation

@JuanCaCoder

Copy link
Copy Markdown
Collaborator

Changed the code sample to use the GlobalInstructionPlugin.

@JuanCaCoder

Copy link
Copy Markdown
Collaborator Author

📝 Executive Summary

  • Migrates the Python A2A Consuming Quickstart sample from the deprecated Agent.global_instruction parameter to GlobalInstructionPlugin registered via App(plugins=[...]).
  • Aligns the quickstart with the modern ADK application architecture and prevents runtime DeprecationWarning exceptions while preserving global instruction behavior across sub-agents.
  • Target doc: docs/a2a/quickstart-consuming.md (rendered under /a2a/quickstart-consuming/).

🗂️ PR Consolidation & Verification Mapping

PR / Source Reference Original Section New Section Change Description Codebase Verification
docs/a2a/quickstart-consuming.md #### How it works (Snippet) #### How it works (Snippet) Removed deprecated global_instruction from root_agent = Agent(...); added App(name="a2a_basic", root_agent=root_agent, plugins=[GlobalInstructionPlugin(...)]). ✅ PASS
google/adk/plugins/global_instruction_plugin.py:L58-L85
google/adk/apps/app.py:L53-L83
docs/a2a/quickstart-consuming.md #### How it works (Prose) #### How it works (Admonition) Added !!! note "Global instructions via Plugins" note explaining deprecation of Agent.global_instruction and pointing to GlobalInstructionPlugin. ✅ PASS
google/adk/agents/llm_agent.py:L758-L766
docs/agents/llm-agents.md:L206-L210
docs/a2a/quickstart-consuming.md Introductory text Introductory text Added link to GlobalInstructionPlugin under /plugins/#prebuilt-plugins. ✅ PASS
docs/plugins/index.md:L67-L68

🔍 Technical Verification Report

  1. GlobalInstructionPlugin Implementation & Lifecycle:

    • Source: src/google/adk/plugins/global_instruction_plugin.py:L58-L115
    • Verified: GlobalInstructionPlugin inherits from BasePlugin. Its constructor accepts global_instruction: Union[str, InstructionProvider] = "" and name: str = "global_instruction". In before_model_callback, it resolves static strings or InstructionProvider callables and prepends the instruction to llm_request.config.system_instruction.
  2. Agent.global_instruction Deprecation:

    • Source: src/google/adk/agents/llm_agent.py:L288-L299, L758-L766
    • Verified: The field is marked deprecated in docstrings and emits a runtime DeprecationWarning ("global_instruction field is deprecated and will be removed in a future version. Use GlobalInstructionPlugin instead for the same functionality at the App level.").
  3. App Container Architecture:

    • Source: src/google/adk/apps/app.py:L53-L83
    • Verified: App requires name: str and root_agent: Union[BaseAgent, Any, None]. It accepts plugins: list[BasePlugin] = Field(default_factory=list), which applies registered plugins application-wide across all local and remote sub-agents.
  4. Runner plugins Deprecation:

    • Source: src/google/adk/runners.py:L285-L286, L386-L387
    • Verified: Passing plugins directly to Runner is deprecated in favor of App(plugins=[...]), confirming App as the canonical entry point for plugin registration.

@JuanCaCoder

Copy link
Copy Markdown
Collaborator Author

📝 Executive Summary

  • Updates the A2A Consuming Quickstart sample to replace the deprecated Agent.global_instruction parameter with the modular GlobalInstructionPlugin registered at the App level.
  • Aligns the guide with ADK's modern architecture, ensuring application-wide instructions and personality persist across hierarchical sub-agents without runtime deprecation warnings.
  • Targets: Target Doc: docs/a2a/quickstart-consuming.md

🗂️ PR Consolidation & Verification Mapping

PR / Source Reference Original Section New / Updated Section Change Description Codebase Verification & GitHub Source
PR #2177 / Branch docs/a2a/quickstart-consuming.md docs/a2a/quickstart-consuming.md Deprecate Agent(global_instruction=...) and adopt App(plugins=[GlobalInstructionPlugin(...)]) ✅ PASSglobal_instruction_plugin.py:L58-L124

🔍 Technical Verification Report

  1. GlobalInstructionPlugin Plugin Architecture:

    • Claimed Doc Behavior: Replaces the deprecated global_instruction field on Agent by providing system instruction injection across the agent hierarchy via GlobalInstructionPlugin registered on App.
    • Verified Code Implementation: GlobalInstructionPlugin extends BasePlugin and hooks into before_model_callback to prepend the global instruction to llm_request.config.system_instruction.
    • GitHub Source Link: src/google/adk/plugins/global_instruction_plugin.py#L58-L124
    • Status: ✅ PASS
  2. Agent.global_instruction Deprecation Status:

  3. App Container Initialization & Plugin Support:

    • Claimed Doc Behavior: Encapsulates root_agent and plugins inside an App(name="a2a_basic", root_agent=root_agent, plugins=[...]) definition.
    • Verified Code Implementation: App defines fields name: str, root_agent: Union[BaseAgent, Any, None], and plugins: list[BasePlugin] = Field(default_factory=list).
    • GitHub Source Link: src/google/adk/apps/app.py#L53-L83
    • Status: ✅ PASS
  4. Module Imports Verification:

  5. Internal Anchor Reference:

    • Claimed Doc Behavior: Links to [GlobalInstructionPlugin](/plugins/#prebuilt-plugins).
    • Verified Code Implementation: Section ## Prebuilt Plugins exists in docs/plugins/index.md and indexes GlobalInstructionPlugin.
    • GitHub Source Link: docs/plugins/index.md#L56-L73
    • Status: ✅ PASS

@JuanCaCoder
JuanCaCoder marked this pull request as ready for review September 1, 2026 17:56
@JuanCaCoder JuanCaCoder changed the title changed example to plugin Changed example to use the Global Instruction Plugin Sep 1, 2026
@JuanCaCoder JuanCaCoder changed the title Changed example to use the Global Instruction Plugin Changed example to use the Global Instruction Plugin (#1244) Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant