Skip to content

Python: add Magentic custom manager prompts sample - #7876

Open
NekoPunch (orangeCatDeveloper) wants to merge 2 commits into
microsoft:mainfrom
orangeCatDeveloper:python/magentic-custom-prompts-sample
Open

Python: add Magentic custom manager prompts sample#7876
NekoPunch (orangeCatDeveloper) wants to merge 2 commits into
microsoft:mainfrom
orangeCatDeveloper:python/magentic-custom-prompts-sample

Conversation

@orangeCatDeveloper

@orangeCatDeveloper NekoPunch (orangeCatDeveloper) commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

MagenticBuilder accepts an override for each of StandardMagenticManager's seven built-in prompts, but no sample shows it, so users with a required report format have to read _magentic.py to find the knobs and the placeholders available to each prompt.

Description & Review Guide

  • What are the major changes?

    A new sample, python/samples/03-workflows/orchestrations/magentic_custom_prompts.py, runs an incident review board and overrides six of the seven prompts. Two design points:

    The replan prompts are overridden alongside the initial ones because a stall makes the manager rebuild both the fact sheet and the plan — overriding only the initial prompts would silently drop the custom format mid-run.

    progress_ledger_prompt is deliberately left at its default: its response is parsed as JSON, so an override must reproduce the built-in schema. The docstring says so, along with a table of every overridable prompt and its available placeholders. Overrides may omit placeholders they do not need.

  • What is the impact of these changes?

    Samples only, plus one README row.

  • What do you want reviewers to focus on?

    Whether the prompt/placeholder table still matches the StandardMagenticManager contract.

Ruff and targeted Pyright checks are clean.

To exercise the same path a sample user follows, I created a temporary Foundry V2 project in East US 2, deployed gpt-4.1-mini, and authenticated with AzureCliCredential. I then ran:

FOUNDRY_PROJECT_ENDPOINT=<temporary-project-endpoint> \
FOUNDRY_MODEL=<temporary-deployment-name> \
uv run python samples/03-workflows/orchestrations/magentic_custom_prompts.py

The process exited successfully after emitting PLAN_CREATED with the custom INCIDENT REVIEW BRIEF, streaming participant responses, and producing a final report with the requested SUMMARY, FINDINGS, and RECOMMENDATION sections. The temporary deployment, project, and resource group were deleted afterward.

The nightly validate-03-workflows job is currently disabled, so this was a manual end-to-end run.

Related Issue

Fixes #7298

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is breaking, add the breaking change label or put [BREAKING] in the title prefix — a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Python sample demonstrating custom Magentic manager prompts for an incident-review workflow.

Changes:

  • Overrides six planning, replanning, ledger, and final-answer prompts.
  • Streams participant and task-ledger output.
  • Adds the sample to the orchestration README.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/samples/03-workflows/orchestrations/README.md Links the new sample.
python/samples/03-workflows/orchestrations/magentic_custom_prompts.py Implements and documents custom manager prompts.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/samples/03-workflows/orchestrations/magentic_custom_prompts.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Add sample to show magentic prompt overwrite

2 participants