penguiflow generate¶
What it is / when to use it¶
penguiflow generate turns an agent spec YAML into a runnable workspace:
- scaffold a project (via the same template system as
penguiflow new) - generate typed tools (Pydantic models + tool functions)
- generate planner wiring and config
- optionally generate flows and orchestrators
- generate tests and environment docs
- persist the spec as
agent.yamlso the playground can discover it
Use it when you want a spec-first, repeatable “declarative config → code” pipeline.
Non-goals / boundaries¶
- This is not a full codegen platform. The generated code is intentionally simple and intended to be edited.
- The spec is not a secrets store; do not put credentials in YAML committed to git.
--initis a workspace bootstrapper; it is not “dry-run safe” (see constraints below).
Contract surface¶
Modes¶
- Initialize a spec workspace:
penguiflow generate --init my-agent
- Generate from an existing spec:
penguiflow generate --spec path/to/my-agent.yaml
Options and constraints¶
- Exactly one of
--initor--specis required. --initcannot be combined with--spec.--dry-runis not supported with--init.--output-dircontrols where the workspace directory is created (defaults to cwd).--forceoverwrites existing files.--verboseprints a generation summary and progress.
Spec schema highlights (what’s validated)¶
The spec is parsed and validated with line-numbered error reporting. Highlights:
agent.templateis one of:minimal,react,parallel,rag_server,wayfinder,analyst,enterprise- tool type annotations support:
str,int,float,boolOptional[T]list[T]dict[K,V](K must be primitive)- external tools configuration supports:
- preset MCP servers (by name), optionally overriding auth and env
- custom MCP/UTCP connections
- OAuth external tools require HITL (
agent.flags.hitl: true) and are validated accordingly
Operational defaults (recommended)¶
- Treat YAML as source of truth, but commit generated code only if your org prefers checked-in artifacts.
- Run generation in CI for drift detection if you keep the spec authoritative.
- Keep
agent.yamlin sync (it is what the playground discovers).
Runnable examples¶
1) Bootstrap and generate¶
uv run penguiflow generate --init my-agent
cd my-agent
# edit my-agent.yaml
uv run penguiflow generate --spec my-agent.yaml --verbose
uv run penguiflow dev --project-root .
2) Minimal spec excerpt (tools + external tools)¶
agent:
name: my-agent
description: "Example agent"
template: react
flags:
hitl: true
tools:
- name: search_documents
description: "Search documents"
side_effects: read
tags: ["search"]
args:
query: str
top_k: Optional[int]
result:
documents: list[str]
external_tools:
presets:
- preset: github
auth_override: oauth
env:
GITHUB_OWNER: "my-org"
Failure modes & recovery¶
- Validation errors: the CLI reports precise spec paths and line numbers; fix the YAML at the reported location.
- You used OAuth without HITL: set
agent.flags.hitl: trueor switch auth to bearer/none. - Files skipped: output already exists; use
--forceintentionally. - Generator crashes on templates: ensure Jinja2 is installed (
penguiflow[cli]).
Observability¶
- Use
--verbosefor progress logging and a final summary. - Generated projects should attach structured logging and event capture as described in:
- Logging
- Telemetry patterns
Security / multi-tenancy notes¶
- Do not store API keys in YAML. Use
.env(uncommitted) and secret managers. - Be careful with external tool config: treat tool outputs as untrusted; prefer allowlists and HITL gates for sensitive operations.
Troubleshooting checklist¶
- If the playground can’t find your spec, confirm
agent.yamlexists at the project root (generation writes it). - If code generation overwrote edits, move hand-written code into separate modules and keep generated targets distinct (or use
--forcesparingly).