Share via

GPT-4.1 (2024-12-01-preview) regression — Python code output lost all formatting (newlines/indentation collapsed to single line)

baris erol 15 Reputation points
2026-02-12T15:31:34.7233333+00:00

We operate a multi-agent system in production that uses GPT-4.1 with API version 2024-12-01-preview. One of our agents generates Python code inside <python_code> XML tags. This has been working reliably for weeks — the model consistently returned properly indented, multi-line Python code.

Starting approximately the week of February 9, 2026, with no changes on our side (no prompt changes, no code changes, no API version change), the same agent began returning all Python code collapsed into a single line — no newlines, no indentation. The code is logically correct but structurally unusable in our execution environment.

Before (properly formatted):

# Step 1: Filter data
prod_shifts = df_schedule[df_schedule['IS_ACTIVE'] == 'Y'][['DATE', 'SHIFT']]

if df_filtered.empty:
    print("No data")
    df_final = pd.DataFrame()
else:
    results = run_analysis(df_filtered, config_map, max_results=3)

After (single line — broken):

# Step 1: Filter data prod_shifts = df_schedule[df_schedule['IS_ACTIVE'] == 'Y'][['DATE', 'SHIFT']] if df_filtered.empty: print("No data") df_final = pd.DataFrame() else: results = run_analysis(df_filtered, config_map, max_results=3)

Is there a known fix or workaround that does not require us to modify our prompts or add post-processing? Our prompt engineering is mature and stable — we should not need to compensate for a model-side regression

Azure OpenAI Service
Azure OpenAI Service

An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.

{count} votes

1 answer

Sort by: Most helpful
  1. Anshika Varshney 7,970 Reputation points Microsoft External Staff Moderator
    2026-02-12T21:24:39.9966667+00:00

    Hi baris erol,

    Thanks for reporting this. The behavior you’re seeing (Python code losing newlines and indentation and being returned as a single line) has been identified as a service-side regression affecting GPT‑4.1 (2024‑12‑01‑preview). This issue is being tracked under INC 747008667.

    Root cause

    Engineering confirmed that a backend formatting regression caused newline and indentation tokens to be dropped in model output. This was not related to any prompt changes, client-side logic, or API version changes on customer workloads.

    Resolution

    The issue has been mitigated service-side. The fix restores proper handling of newline and indentation tokens in model responses.

    Action required

    No changes are required from your side. Existing deployments will automatically reflect the fix as the rollout completes.

    If you continue to see the issue, please share the deployment name and region so we can investigate further. We’ll be glad to provide further clarification or guidance.


    If this answers your query, please do click Accept Answer and Yes for was this answer helpful.

    Thank you!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.