Skip to content

Output Styles API

Output styles customize the tone and formatting of agent responses. Select one via the output_style parameter on create_deep_agent. See Output Styles for the conceptual overview.

OutputStyle

pydantic_deep.styles.OutputStyle dataclass

An output style that controls agent tone and response format.

Attributes:

Name Type Description
name str

Style identifier (e.g. "concise", "formal").

description str

Brief description of the style.

content str

The actual instructions to inject into the system prompt.

BUILTIN_STYLES

pydantic_deep.styles.BUILTIN_STYLES = {'concise': CONCISE_STYLE, 'explanatory': EXPLANATORY_STYLE, 'formal': FORMAL_STYLE, 'conversational': CONVERSATIONAL_STYLE, 'markdown': MARKDOWN_STYLE, 'json-only': JSON_ONLY_STYLE, 'bullet': BULLET_STYLE} module-attribute

Registry of built-in output styles, keyed by name.

resolve_style

pydantic_deep.styles.resolve_style(style, styles_dir=None)

Resolve a style by name or pass through an OutputStyle instance.

Resolution order: 1. If style is an OutputStyle, return it directly. 2. If style is a string, look up in built-in styles. 3. If not found, search in styles_dir directories. 4. If still not found, raise ValueError.

Parameters:

Name Type Description Default
style str | OutputStyle

Style name (string) or OutputStyle instance.

required
styles_dir str | list[str] | None

Directory or list of directories to search for custom styles.

None

Returns:

Type Description
OutputStyle

Resolved OutputStyle instance.

Raises:

Type Description
ValueError

If style name is not found anywhere.

discover_styles

pydantic_deep.styles.discover_styles(directory)

Discover output styles from markdown files in a directory.

Scans the directory for *.md files, parses each as a style file (frontmatter + body), and returns a dict keyed by style name. Files without a name in frontmatter are skipped.

Parameters:

Name Type Description Default
directory str | Path

Path to the styles directory.

required

Returns:

Type Description
dict[str, OutputStyle]

Dict of style name to OutputStyle.

load_style_from_file

pydantic_deep.styles.load_style_from_file(path)

Load an OutputStyle from a markdown file with frontmatter.

The file should have YAML-style frontmatter with at least a name field, followed by the style content:

Markdown
---
name: my-style
description: My custom style
---

Be very detailed in responses...

Parameters:

Name Type Description Default
path str | Path

Path to the markdown style file.

required

Returns:

Type Description
OutputStyle

Loaded OutputStyle instance.

Raises:

Type Description
FileNotFoundError

If the file doesn't exist.

ValueError

If the file has no name in frontmatter or an empty content body.

format_style_prompt

pydantic_deep.styles.format_style_prompt(style)

Format an OutputStyle for injection into the system prompt.

Parameters:

Name Type Description Default
style OutputStyle

The output style to format.

required

Returns:

Type Description
str

Formatted string ready for system prompt injection.