Send base instructions as Responses input messages (#51156)

## What changed

Move base instructions from the top-level `instructions` field into a prefixed `developer` message in `input` for standard Responses requests, matching Responses Lite. Remove the field from HTTP and WebSocket request types and assign instruction messages stable IDs derived from the thread and instruction text.

## Testing

Extend standard and Responses Lite tests to cover instruction message serialization, stable IDs, and resume consistency. Update WebSocket tests to verify that changed instructions trigger a full request without `previous_response_id`.

GitOrigin-RevId: e2de4b8e30a9339377fac133ceda981abd1a112b
This commit is contained in:
pakrym-oai
2026-10-05 18:52:51 +00:00
committed by copyberry
parent 3f1ccb7ceb
commit c9253c4977
81 changed files with 1330 additions and 943 deletions
+1 -5
View File
@@ -339,7 +339,6 @@ async fn responses_client_stream_request_preserves_item_ids() -> Result<()> {
let client = ResponsesClient::new(transport, provider("openai"), Arc::new(NoAuth));
let request = ResponsesApiRequest {
model: "gpt-test".into(),
instructions: "Say hi".into(),
input: vec![ResponseItem::Message {
id: Some(ResponseItemId::with_suffix("msg", "1")),
role: "user".into(),
@@ -394,7 +393,6 @@ async fn responses_client_stream_request_sends_routing_fields_ahead_of_large_inp
let large_input = "x".repeat(2 * 1024 * 1024);
let request = ResponsesApiRequest {
model: "gpt-test".into(),
instructions: "Say hi".into(),
input: vec![ResponseItem::Message {
id: None,
role: "user".into(),
@@ -434,7 +432,7 @@ async fn responses_client_stream_request_sends_routing_fields_ahead_of_large_inp
);
}
assert!(body.starts_with(
r#"{"model":"gpt-test","stream":true,"service_tier":"priority","instructions":"Say hi","input":[{"type":"message""#
r#"{"model":"gpt-test","stream":true,"service_tier":"priority","input":[{"type":"message""#
));
assert!(body.len() > 2 * 1024 * 1024);
assert_eq!(serde_json::from_str::<serde_json::Value>(body)?, expected);
@@ -491,7 +489,6 @@ async fn streaming_client_retries_on_transport_error() -> Result<()> {
let request = ResponsesApiRequest {
model: "gpt-test".into(),
instructions: "Say hi".into(),
input: Vec::new(),
tools: Some(empty_tools().into()),
tool_choice: "auto".into(),
@@ -606,7 +603,6 @@ async fn azure_store_sends_ids_and_headers() -> Result<()> {
let request = ResponsesApiRequest {
model: "gpt-test".into(),
instructions: "Say hi".into(),
input: vec![ResponseItem::Message {
id: Some(ResponseItemId::with_suffix("msg", "1")),
role: "user".into(),