[bot] OpenAI Responses API `instructions` and string-form `input` not captured in span input
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- java
- Área
- observability
Línea de trabajo
Comienza en braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java, en tagOpenAIRequest(), y luego compara el manejo del campo system de Anthropic alrededor de las líneas 224–232. Revisa las pruebas de Responses API en braintrust-sdk/instrumentation/openai_2_15_0/src/test/java/dev/braintrust/instrumentation/openai/v2_15_0/BraintrustOpenAITest.java y amplía la cobertura para instructions y string input. Se considera terminado cuando ambas formas aparecen en braintrust.input_json.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
The OpenAI Responses API request tagger in InstrumentationSemConv.tagOpenAIRequest() drops two important pieces of input data:
-
instructions(system prompt) silently dropped: The Responses API usesinstructionsas the system-level prompt (equivalent to Chat Completions' system message or Anthropic'ssystemfield). This field is not included inbraintrust.input_json, so the system prompt is invisible when viewing the trace. -
String-form
inputsilently dropped: The Responses API acceptsinputas either a plain string ("Hello!") or an array of input items. The code checksrequestJson.get("input").isArray(), which means plain-string inputs fail the guard andinput_jsonis never set.
For comparison, the Anthropic request tagger in the same file correctly captures the system field as a synthetic {role: "system"} message appended to the input array (lines 224–232).
What is missing
In InstrumentationSemConv.tagOpenAIRequest() (lines 127–138):
if (requestBody != null) {
JsonNode requestJson = BraintrustJsonMapper.get().readTree(requestBody);
if (requestJson.has("model")) {
metadata.put("model", requestJson.get("model").asText());
}
// Chat completions API uses "messages"; Responses API uses "input"
if (requestJson.has("messages")) {
span.setAttribute("braintrust.input_json", toJson(requestJson.get("messages")));
} else if (requestJson.has("input") && requestJson.get("input").isArray()) {
span.setAttribute("braintrust.input_json", toJson(requestJson.get("input")));
}
}
Problem 1: instructions not captured
A typical Responses API request:
{
"model": "gpt-4o-mini",
"instructions": "You are a helpful assistant",
"input": [{"role": "user", "content": "What is 2+2?"}]
}
The input array is captured, but instructions is silently dropped. Users viewing this trace in Braintrust see the user message but not the system instructions that shaped the model's behavior.
The Anthropic handler (tagAnthropicRequest, lines 224–232) solves the equivalent problem by appending a synthetic {role: "system", content: ...} entry:
if (requestJson.has("system") && ...) {
var systemNode = BraintrustJsonMapper.get().createObjectNode();
systemNode.put("role", "system");
systemNode.set("content", requestJson.get("system"));
inputArray.add(systemNode);
}
Problem 2: String-form input dropped
A valid Responses API request:
{
"model": "gpt-4o-mini",
"input": "What is the capital of France?"
}
The requestJson.get("input").isArray() check fails for string inputs, so input_json is never set. The span has no input at all.
The OpenAI Java SDK supports both forms via ResponseCreateParams.builder().inputOfResponse(String) and .inputOfResponse(List<ResponseInputItem>).
Braintrust docs status
- The Braintrust tracing docs at https://www.braintrust.dev/docs/guides/tracing state that LLM spans capture "the model, messages, parameters" — implying system-level instructions should be captured: unclear
- The OpenAI integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/openai do not mention the Responses API
instructionsfield: not_found
Upstream sources
- OpenAI Responses API: https://developers.openai.com/docs/guides/responses-vs-chat-completions — documents
instructionsas the system prompt equivalent andinputaccepting both string and array formats - OpenAI Java SDK:
ResponseCreateParams.builder().instructions(String)and.inputOfResponse(String)/.inputOfResponse(List)are stable API surfaces
Local files inspected
braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java— lines 127–138 (tagOpenAIRequest:instructionsnot extracted, stringinputdropped byisArray()guard); lines 224–232 (tagAnthropicRequest:systemcorrectly captured as synthetic system message for comparison)braintrust-sdk/instrumentation/openai_2_15_0/src/test/java/dev/braintrust/instrumentation/openai/v2_15_0/BraintrustOpenAITest.java— lines 229–253, 275–302 (Responses API tests use.instructions("You are a helpful assistant")butassertValidOpenAISpanonly checksinput_jsonis non-null, not that it contains the instructions)
- Lenguaje dominante
- Java
- Estrellas
- 21
- Forks
- 5
- Merge medio
- 2 d 7 h
- PR fusionados (30 d)
- 8
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de braintrustdata/braintrust-sdk-java
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de braintrustdata/braintrust-sdk-java
Issues similares
-
certification
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Abiertobug ecr
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Needs: Triage Type: Feature request
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
github/copilot-sdk#2760 ·