Skip to content

Azure OpenAI rejects system prompt from prompt_with_handoff_instructions #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LatVAlY opened this issue Jun 3, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@LatVAlY
Copy link

LatVAlY commented Jun 3, 2025

Describe the bug

When using prompt_with_handoff_instructions with the Azure OpenAI endpoint, the prompt is being flagged by Azure’s content filtering policy with a jailbreak detection error.

The error message returned is:

Error code: 400 - {'error': {'message': "The response was filtered due to the prompt triggering Azure OpenAI's content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766", 'code': 'content_filter', 'innererror': {'code': 'ResponsibleAIPolicyViolation', 'content_filter_result': {'jailbreak': {'detected': True, 'filtered': True}}}}}

However, if I bypass prompt_with_handoff_instructions and pass a custom prompt directly, everything works as expected.


Debug information

  • Agents SDK version: v0.0.16
  • Python version: 3.11
  • Model: gpt-4o
  • Endpoint: Azure OpenAI

Repro steps

agent= Agent[AgentContext](
            name="Orchestrator",
            instructions=f"""{prompt_with_handoff_instructions(orchestrator_prompt_default)}"""
)
result = await Runner.run(
                agent,
                input=input_messages,
                context=context,
                run_config=RunConfig(model_settings=ModelSettings(temperature=0.2)),
                model=OpenAIChatCompletionsModel(
                   model=self.model_name, openai_client=self.openai_client
               ),
            )

print(result.final_output)

This throws a 400 error with a content_filter violation due to the moderation system flagging the system context injected by prompt_with_handoff_instructions.

When using a plain prompt (e.g., just "Hello, what can you do?"), the request succeeds.
Also tried the same prompt on the Azure AI studio, and worked as expected

Expected behavior

prompt_with_handoff_instructions should not trigger moderation filters—especially with default or recommended content. Ideally, the system prompt it generates should be safe to use even on stricter platforms like Azure OpenAI.

@LatVAlY LatVAlY added the bug Something isn't working label Jun 3, 2025
@rm-openai
Copy link
Collaborator

@jhills20 any ideas here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants