Skip to content

Reasoning summaries #16

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
simonw opened this issue Apr 16, 2025 · 5 comments
Open

Reasoning summaries #16

simonw opened this issue Apr 16, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Apr 16, 2025

https://platform.openai.com/docs/guides/reasoning#reasoning-summaries

reasoning: {
  effort: "medium", // unchanged
  summary: "auto" // auto gives you the best available summary (detailed > auto > None)
}
@simonw simonw added the enhancement New feature or request label Apr 16, 2025
@simonw
Copy link
Owner Author

simonw commented Apr 16, 2025

I need to verify my account before I can try this out, but the verification flow is currently broken for me for some reason.

@simonw
Copy link
Owner Author

simonw commented Apr 16, 2025

My account is now verified.

@simonw
Copy link
Owner Author

simonw commented Apr 16, 2025

Ooh this is interesting. I got it working in non-streaming mode where the logged JSON included this:

      "object": "response",
      "output": [
        {
          "id": "rs_680042023eb48191a56e9cbf73149de301257c951f8a8d75",
          "summary": [
            {
              "text": "**Explaining the blue sky**\n\nThe user wonders why the sky appears blue. The standard answer involves Rayleigh scattering, which scatters shorter wavelengths of light more than longer ones; thus, blue light is scattered in all directions. This occurs when sunlight interacts with gas molecules in the atmosphere. I also want to note that scattering is dependent on the wavelength, and that during sunset, a different scattering effect can lead to reds and oranges. I\u2019ll keep my explanation concise and clear!",
              "type": "summary_text"
            }
          ],
          "type": "reasoning",
          "status": null
        },
        {
          "id": "msg_680042059ea88191afaf0af9438db68a01257c951f8a8d75",
          "content": [
            {
              "annotations": [],
              "text": {
                "$": "r:01js0g3tr6mzpgpnreaqdsyxcx"
              },
              "type": "output_text"
            }
          ],
          "role": "assistant",
          "status": "completed",
          "type": "message"
        }
      ]

In streaming mode with an extra print() I saw this:

ResponseOutputItemAddedEvent(item=ResponseReasoningItem(id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', summary=[], type='reasoning', status=None), output_index=0, type='response.output_item.added')
ResponseAudioDeltaEvent(delta=None, type='response.reasoning_summary_part.added', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0, part={'type': 'summary_text', 'text': ''})
ResponseAudioDeltaEvent(delta='**Expl', type='response.reasoning_summary_text.delta', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0)
ResponseAudioDeltaEvent(delta='aining', type='response.reasoning_summary_text.delta', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0)
ResponseAudioDeltaEvent(delta=' the', type='response.reasoning_summary_text.delta', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0)
ResponseAudioDeltaEvent(delta=' blue', type='response.reasoning_summary_text.delta', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0)
ResponseAudioDeltaEvent(delta=' sky', type='response.reasoning_summary_text.delta', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0)
...

Then at the end of that a bunch of these:

ResponseAudioDeltaEvent(delta=None, type='response.reasoning_summary_text.done', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0, text="**Explaining the blue sky**\n\nThe user is curious about why the sky is blue, so I'll provide a simple explanation. The blue color comes from Rayleigh scattering, where shorter wavelengths, like blue light, scatter more than longer ones, like red. \n\nDuring sunrise and sunset, the sunlight travels a longer path through the atmosphere, scattering more blue light and allowing red/orange colors to dominate. I’ll note that Mie scattering also contributes to white clouds, as larger particles scatter light differently. I’ll keep it clear and concise!")
ResponseAudioDeltaEvent(delta=None, type='response.reasoning_summary_part.done', item_id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', output_index=0, summary_index=0, part={'type': 'summary_text', 'text': "**Explaining the blue sky**\n\nThe user is curious about why the sky is blue, so I'll provide a simple explanation. The blue color comes from Rayleigh scattering, where shorter wavelengths, like blue light, scatter more than longer ones, like red. \n\nDuring sunrise and sunset, the sunlight travels a longer path through the atmosphere, scattering more blue light and allowing red/orange colors to dominate. I’ll note that Mie scattering also contributes to white clouds, as larger particles scatter light differently. I’ll keep it clear and concise!"})
ResponseOutputItemDoneEvent(item=ResponseReasoningItem(id='rs_68004248aed48191a39be70899b2985704532ffe363465ba', summary=[Summary(text="**Explaining the blue sky**\n\nThe user is curious about why the sky is blue, so I'll provide a simple explanation. The blue color comes from Rayleigh scattering, where shorter wavelengths, like blue light, scatter more than longer ones, like red. \n\nDuring sunrise and sunset, the sunlight travels a longer path through the atmosphere, scattering more blue light and allowing red/orange colors to dominate. I’ll note that Mie scattering also contributes to white clouds, as larger particles scatter light differently. I’ll keep it clear and concise!", type='summary_text')], type='reasoning', status=None), output_index=0, type='response.output_item.done')

The use of ResponseAudioDeltaEvent looks to me like a bug.

@simonw
Copy link
Owner Author

simonw commented Apr 16, 2025

Using curl instead:

curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $(llm keys get openai)" \
  -d '{
    "model": "o3",
    "input": "why is the sky blue?",
    "reasoning": {"summary": "auto"},
    "stream": true
  }'

Output (truncated in the middle):

event: response.created
data: {"type":"response.created","response":{"id":"resp_6800431ff58881919d38df70bdd5be050e9a94ce520f0206","object":"response","created_at":1744847647,"status":"in_progress","error":null,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"model":"o3-2025-04-16","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":"medium","summary":"detailed"},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}

event: response.in_progress
data: {"type":"response.in_progress","response":{"id":"resp_6800431ff58881919d38df70bdd5be050e9a94ce520f0206","object":"response","created_at":1744847647,"status":"in_progress","error":null,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"model":"o3-2025-04-16","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":"medium","summary":"detailed"},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}

event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","type":"reasoning","summary":[]}}

event: response.reasoning_summary_part.added
data: {"type":"response.reasoning_summary_part.added","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"part":{"type":"summary_text","text":""}}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"delta":"**Expl"}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"delta":"aining"}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"delta":" why"}
...
event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"delta":"!"}

event: response.reasoning_summary_text.done
data: {"type":"response.reasoning_summary_text.done","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"text":"**Explaining why the sky is blue**\n\nThe user wants to know why the sky is blue, so I'll provide a straightforward explanation. It comes down to Rayleigh scattering. Sunlight interacts with the Earth's atmosphere, causing gas molecules to scatter shorter wavelengths, like blue and violet, more strongly. However, our eyes are less sensitive to violet light. I'll also mention that the sky looks different at different times, such as when the sun is overhead compared to sunrise or sunset. Let's finalize this answer!"}

event: response.reasoning_summary_part.done
data: {"type":"response.reasoning_summary_part.done","item_id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","output_index":0,"summary_index":0,"part":{"type":"summary_text","text":"**Explaining why the sky is blue**\n\nThe user wants to know why the sky is blue, so I'll provide a straightforward explanation. It comes down to Rayleigh scattering. Sunlight interacts with the Earth's atmosphere, causing gas molecules to scatter shorter wavelengths, like blue and violet, more strongly. However, our eyes are less sensitive to violet light. I'll also mention that the sky looks different at different times, such as when the sun is overhead compared to sunrise or sunset. Let's finalize this answer!"}}

event: response.output_item.done
data: {"type":"response.output_item.done","output_index":0,"item":{"id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","type":"reasoning","summary":[{"type":"summary_text","text":"**Explaining why the sky is blue**\n\nThe user wants to know why the sky is blue, so I'll provide a straightforward explanation. It comes down to Rayleigh scattering. Sunlight interacts with the Earth's atmosphere, causing gas molecules to scatter shorter wavelengths, like blue and violet, more strongly. However, our eyes are less sensitive to violet light. I'll also mention that the sky looks different at different times, such as when the sun is overhead compared to sunrise or sunset. Let's finalize this answer!"}]}}

event: response.output_item.added
data: {"type":"response.output_item.added","output_index":1,"item":{"id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","type":"message","status":"in_progress","content":[],"role":"assistant"}}

event: response.content_part.added
data: {"type":"response.content_part.added","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"part":{"type":"output_text","annotations":[],"text":""}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"delta":"The"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"delta":" sky"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"delta":" looks"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"delta":" blue"}
...
event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"delta":"."}

event: response.output_text.done
data: {"type":"response.output_text.done","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"text":"The sky looks blue because of the way sunlight interacts with the gases in Earth’s atmosphere.\n\n1. Sunlight is a mix of all visible colors.\n2. When this white light hits air molecules, the shorter‑wavelength colors (violet and blue) are scattered about 10 × more efficiently than the longer wavelengths (red, orange) in a process called Rayleigh scattering.\n3. Although violet is scattered even more than blue, our eyes are less sensitive to violet and much of it is absorbed by the upper atmosphere. The scattered light that dominates our vision is therefore blue.\n4. At sunrise and sunset the sunlight travels through a thicker slice of atmosphere, so most of the blue light has already been scattered away, leaving the longer‑wavelength reds and oranges to reach your eyes—hence colorful sunsets.\n\nSo, the preferential scattering of short‑wavelength light by air molecules makes the sky appear blue most of the day."}

event: response.content_part.done
data: {"type":"response.content_part.done","item_id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","output_index":1,"content_index":0,"part":{"type":"output_text","annotations":[],"text":"The sky looks blue because of the way sunlight interacts with the gases in Earth’s atmosphere.\n\n1. Sunlight is a mix of all visible colors.\n2. When this white light hits air molecules, the shorter‑wavelength colors (violet and blue) are scattered about 10 × more efficiently than the longer wavelengths (red, orange) in a process called Rayleigh scattering.\n3. Although violet is scattered even more than blue, our eyes are less sensitive to violet and much of it is absorbed by the upper atmosphere. The scattered light that dominates our vision is therefore blue.\n4. At sunrise and sunset the sunlight travels through a thicker slice of atmosphere, so most of the blue light has already been scattered away, leaving the longer‑wavelength reds and oranges to reach your eyes—hence colorful sunsets.\n\nSo, the preferential scattering of short‑wavelength light by air molecules makes the sky appear blue most of the day."}}

event: response.output_item.done
data: {"type":"response.output_item.done","output_index":1,"item":{"id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"The sky looks blue because of the way sunlight interacts with the gases in Earth’s atmosphere.\n\n1. Sunlight is a mix of all visible colors.\n2. When this white light hits air molecules, the shorter‑wavelength colors (violet and blue) are scattered about 10 × more efficiently than the longer wavelengths (red, orange) in a process called Rayleigh scattering.\n3. Although violet is scattered even more than blue, our eyes are less sensitive to violet and much of it is absorbed by the upper atmosphere. The scattered light that dominates our vision is therefore blue.\n4. At sunrise and sunset the sunlight travels through a thicker slice of atmosphere, so most of the blue light has already been scattered away, leaving the longer‑wavelength reds and oranges to reach your eyes—hence colorful sunsets.\n\nSo, the preferential scattering of short‑wavelength light by air molecules makes the sky appear blue most of the day."}],"role":"assistant"}}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_6800431ff58881919d38df70bdd5be050e9a94ce520f0206","object":"response","created_at":1744847647,"status":"completed","error":null,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"model":"o3-2025-04-16","output":[{"id":"rs_68004320496081918e1e75ddb550d56e0e9a94ce520f0206","type":"reasoning","summary":[{"type":"summary_text","text":"**Explaining why the sky is blue**\n\nThe user wants to know why the sky is blue, so I'll provide a straightforward explanation. It comes down to Rayleigh scattering. Sunlight interacts with the Earth's atmosphere, causing gas molecules to scatter shorter wavelengths, like blue and violet, more strongly. However, our eyes are less sensitive to violet light. I'll also mention that the sky looks different at different times, such as when the sun is overhead compared to sunrise or sunset. Let's finalize this answer!"}]},{"id":"msg_6800432302c8819187223e796def7b7c0e9a94ce520f0206","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"The sky looks blue because of the way sunlight interacts with the gases in Earth’s atmosphere.\n\n1. Sunlight is a mix of all visible colors.\n2. When this white light hits air molecules, the shorter‑wavelength colors (violet and blue) are scattered about 10 × more efficiently than the longer wavelengths (red, orange) in a process called Rayleigh scattering.\n3. Although violet is scattered even more than blue, our eyes are less sensitive to violet and much of it is absorbed by the upper atmosphere. The scattered light that dominates our vision is therefore blue.\n4. At sunrise and sunset the sunlight travels through a thicker slice of atmosphere, so most of the blue light has already been scattered away, leaving the longer‑wavelength reds and oranges to reach your eyes—hence colorful sunsets.\n\nSo, the preferential scattering of short‑wavelength light by air molecules makes the sky appear blue most of the day."}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":"medium","summary":"detailed"},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":12,"input_tokens_details":{"cached_tokens":0},"output_tokens":259,"output_tokens_details":{"reasoning_tokens":64},"total_tokens":271},"user":null,"metadata":{}}}

@simonw
Copy link
Owner Author

simonw commented Apr 17, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant