promptflow-to-maf
Skill11 starsChanged 6 months agoMITView on GitHub
Convert Prompt Flow flow definitions to Microsoft Agent Framework (MAF)
- Reads credentials
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- microsoft/promptflowedited, first seen Apr 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- microsoft/promptflow★ 11k99% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository37 other files it gives its agents.
- Browser ML in JavaScriptSkill
- CLI BuilderSkill
- ClickHouse Best PracticesSkill
- Code ReviewerSkill
- Code Review WorkflowSkill
- Commit Message WriterSkill
- deepeval Pytest Eval SuiteSkill
- deepeval OTel Trace ExportSkill
- deepeval SDK TracingSkill
- Doc Co-Authoring WorkflowSkill
- Embedding Model TrainingSkill
- Frontend Large-Feature ArchitectureSkill
- Frontend Visual Design TasteSkill
- Goal DefinitionSkill
- Internal Comms AuthoringSkill
- Invalid Name HandlerSkill
- LLM Model Pricing File UpdateSkill
- maf-prs-jobSkill
- MCP Server BuilderSkill
- Code Ownership & Bus FactorSkill
- PDF SummarizerSkill
- PDF Vision ExtractorSkill
- PNPM Upgrade PackageSkill
- promptfoo Eval Suite AuthorSkill
- promptfoo Redteam Plugin AuthorSkill
- Single-Flow PR YeetSkill
- React Router Search Param StateSkill
- Realtime Eval ScaffoldSkill
- Secure Code by LanguageSkill
- Security Review ChecklistSkill
- Skill Authoring LoopSkill
- SQL Query HelperSkill
- Storybook Component StoriesSkill
- Unit Test GeneratorSkill
- Repository Threat ModelSkill
- Turborepo Monorepo AuthoringSkill
- Webapp Testing HarnessSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Use this skill when you need guidance on promptflow-to-maf.
- Distinctive: line 51
When converting a Prompt Flow to MAF, follow these steps:
- Very specific: line 52
Read the source flow.dag.yaml and all referenced files (.jinja2, .py, requirements.txt).
- Very specific: line 55
Create the output folder <original-folder>-maf/ and generate one Executor per node.
- Very specific: line 110
Update all file path references (e.g., DEFAULT_DATA, _TEMPLATES_DIR, _PROMPT_TEMPLATE) to point to the local copy using …
- Distinctive: line 186
If any check fails, fix the workflow before proceeding.
- Distinctive: line 214
Do not use this skill for tasks outside its scope.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to use
Use this skill when you need guidance on promptflow-to-maf.
Inputs
User request or task description.
Output
Generated content based on the user request.
Prompt
When converting a Prompt Flow to MAF, follow these steps:
- Read the source
flow.dag.yamland all referenced files (.jinja2,.py,requirements.txt). - Map the node dependency graph and produce a node-mapping table.
- Detect special cases (evaluation flows, custom tools, multimodal inputs) and load the matching topic file.
- Create the output folder
<original-folder>-maf/and generate one Executor per node. - Wire the workflow inside a
create_workflow()factory usingWorkflowBuilder. - Generate supporting files (
requirements.txt,.env.example,test_<name>.py). - Validate graph topology equivalence against the original
flow.dag.yaml.
Prompt Flow → Microsoft Agent Framework Conversion
Convert Prompt Flow
flow.dag.yamldefinitions into runnable MAFWorkflowBuilderPython code.
Triggers
Activate this skill when the user wants to:
- Convert a Prompt Flow flow to Microsoft Agent Framework
- Migrate a
flow.dag.yamlto MAF workflow code - Rebuild a Prompt Flow application using
agent-framework
What to Read When (Progressive Disclosure)
This skill is split across multiple files. Always read this file first. Then read additional files based on what the source flow contains:
| Situation | Required Reading |
| Every conversion task | This file + references/gotchas.md |
| Need to map a specific node type | references/node-mapping.md |
Writing Executor handlers / picking LLM client / setting temperature/max_tokens | references/workflow-context.md |
Source flow has a node with source.type: package | topics/custom-tool-nodes.md |
| Source flow has image / multimodal inputs | topics/multimodal.md + examples/multimodal-chat.md |
Source flow has any node with aggregation: true | topics/evaluation-flows.md + templates/eval_runner.py + examples/evaluation.md |
| Want a complete reference example | examples/linear-chat.md (basic), examples/multimodal-chat.md, examples/evaluation.md |
Don't pre-load everything. Read each file lazily when its situation is detected during Phase 1 audit.
Core Rules (apply to every conversion)
- Read the source flow first — Always parse
flow.dag.yaml, all referenced source files (.jinja2,.py), andrequirements.txtbefore generating anything. - Preserve prompts verbatim — System prompts, user prompt templates, and any text from
.jinja2or inline prompt nodes must be copied exactly as they appear in the original Prompt Flow. Do not rephrase, summarize, add, or remove any content — including examples, instructions, formatting, and preambles (e.g., "Read the following conversation and respond:"). The MAF workflow must send the identical prompt text to the LLM. - One Executor per node — Each Prompt Flow node becomes one
Executorsubclass with a@handlermethod. (Some node combinations may be safely merged — see references/node-mapping.md for "Node Collapsing Patterns".) - Preserve behaviour — The MAF workflow must produce the same outputs for the same inputs as the original flow.
- Use GA packages —
agent-framework>=1.0.1,agent-framework-openai>=1.0.1. Use preview packages (--pre) only for orchestrations, Azure AI Search, or multi-agent features. (Full table in references/workflow-context.md.) - Create output folder — Place generated files in a sibling folder named
<original-folder>-maf/. - Copy user-defined Python packages — If the flow imports from internal packages (e.g.,
my_utils/, helper modules), copy the entire package directory into the output folder. The MAF workflow imports directly from the local copy — nosys.pathmanipulation needed. - Generate a test sample — Always include a runnable
test_<name>.pysample script. - Never modify the original flow — All output goes into the new folder.
- Evaluation flows use the EvalRunner pattern — If any node has
aggregation: true, the flow is an evaluation flow. See topics/evaluation-flows.md. - Always export a
create_workflow()factory — MAF workflows do not support concurrentrun()calls on a single instance (RuntimeError: Workflow is already running). Every generatedworkflow.pymust export acreate_workflow()factory function that creates a fresh workflow instance per call. Do NOT instantiate Executors or build the workflow at module level. This ensures callers can safely run multiple workflows concurrently (e.g., evaluation batches, parallel API requests, or test suites). For evaluation flows,EvalRunnerrelies on this factory to create one workflow per row. Copy ALL referenced resources into the output folder — The generated
-maf/project must be fully self-contained with zero dependencies on the original Prompt Flow folder. Copy every resource file the flow references:- Data files (
.jsonl,.csv,.json,.tsv) used for testing or evaluation - Prompt / template files (
.jinja2,.mdused as prompts) - User-defined Python modules (
.pyfiles or packages imported by nodes — see rule 7) - Any other non-code assets (e.g.,
samples.json, config files, image assets)
Update all file path references (e.g.,
DEFAULT_DATA,_TEMPLATES_DIR,_PROMPT_TEMPLATE) to point to the local copy usingPath(__file__).parent / .... Never useparent.parentor relative paths that reach back into the original flow directory.- Data files (
- Preserve graph topology and conditions exactly — The MAF workflow's graph structure MUST be equivalent to the original
flow.dag.yamlgraph. Specifically:- Node coverage — Every Prompt Flow node must map to exactly one MAF Executor (or be merged via an explicitly allowed Collapsing Pattern; see references/node-mapping.md). No PF node may be silently dropped, and no extra Executors may be invented that don't correspond to a PF node or an allowed merge.
- Edge coverage — Every data reference
${node.output}inflow.dag.yamlmust correspond to a MAF edge (add_edge/add_fan_out_edges/add_fan_in_edges) connecting the equivalent Executors. No edges may be added or removed. - Parallelism preserved — If two PF nodes run in parallel from a shared upstream node, they must remain parallel in MAF (
add_fan_out_edges). Do NOT serialize parallel branches. If multiple PF nodes fan into one downstream node, they must useadd_fan_in_edges. - Conditions preserved — Every
activate_config(when/is) in PF must become anadd_edge(..., condition=fn)with semantically identical predicate logic. The truth value of the condition for any given input must match the original. - No reordering — The execution order implied by the dependency graph must be preserved. Do not move logic from a downstream node into an upstream node (or vice versa) in a way that changes when work happens relative to other branches.
- Mapping table required — In Phase 1, produce an explicit PF-node → MAF-Executor / edge mapping table (see Phase 1 step 6) and verify it in Phase 4 (see Phase 4 step 22). Any allowed merge must be annotated with the matching Collapsing Pattern from references/node-mapping.md.
Conversion Workflow (4 Phases)
Phase 1 — Audit the Prompt Flow
- Read
flow.dag.yaml— identify all inputs, outputs, nodes, their types, and edges (data references like${node.output}).- For every node, record
typeANDsource.type. A node withsource.type: packageis a custom user-defined tool — read topics/custom-tool-nodes.md and call it directly from the Executor; do NOT remap toOpenAIChatClient/Agent.
- For every node, record
- Read source files — open every
.jinja2template, every.pyfile referenced bysource.type: codenodes, and the package source for everysource.type: packagenode. - Read
requirements.txt— note any extra dependencies. - Map the graph — draw the node dependency graph from
${...}references. Identify:- Linear chains (A → B → C)
- Parallel branches (A → B, A → C)
- Conditional branches (
activate_config) - Fan-in / aggregation points
- Detect special cases — load the matching topic file:
- Any node with
aggregation: true→ evaluation flow → load topics/evaluation-flows.md - Any node with
source.type: package→ custom tool → load topics/custom-tool-nodes.md - Any image inputs (dict with
data:image/*;urlkey, or string starting withdata:image/) → multimodal → load topics/multimodal.md
- Any node with
Produce a node-mapping table — Before writing any MAF code, emit (in your reasoning or as a comment block at the top of
workflow.py) an explicit table that lists, for every PF node:- PF node name and
type(+source.type) - The MAF Executor it maps to (or the merged Executor name, with the matching Collapsing Pattern from references/node-mapping.md)
- The incoming edges (PF
${...}references → MAFadd_edge/add_fan_in_edges) - The outgoing edges (PF downstream consumers → MAF
add_edge/add_fan_out_edges) - Any
activate_config→ the MAFcondition=fnit becomes
This table is the contract used to verify graph equivalence in Phase 4. Every PF node must appear; every
${...}reference must appear as an edge.- PF node name and
Phase 2 — Generate MAF Code
- Create output folder —
<original-folder>-maf/. - Copy internal packages — see Rule 7 above.
- Copy all referenced resources — see Rule 12 above.
- Create one Executor per node following the mapping table from Phase 1 step 6 and references/node-mapping.md. Do not invent extra Executors and do not silently merge nodes outside of the explicitly allowed Collapsing Patterns.
- Wire the workflow inside a
create_workflow()factory function usingWorkflowBuilder. The edges you add MUST exactly match the edges listed in the Phase 1 mapping table. Executor instantiation andWorkflowBuilder.build()must happen inside this function — not at module level — so each call returns a fresh, independent workflow instance:.add_edge(source, target)for linear connections.add_edge(source, target, condition=fn)for conditionals (one per PFactivate_config, with semantically identical predicate).add_fan_out_edges(source, [targets])for parallel branches (preserve PF parallelism — never serialize).add_fan_in_edges([sources], target)for aggregation
- Handle LLM nodes:
- Extract system prompt from
.jinja2template →Agent(instructions="...") - Pick the right client — see references/workflow-context.md
Agent.run()returns anAgentResponse— extract text with.text- Preserve LLM parameters — pass
temperature,max_tokens, etc. viaOpenAIChatOptions(see references/workflow-context.md)
- Extract system prompt from
- Handle chat history — format prior turns into a prompt string in an InputExecutor, not as raw message dicts.
- Handle Python tool nodes — convert to plain functions and pass to
Agent(tools=[fn]). - For evaluation flows / multimodal flows / custom-tool nodes — follow the topic file you loaded in Phase 1 step 5.
Phase 3 — Generate Supporting Files
requirements.txt— include only neededagent-framework-*packages. Addazure-identity>=1.15.0if any LLM client uses the identity template..env.example— template with required environment variables (endpoint, model, key only if the connection uses key auth).test_<name>.py— runnable sample script exercising single-turn and multi-turn (if applicable).README.md— brief setup and run instructions. (Other documentation only if the user requests it.)
Phase 4 — Validate
- Create a virtual environment and install dependencies.
- Run the test sample to verify the workflow produces output.
Verify graph topology equivalence against
flow.dag.yaml— re-open the sourceflow.dag.yamland the Phase 1 mapping table, then check:- Every PF node appears in the mapping table and is realized as exactly one MAF Executor (or is part of an explicitly annotated Collapsing Pattern).
- No MAF Executor exists that does not correspond to a PF node or an annotated merge.
- Every PF
${node.output}reference is realized as a MAF edge between the corresponding Executors. - No MAF edges exist that are not present in PF.
- PF parallel branches use
add_fan_out_edges; PF fan-in points useadd_fan_in_edges. No parallel branch has been serialized. - Every PF
activate_confighas a matchingadd_edge(..., condition=fn)whose predicate is semantically identical (same truth value for the same inputs).
If any check fails, fix the workflow before proceeding.
- Fix errors — see references/gotchas.md.
Skill File Index
.github/skills/promptflow-to-maf/
├── SKILL.md ← This file: rules + 4-phase workflow + routing
├── references/
│ ├── node-mapping.md ← Prompt Flow node → MAF mapping table + collapse patterns
│ ├── workflow-context.md ← WorkflowContext types, LLM clients, ChatOptions, packages
│ └── gotchas.md ← Common pitfalls, runtime errors, anti-patterns
├── topics/
│ ├── custom-tool-nodes.md ← Handling source.type: package nodes
│ ├── multimodal.md ← Image/multimodal input handling
│ └── evaluation-flows.md ← aggregation: true + EvalRunner pattern
├── templates/
│ └── eval_runner.py ← Reusable runner — copy verbatim into eval flow output
└── examples/
├── linear-chat.md ← Single LLM node + chat history
├── multimodal-chat.md ← Image inputs (GPT-4V style)
└── evaluation.md ← Per-row workflow + aggregation function + run_eval.pyWhen NOT to use
Do not use this skill for tasks outside its scope.
Example
Converting a simple chat flow from PromptFlow to MAF:
Source flow.dag.yaml:
inputs:
chat_history:
type: list
default: []
question:
type: string
default: "What is MAF?"
outputs:
answer:
type: string
reference: ${llm_node.output}
nodes:
- name: format_chat_history
type: python
source:
type: code
path: format_chat_history.py
inputs:
chat_history: ${inputs.chat_history}
- name: llm_node
type: llm
source:
type: code
path: llm_node.jinja2
inputs:
deployment_name: gpt-4
temperature: 0.7
max_tokens: 500
chat_history: ${format_chat_history.output}
question: ${inputs.question}Source format_chat_history.py:
def format_chat_history(chat_history: list) -> str:
if not chat_history:
return "No prior conversation."
formatted = []
for turn in chat_history:
formatted.append(f"User: {turn.get('user', '')}")
formatted.append(f"Assistant: {turn.get('assistant', '')}")
return "\n".join(formatted)Source llm_node.jinja2:
You are a helpful AI assistant. Answer questions clearly and concisely.
{% if chat_history != "No prior conversation." %}
Previous conversation:
{{ chat_history }}
{% endif %}
User question: {{ question }}Generated MAF workflow.py:
from agent_framework import WorkflowBuilder, Executor, handler
from agent_framework_openai import OpenAIChatClient, OpenAIChatOptions
from pathlib import Path
import os
class FormatChatHistoryExecutor(Executor):
@handler
async def format_chat_history(self, chat_history: list) -> str:
if not chat_history:
return "No prior conversation."
formatted = []
for turn in chat_history:
formatted.append(f"User: {turn.get('user', '')}")
formatted.append(f"Assistant: {turn.get('assistant', '')}")
return "\n".join(formatted)
class LLMNodeExecutor(Executor):
def __init__(self):
self.client = OpenAIChatClient(
api_key=os.environ["OPENAI_API_KEY"],
model="gpt-4"
)
self.prompt_template = self._load_prompt()
def _load_prompt(self) -> str:
prompt_path = Path(__file__).parent / "llm_node.jinja2"
return prompt_path.read_text()
@handler
async def process(self, chat_history: str, question: str) -> str:
from jinja2 import Template
prompt = Template(self.prompt_template).render(
chat_history=chat_history,
question=question
)
response = await self.client.complete(
prompt,
options=OpenAIChatOptions(temperature=0.7, max_tokens=500)
)
return response.text
def create_workflow():
format_history = FormatChatHistoryExecutor()
llm_node = LLMNodeExecutor()
return (
WorkflowBuilder()
.add_edge(format_history, llm_node)
.build()
)Generated test_chat.py:
import asyncio
from workflow import create_workflow
async def main():
workflow = create_workflow()
# Single-turn test
result = await workflow.run(
inputs={
"chat_history": [],
"question": "What is Microsoft Agent Framework?"
}
)
print(f"Answer: {result['answer']}")
# Multi-turn test
history = [
{"user": "What is Python?", "assistant": "Python is a programming language."}
]
result = await workflow.run(
inputs={
"chat_history": history,
"question": "What are its main features?"
}
)
print(f"Follow-up answer: {result['answer']}")
if __name__ == "__main__":
asyncio.run(main())Generated requirements.txt:
agent-framework>=1.0.1
agent-framework-openai>=1.0.1
jinja2>=3.1.0Generated .env.example:
OPENAI_API_KEY=your-api-key-hereDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

