Safe Format • AI Agents Framework

safe_format: Safe string formatting that preserves JSON/dict literals while substituting variables.

safe_format

Function

</div>

This function is defined in the agents_generator module.

Safe string formatting that preserves JSON/dict literals while substituting variables.

This function only substitutes placeholders that look like identifiers (e.g., &#123;topic&#125;) while preserving JSON structures like &#123;”level”: 2&#125;.

Delegates to the single source of truth, `BaseFrameworkAdapter._format_template in the core SDK, so the wrapper and core cannot drift (non-string short-circuit, regex, missing-key handling). _format_template` is stateless; a fresh instance is free.

Signature

python
def safe_format(template: Any) -> Any

Parameters

ParamField Any

Template string with placeholders **kwargs: Values to substitute

Returns

ResponseField Any

Formatted string with safe substitutions

Uses

  • BaseFrameworkAdapter

Source

View on GitHub

praisonai/agents_generator.py at line 2054