ai-amazon-bedrock: a tool result that isn't a JSON object fails the next request
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- backend-api-design
Línea de trabajo
Empieza leyendo AmazonBedrockLanguageModel.ts y la función toolResultContent identificada en el issue. Comprueba si ya existen pruebas para los resultados de herramientas de Bedrock y compara cómo gestiona @effect/ai-anthropic los resultados que no son cadenas. El trabajo estará terminado cuando se puedan enviar resultados de herramientas de tipo array y primitivo en una solicitud posterior a Bedrock sin el error de validación indicado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
When a tool's result is an array (or a number, boolean or null), the next request to Bedrock fails:
AiError: AmazonBedrockClient.converseStream: Invalid request. ValidationException: The format of the value at messages.6.content.1.toolResult.content.0.json is invalid. Provide a json object for the field and try again.
The result stays in the conversation's history, so every later request in that conversation fails the same way.
Reproduction
import { Effect, Schema } from "effect"
import { LanguageModel, Tool, Toolkit } from "effect/ai"
const Search = Tool.make("search", {
parameters: Schema.Struct({ query: Schema.String }),
success: Schema.Array(Schema.String)
})
const Tools = Toolkit.make(Search)
const ToolsLive = Tools.toLayer({ search: () => Effect.succeed([]) })
// With AmazonBedrockLanguageModel (Claude via Converse): the model calls `search`,
// and the request that sends its result back fails with the ValidationException above.
Cause
toolResultContent in AmazonBedrockLanguageModel.ts sends every non-string result as json:
const toolResultContent = (result: unknown) => {
if (typeof result === "string") return [{ text: result }]
if (Predicate.isUndefined(result)) return [{ text: "" }]
return [{ json: result }]
}
Converse only accepts a JSON object in ToolResultContentBlock.json. Tool allows any success schema, and @effect/ai-anthropic already handles this by stringifying non-string results.
Suggested fix
Send only objects as json and stringify everything else:
const toolResultContent = (result: unknown) => {
if (Predicate.isString(result)) return [{ text: result }]
if (Predicate.isUndefined(result)) return [{ text: "" }]
if (Predicate.isObject(result)) return [{ json: result }]
return [{ text: JSON.stringify(result) }]
}
Version: @effect/ai-amazon-bedrock 4.1.4.
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 20 h 31 min
- PR fusionados (30 d)
- 733
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 Effect-TS/effect
-
HttpApiEndpoint: static path and wildcard (/*) path with the same prefix are treated as duplicate routesPosiblemente ocupada @effect-bot la tomó hoy. Abiertobug
Effect-TS/effect#10765 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 10/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Investigate Deno CI timeouts in JSDoc diagnostic testsPosiblemente ocupada @haranishi la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
`HttpClient.withRateLimiter`: let `RateLimiterError` be handled as an `HttpClientError`Posiblemente ocupada @effect-bot la tomó hace 2 días. Abiertoenhancement
Effect-TS/effect#10697 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
db-ux-design-system/core-web#8856 ·
Los mantenedores suelen responder en 1 día
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footerPosiblemente ocupada @wittdennis la tomó hoy. Abiertopriority: p3 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
googleapis/release-please#2971 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
🛠️ dette technique
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
betagouv/mon-entreprise#4752 · 1 comentario ·
Los mantenedores suelen responder en 5 días