Dynamic Agent Tool Definition for Text-to-Image Orchestration
Generate a production-ready Python tool definition and prompt builder script for autonomous text-to-image agent toolchains.
Use this template when designing OpenAI-compatible or Anthropic tool-calling schemas that translate agent reasoning into structured diffusion prompts. It bridges raw LLM tool invocations with parameterized image generation endpoints.
Role: Senior Agentic Systems Architect & Multi-Modal Tooling Engineer
Context
- Target Diffusion Backend: {{target_diffusion_model}}
- Agent Orchestration Layer: {{orchestrator_framework}}
- Visual Domain & Aesthetic Target: {{visual_domain}}
- Mandatory Parameter Attributes: {{parameter_schema}}
- Negative Token Architecture: {{negative_prompt_strategy}}
- Deployment Runtime: {{execution_runtime}}
Task
Develop an end-to-end Python script containing rigorous JSON Schema / Pydantic tool definitions, validation logic, and a dynamic prompt synthesis engine that an autonomous agent invokes to generate deterministic, production-grade image prompts for {{target_diffusion_model}} within {{orchestrator_framework}}.
Method
- Define strongly typed Pydantic models mapping directly to {{parameter_schema}}, enforcing strict value boundaries, aspect ratio enums, and seed constraints.
- Construct the tool signature schema conforming to {{orchestrator_framework}} tool-calling standards.
- Implement dynamic prompt sanitization routines that strip markdown artifacts, conversational filler, and non-visual abstractions.
- Build a domain-specific visual enrichment module tailored to {{visual_domain}} that injects lighting, composition, and technical camera tokens.
- Integrate {{negative_prompt_strategy}} into a dedicated negative prompt assembler.
- Implement the primary execution function with asynchronous dispatch handlers formatted for {{execution_runtime}}.
- Add structured logging that records incoming agent thoughts, transformed prompt tokens, and resolved API payload parameters.
Constraints
- The script MUST be fully executable Python without placeholder functions, pseudo-code, or unhandled exceptions.
- MUST NOT hardcode API credentials; consume environment variables via configuration classes.
- All prompt-building functions MUST enforce deterministic string formatting.
- Code MUST include comprehensive type hints and docstrings for agent self-discovery.
Output format
Provide the response as a single, multi-section Python script containing:
- Environment imports and Pydantic schema declarations.
- Tool definition metadata object for {{orchestrator_framework}}.
- Prompt translation and enrichment helper classes.
- The primary asynchronous entrypoint function.
- An executable
__main__block demonstrating a simulated agent tool call payload.
Self-review
- Verify all variables ({{target_diffusion_model}}, {{orchestrator_framework}}, {{visual_domain}}, {{parameter_schema}}, {{negative_prompt_strategy}}, {{execution_runtime}}) are explicitly handled.
- Confirm the script validates edge cases such as missing parameters or out-of-bound aspect ratios.
- Ensure no placeholder tokens remain in prompt synthesis templates.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.