Learning resourcesReviewed · Pydantic

Managed Prompt guide for Pydantic AI and Logfire

Managed Prompt is a guide for Python developers updating Pydantic AI agent instructions through Logfire, with prompt text and targeting data recorded in telemetry. It explains defaults, labels, rollouts, user targeting, optional templates and effects on provider prompt caching.

Researched 15 Nov 2026

In short.

Managed Prompt is a guide for Python developers who want to change Pydantic AI agent instructions through Logfire without redeploying, but the integration records prompt text and targeting data in telemetry. It documents the ManagedPrompt capability, including code defaults, controlled rollouts, stable user assignments, templates and trace attribution. Practical caveats include missing-label fallback, synchronous initial resolution, cache fragmentation and access to dependency values through templates. No execution results, measured performance, prices or licence terms are supplied.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is limited to the complete selected page at [https://pydantic.dev/docs/ai/harness/managed-prompt/index.md], captured at 2026-11-15T04:18:10.525Z with source SHA-256 81a8c0d0b0f99d753590553fa1fab54045880f2e20879b627f39ce64933df5c7. It includes installation, usage, targeting, templating, caching, variable composition, telemetry, the API reference and the 0.x API-change notice. Linked pages, repository contents, package files, licence texts and service terms are excluded. No commands or examples were executed; runtime behavior, performance and deployment outcomes remain unverified.

The overview

Identity

This documentation page explains ManagedPrompt, a Pydantic AI Harness capability that supplies agent instructions from a Logfire-managed prompt. Developers attach it through the Agent capabilities parameter; prompt editors can then edit, version, label and roll out instructions in the Logfire UI.

The original page is [https://pydantic.dev/docs/ai/harness/managed-prompt/index.md]. It combines an integration guide, Python examples, operational explanations and an API reference.

Assessment

The guide is useful for teams whose agent instructions change frequently and who want prompt releases to happen independently of application deployments. It explains both the basic integration and consequential details, such as associating traces with prompt labels and versions.

Its examples support understanding and implementation planning. Production reliability, response quality, latency, throughput and rollout outcomes are not demonstrated, and the examples were not executed.

Users

The primary audience is Python developers building Pydantic AI agents, especially applications such as customer support assistants where instructions need revisions, experiments or rollback. Developers responsible for tracing and performance also get guidance on telemetry and prompt-cache behavior.

After integration, people with suitable Logfire access can change managed prompts through its UI. Initial setup still requires Python development and Logfire configuration; the page does not explain account permissions or provide a complete beginner introduction to either system.

Capabilities

ManagedPrompt can select a named label, follow percentage rollouts, use a targeting_key for deterministic assignment and accept attributes for condition-based targeting. A code default supplies instructions until a remote value is published. Changes are resolved at the start of the next run.

Optional Handlebars rendering fills template fields from the agent's deps, the application data supplied to a run. ManagedPrompt.resolved exposes the active resolution, including value, label, version and reason, during the run. The capability can also accept a previously declared Logfire Variable.

Using it

Requirements

The documented setup uses a Python project with Pydantic AI, Pydantic AI Harness installed with its logfire extra, and configured Logfire access. The agent examples also assume access to their configured model provider; provider credential setup is not explained.

A default string is required when constructing ManagedPrompt from a prompt name. Minimum Python version and a complete dependency compatibility matrix are unspecified. Recording the resolved version in tracing baggage requires Logfire 4.34 or later; the selected label is also recorded.

Mechanism

A prompt name such as support_agent maps to the managed variable prompt__support_agent, with hyphens normalized to underscores. The wrap_run hook resolves that variable once and supplies its string value as system instructions. The resolved variable's context stays open throughout the run so tracing metadata covers the run and its child spans.

The documentation describes per-run context isolation, allowing a capability instance to be shared across concurrent runs. ManagedPrompt.resolved is available within the active run and is None outside it.

When a conversation continues through message_history, changed instructions are appended as replacement system messages rather than rewriting the original conversation prefix. A stable capability ID identifies the instruction block being updated.

Setup

The page gives two installation options: pip install "pydantic-ai-harness[logfire]" and uv add "pydantic-ai-harness[logfire]". For an unconfigured project, it directs users to uvx logfire-cli wizard --task pydantic-ai.

The integration pattern calls logfire.configure(), imports ManagedPrompt and adds it to Agent(capabilities=[...]). Supply a prompt name and code default. If experiments are unnecessary, the page recommends an explicit production label; that label must exist, because an unknown label falls back to rollout and targeting rules.

Example

The customer-support example creates a ManagedPrompt named support_agent, supplies fallback support instructions and selects label='production'. It attaches the capability to an Agent, sends the message 'My order never arrived.' through run_sync and prints result.output. The page supplies no resulting model response.

Further examples derive targeting_key from ctx.deps.user_id and render a customer_name field into a template. These illustrate stable user assignment and personalized instructions; their behavior was not executed or measured.

Assessment & evidence

Limitations

Logfire records a resolution span containing prompt text, targeting keys and targeting attributes. InstrumentationSettings(include_content=False) does not suppress this span. With render_template=True, prompt editors can insert any deps field into system instructions and potentially traces. The page advises keeping secrets out of deps or leaving rendering disabled, and using controlled text for instructions.

An invalid remote template falls back to the code default, emits warnings and reports the default as the resolved value, with the template error available through resolved.exception. An invalid code default raises. General network and authentication failure behavior is not established.

Without an explicit label, targeting rules choose the label. Without a targeting key, resolution falls back to Logfire's targeting context and then an enclosing trace ID; with neither, assignment is random per run. A missing explicit label also falls back to targeting rules.

Resolution is synchronous. With Logfire's remote variables provider, the first resolution waits for initial configuration unless block_before_first_resolve=False permits using the code default. The page supplies no timing measurements.

Reasoning

The strongest adoption case is a need to change prompts independently of application releases while retaining trace-level attribution. That follows from resolving instructions at run start and carrying the selected prompt metadata through the run. The page does not establish that this improves model answers or reduces operational costs.

Adoption also makes prompt editing an application-control responsibility: published instructions affect subsequent runs, and template editors can access dependency fields. Teams need to weigh that operational flexibility against telemetry exposure, remote-resolution behavior and effects on caching.

Alternatives

Keeping instructions in application code is the baseline alternative described by the page's edit, review and deploy comparison. It may suit infrequent prompt changes, although changes then follow the application's deployment process. The source does not compare other prompt-management services.

Within ManagedPrompt, a fixed existing label offers a simpler operating mode than percentage rollouts. Declaring a plain variable with logfire.var and passing it to ManagedPrompt enables registration for variables_push and composition from other variables. Automatically created variables are unregistered, and TemplateVariable is unsupported.

Multiple prompts on one agent need distinct capability IDs. Different prompt names receive distinct IDs automatically; duplicate names raise UserError unless IDs are overridden.

Evidence

The evidence consists of the complete documentation page at [https://pydantic.dev/docs/ai/harness/managed-prompt/index.md]. It includes installation instructions, conceptual explanations, Python examples, operational caveats and the ManagedPrompt API reference.

These support statements about documented functionality. Linked documentation, implementation files, service terms and licence files are outside scope. No execution logs, benchmarks, deployment observations or independent validation are supplied.

Access & freshness

Costs

The page provides no package price, Logfire plan details, model-provider rates or total cost estimate. Cost is unknown and depends on the services and configuration used.

The documented cost-related trade-off concerns prompt caching. Distinct resolved prompts create distinct cached prefixes across conversations. Multiple rollout labels can divide cache reuse, and a label change gives new conversations a cold prefix. Pinning an existing label without a rollout split keeps the prompt stable until a deliberate change. No cache-hit rates, token savings or monetary effects are measured.

Rights

The selected page contains no licence or redistribution terms. It links to implementation source at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/logfire/], but repository licence files and Logfire service terms are outside the supplied evidence. Rights to reuse or redistribute the documentation, examples and package code are therefore not established here.

Freshness

The page was captured on 15 November 2026. It warns that Pydantic AI Harness 0.x APIs may change between minor releases, with deprecation warnings and migration guidance described as the upgrade mechanism. It also distinguishes version metadata available from Logfire 4.34 onward.

The page does not identify its publication date, last update date or exact Harness release. Compatibility with a particular installed release remains unknown.

Actions

Before adoption, confirm dependency compatibility, applicable licences, Logfire terms and actual service costs. Review who can edit prompts and what prompt, targeting and dependency data may enter telemetry. Choose a code default and confirm that any pinned label exists.

In the intended environment, verify next-run updates, rollback, missing-label fallback, conversation-history changes and invalid-template handling. For experiments, verify stable targeting assignments. Measure initial resolution delay and cache behavior with the actual model provider. These behaviors remain unassessed by execution.

Evidence for this report

selected-page.txtselected · checked 2026-11-15