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., {topic}) while preserving JSON structures like {”level”: 2}.
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
def safe_format(template: Any) -> AnyParameters
AnyTemplate string with placeholders **kwargs: Values to substitute
Returns
AnyFormatted string with safe substitutions
Uses
BaseFrameworkAdapter
Source
View on GitHubpraisonai/agents_generator.py at line 2054