Skip to content

feat(ai): model prompt and reply text kept out of telemetry by default #606

Closed

Description

@dan-petty

Context & Rationale

When --logfire or telemetry.logfire: true is set (commands/review.py:146-160), LogfireBridge.configure calls logfire.instrument_pydantic() and instrument_pydantic_ai() with no arguments and passes no scrubbing (telemetry/logfire.py:206-217); once a token resolves, spans go to Logfire (logfire.py:191-198). Review personas run through devops-cli's own PydanticAgent and LLMClient, not pydantic_ai.Agent, so today's leak is instrument_pydantic at its default record='all': validation spans carry the prompt and reply held in CachedLLMResponse and AgentResponse. Separately, every native ai.llm.dispatch span carries gen_ai.prompt_preview (ai/client/unified.py:372), every successful one gen_ai.response_preview (:92), exported unmasked (telemetry/tracer.py:871-888) with native export on by default (config/settings.py:263). redact_text (security/sanitizer.py:177) has no private-host pattern. vibes documents collector-side scrubbing its shipped collector config never implements.

Scope & Deliverables

  • Context & Rationale*: When --logfire or telemetry.logfire: true is set (commands/review.py:146-160), LogfireBridge.configure calls logfire.instrument_pydantic() and instrument_pydantic_ai() with no arguments and passes no scrubbing (telemetry/logfire.py:206-217); once a token resolves, spans go to Logfire (logfire.py:191-198). Review personas run through devops-cli's own PydanticAgent and LLMClient, not pydantic_ai.Agent, so today's leak is instrument_pydantic at its default record='all': validation spans carry the prompt and reply held in CachedLLMResponse and AgentResponse. Separately, every native ai.llm.dispatch span carries gen_ai.prompt_preview (ai/client/unified.py:372), every successful one gen_ai.response_preview (:92), exported unmasked (telemetry/tracer.py:871-888) with native export on by default (config/settings.py:263). redact_text (security/sanitizer.py:177) has no private-host pattern. vibes documents collector-side scrubbing its shipped collector config never implements.
  • Deliverable*: One PR. Add telemetry.capture_llm_content: bool = False; while off, call instrument_pydantic(record="failure") and instrument_pydantic_ai(include_content=False) (the latter guards the exported pydantic_ai helpers, which have no runtime caller yet), pass scrubbing=logfire.ScrubbingOptions(extra_patterns=PRIVATE_HOST_PATTERNS) with that constant beside _SECRET_PATTERNS, and emit the two gen_ai.*_preview attributes only when capture is on. Leave agent.prompt/agent.response: only devops telemetry test sets them, with fixed strings. Test: configure the bridge with a capturing processor, drive PydanticAgent + LLMClient on a stubbed driver with node1.example.internal in the prompt, and assert the hostname is in no Logfire-captured attribute and nothing from get_recent_spans(); a capture-on case asserts the previews return. Cross-check pattern hits with is_loopback_or_private_host (core/validation.py:81), not a new IP check. Attribute names are unchanged.
  • Constraint*: Logfire 5.1.0 exempts gen_ai.input.messages, gen_ai.output.messages and pydantic_ai.all_messages from scrubbing (_internal/scrubbing.py:161-168); once pydantic_ai.Agent gains a caller, ScrubbingOptions looks configured while message bodies pass intact, so include_content=False is the only switch. A broad hostname regex also matches dotted code identifiers and Logfire replaces the whole value on a match, so count hits over recorded spans before choosing patterns. A collector redaction processor is out of scope: traces export only to in-cluster Jaeger and logs only to debug (k8s/otel/values.yaml:91, :104), and it would never see Logfire's export.
  • Measured*: Scratch probe mirroring logfire.py:206-217 around PydanticAgent + LLMClient on a stubbed driver: python realpath_probe3.py late gives 3 pydantic.validate_python spans carrying the marker in input_data/result; P_SCRUB=1 python realpath_probe3.py late (extra pattern) leaves 0 marker attributes; P_FAIL=1 python realpath_probe3.py late (record="failure") emits 0 spans. python scrub_probe.py default (standalone pydantic_ai.Agent, extra pattern set): marker still in 2 exempt attributes.
  • Source*: vibes resources/docker-compose/README.md, resources/observability/README.md, resources/README.md, resources/observability/otel-collector-config.yaml

Update 2026-10-08: refinement

Today's leak is gone (#858; telemetry/logfire.py:214-215 calls only instrument_pydantic_ai()); drop instrument_pydantic(record="failure"). With the owner's #1001 decision, direct requests record message bodies, so include_content=False while capture is off is the main fix. Gate llm.prompt_preview and llm.response_preview (ai/client/unified.py:375, :148). After #1001 lands, the test drives TestModel offline. Whichever of this item and #1001 lands second wires include_content.

Proposed design

Problem statement

The issue addresses a security vulnerability where model prompts and replies are being exposed in telemetry data by default when Logfire is enabled. This occurs through Pydantic validation spans and native AI LLM dispatch spans that carry unmasked prompt and response preview data.

Acceptance criteria

  • Criterion 1: When --logfire or telemetry.logfire: true is set, Pydantic spans should not include prompt and reply content by default
    Verification: Configure LogfireBridge with telemetry enabled, run PydanticAgent + LLMClient on a stubbed driver with private hostnames in prompt, assert no hostname appears in Logfire-captured attributes
  • Criterion 2: Native AI spans should not include gen_ai.prompt_preview and gen_ai.response_preview when capture is off
    Verification: Run test that asserts these preview attributes are only emitted when capture is explicitly enabled
  • Criterion 3: The telemetry configuration should support a new telemetry.capture_llm_content: bool = False setting
    Verification: Verify that the new setting properly gates content capture behavior in both Pydantic and native AI spans

Key questions

  • What is the proposed solution for handling private host patterns in scrubbing?: The solution involves adding PRIVATE_HOST_PATTERNS beside _SECRET_PATTERNS and using ScrubbingOptions(extra_patterns=PRIVATE_HOST_PATTERNS) when capturing telemetry (proposed)
  • What is the expected behavior when capture_llm_content is enabled?: When telemetry.capture_llm_content: true, Pydantic spans should record all content and native AI spans should include gen_ai.prompt_preview and gen_ai.response_preview attributes (proposed) [sources: docs/agent/tasks/task-606-model-prompt-and-reply-text-kept-out-of-telemetry-by-default.md]

Open questions

  • What are the specific telemetry leak points mentioned in the issue? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added this to the v0.2.23 milestone on Sep 25, 2026
  2. added
    type/feature
    scope/ai
    priority/p2-medium
    on Sep 25, 2026
  3. modified the milestones: v0.2.23, v0.2.24 on Sep 28, 2026
  4. removed this from the v0.2.23 milestone on Oct 1, 2026
  5. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.

  6. added
    scope/telemetry
    on Oct 2, 2026
  7. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    More evidence for this issue from the devsecops review session 20261001-224227 (2026-10-02). Each finding below was triaged against release/v0.2.25 (c279c18), judged real and covered by this issue, and then upheld by a second agent that tried to refute it.

    • Potential information exposure in telemetry recording (src/devops_cli/ai/client/unified.py:373, re-rated LOW): The prompt-preview part is real. _dispatch_messages sets "llm.prompt_preview": prompt_preview, the first 200 characters of the last user message (unified.py:373-393). _set_response_span_attributes sets llm.response_preview (unified.py:127). Both are exported unmasked. Open issue feat(ai): model prompt and reply text kept out of telemetry by default #606 ('model prompt and reply text kept out of telemetry by default') names exactly these two preview attributes and gates them behind telemetry.capture_llm_content=False. The backend_info part is not sensitive. It is the string provider (host), and the span sets only server.address from …
  8. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Ordering and a correction from the library-first batch (2026-10-03):

  9. modified the milestones: v0.2.39, on Oct 17, 2026
  10. added a commit that references this issue on Oct 24, 2026
    1ac4c98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aiscope/telemetrytype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions