Skip to content

Commit 423542a

Browse files
seanzhougooglecopybara-github
authored andcommitted
fix: shared default plugin manager and cost manager instances among multiple invocations
PiperOrigin-RevId: 791303349
1 parent 37dae9b commit 423542a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/google/adk/agents/invocation_context.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from google.genai import types
2121
from pydantic import BaseModel
2222
from pydantic import ConfigDict
23+
from pydantic import Field
24+
from pydantic import PrivateAttr
2325

2426
from ..artifacts.base_artifact_service import BaseArtifactService
2527
from ..auth.credential_service.base_credential_service import BaseCredentialService
@@ -154,10 +156,12 @@ class InvocationContext(BaseModel):
154156
run_config: Optional[RunConfig] = None
155157
"""Configurations for live agents under this invocation."""
156158

157-
plugin_manager: PluginManager = PluginManager()
159+
plugin_manager: PluginManager = Field(default_factory=PluginManager)
158160
"""The manager for keeping track of plugins in this invocation."""
159161

160-
_invocation_cost_manager: _InvocationCostManager = _InvocationCostManager()
162+
_invocation_cost_manager: _InvocationCostManager = PrivateAttr(
163+
default_factory=_InvocationCostManager
164+
)
161165
"""A container to keep track of different kinds of costs incurred as a part
162166
of this invocation.
163167
"""

0 commit comments

Comments
 (0)