Skip to content

[BUG] AzureOpenAI content filterΒ #1139

@Anderzz

Description

@Anderzz

Describe the bug
After upgrading to smolagents 1.13, Azure's content filter is blocking my requests.
This ONLY happens when planning_interval != 0 (ie. is enabled). If planning_interval is not set, everyting works just fine.
It usually complains about "self_harm"

Code to reproduce the error

import os
from smolagents import CodeAgent, AzureOpenAIServerModel

model = AzureOpenAIServerModel(
    model_id = "gpt-4o",
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
)
agent = CodeAgent(
    tools=[],
    model=model,
    planning_interval=2,
)
agent.run("what is e**3?")

Error logs (if any)
Error in generating model output: 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", 'type': None, 'param': 'prompt', 'code': 'content_filter', 'status': 400, 'innererror': {'code': 'ResponsibleAIPolicyViolation', 'content_filter_result': {'hate': {'filtered': False, 'severity': 'safe'}, 'jailbreak': {'filtered': False, 'detected': False}, 'self_harm': {'filtered': True, 'severity': 'high'}, 'sexual': {'filtered': False, 'severity': 'safe'}, 'violence': {'filtered': False, 'severity': 'medium'}}}}}

Expected behavior
I expected the agent to run normally after upgrading versions, both with and without planning.

Packages version:
smolagents==1.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions