Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/unit/vertex_adk/test_agent_engine_templates_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,10 @@ def test_span_content_capture_disabled_by_default(self):
@mock.patch.dict(
os.environ, {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}
)
def test_span_content_capture_enabled_with_env_var(self):
def test_span_content_capture_disabled_with_env_var(self):
app = agent_engines.AdkApp(agent=_TEST_AGENT)
app.set_up()
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "true"
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "false"

@mock.patch.dict(os.environ)
def test_span_content_capture_enabled_with_tracing(self):
Expand Down
12 changes: 4 additions & 8 deletions vertexai/agent_engines/templates/adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,10 @@ def set_up(self):
location = self._tmpl_attrs.get("location")
os.environ["GOOGLE_CLOUD_LOCATION"] = location

content_enabled = os.getenv(
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "false"
).lower() in ("true", "1")
# Disable content capture in custom ADK spans unless:
# 1. User opted-in for content capture.
# 2. Or user enabled tracing explicitly with the old flag (this is to
# preserve compatibility with old behavior).
if self._tmpl_attrs.get("enable_tracing") or content_enabled:
# Disable content capture in custom ADK spans unless user enabled
# tracing explicitly with the old flag
# (this is to preserve compatibility with old behavior).
if self._tmpl_attrs.get("enable_tracing"):
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "true"
else:
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false"
Expand Down