Feature Request: decode `Response.StreamPart` without toolkit provided
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- api, backend-api-design
Línea de trabajo
Start by reading ai/Response.ts, especially ToolCallPart(), and compare its required toolkit and literal tool-name schema with the dynamic-tool model in ai/Tool.ts. The work is complete when encoded stream parts can be decoded without a toolkit, accepting dynamically named tools and JSON parameters while preserving the existing strict path.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What is the problem this feature would solve?
I wrote a transform function that converts ACP (agent client protocol) SessionUpdate stream into Response.StreamPartEncoded stream, and then sends it to the frontend via SSE for UI display.
However, I ran into trouble when I needed to decode the data into Response.StreamPart, because the toolkit parameter is mandatory.
The ACP protocol does not report the tools the agent uses, nor the corresponding input/output schemas.
In fact, in the ACP stream, tool names and input/output data appear dynamically and no dedicated schema is ever provided, which makes it impossible to define a toolkit.
On the other hand, I don't actually need a strict schema to decode the inputs and outputs of these tools, because for UI display I only need to treat them as ordinary JSON objects.
I noticed that Tool.dynamic is provided in ai/Tool.ts to represent scenarios where the schema is determined at runtime.
But this design cannot solve the case where even the tool name is unknown, because in ai/Response.ts the Schema generated by ToolCallPart() is:
Schema.Struct({
name: Schema.Literal(name),
params: someParametersSchema,
});
This means it will always reject dynamic tool names.
What is the feature you are proposing to solve the problem?
Specifically, this problem shows up when the toolset of an AI system that uses the current effect ai message model cannot be predetermined. This can happen in cases such as:
- Merely using the effect ai message model as an intermediate layer for external message models, as in the case I described above;
- Currently effect only ships providers for OpenAI, Anthropic, and OpenRouter; if more providers are supported in the future, the situation where the toolset cannot be predetermined will become more common;
- Tools are not defined on the client, but are implicitly provided to the AI system, such as server-side executed tools like the OpenAI Response
computer-use;
For these cases, I think a loose Schema that does not require a specific toolkit would be very convenient and also acceptable in terms of real usage:
// tool call part schema that will accept any tool
const AnyToolCallPart = Schema.Struct({
name: Schema.String,
params: Schema.Json,
});
What alternatives have you considered?
Build toolkit on the fly
I came up with a hacky way to read the tool name of the encoded tool-call part, and then build a toolkit on the fly with a dynamic tool definition. Can work but not ideal:
const toolkitFor = (name: string): Toolkit.Any =>
Toolkit.make(
Tool.make(name, {
parameters: Schema.Unknown,
success: Schema.Unknown,
failure: Schema.Unknown,
}),
);
ai SDK
The AI SDK also keeps a strict schema-based path for registered tools, but keeps an escape hatch for tools that were not registered. It falls back to a bare JSON parse with no validation.
// ...
} catch (error) {
const parsedInput = await safeParseJSON({ text: toolCall.input }); // just json parse, no schema validation
return { type: 'tool-call', toolCallId, toolName, input, dynamic: true, invalid: true, error };
}
AI SDK community provider: acp-ai-provider
The tool-call emitted in the stream of acp-ai-provider never uses the agent's real tool name; instead it uniformly uses a placeholder Provider tool:
import { tool, jsonSchema } from "ai";
export const ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME = "acp.acp_provider_agent_dynamic_tool";
export function getACPDynamicTool() {
return {
[ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME]: tool({
type: "provider",
id: ACP_PROVIDER_AGENT_DYNAMIC_TOOL_NAME,
args: {},
inputSchema: jsonSchema({}),
}),
};
}
The real information is packed into a wrapper object:
import { z } from "zod";
export type ProviderAgentDynamicToolInput = {
toolCallId: string;
toolName: string;
args: Record<string, unknown>;
};
export const providerAgentDynamicToolSchema = z.object({
toolCallId: z.string(),
toolName: z.string(),
args: z.record(z.unknown()),
});
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 10 h 33 min
- PR fusionados (30 d)
- 830
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
-
RpcTest.makeClient: accept disableFatalDefectsPosiblemente ocupada @effect-bot la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Effect-TS/effect#9893 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
`HttpApiSchema.Upgrade`: allow a regular success for servers that don't upgradePosiblemente ocupada @effect-bot la tomó hoy. Abiertodocker-made-me-do-it enhancement
Effect-TS/effect#9912 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
docker-made-me-do-it enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
Los mantenedores suelen responder en 1 día
-
`HttpApiSchema`: stream bodies in a custom framingPosiblemente ocupada @effect-bot la tomó hoy. Abiertodocker-made-me-do-it enhancement
Effect-TS/effect#9910 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`HttpApiSchema` streams: declare every media type a stream can be sent asPosiblemente ocupada @effect-bot la tomó hoy. Abiertodocker-made-me-do-it enhancement
Effect-TS/effect#9909 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
freshness freshness:observed-only
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
area: web
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
expressjs/expressjs.com#2549 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bug good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
codercops/discord-bot#101 · 1 comentario ·
Los mantenedores suelen responder en 1 día