Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Oct 7, 2025

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@effect/ai@0.31.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

@effect/ai-amazon-bedrock@0.11.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

Patch Changes

  • Updated dependencies [4c3bdfb]:
    • @effect/ai-anthropic@0.21.0
    • @effect/ai@0.31.0

@effect/ai-anthropic@0.21.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

Patch Changes

  • Updated dependencies [4c3bdfb]:
    • @effect/ai@0.31.0

@effect/ai-google@0.10.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

Patch Changes

  • Updated dependencies [4c3bdfb]:
    • @effect/ai@0.31.0

@effect/ai-openai@0.34.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

Patch Changes

  • Updated dependencies [4c3bdfb]:
    • @effect/ai@0.31.0

@effect/ai-openrouter@0.5.0

Minor Changes

  • #5621 4c3bdfb Thanks @IMax153! - Remove Either / EitherEncoded from tool call results.

    Specifically, the encoding of tool call results as an Either / EitherEncoded has been removed and is replaced by encoding the tool call success / failure directly into the result property.

    To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an isFailure property has also been added to the "tool-result" part. If isFailure is true, then the tool call handler result was an error.

    import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
    import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
    import * as LanguageModel from "@effect/ai/LanguageModel"
    import * as Tool from "@effect/ai/Tool"
    import * as Toolkit from "@effect/ai/Toolkit"
    import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
    import { Config, Effect, Layer, Schema, Stream } from "effect"
    
    const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
    
    const MyTool = Tool.make("MyTool", {
      description: "An example of a tool with success and failure types",
      failureMode: "return", // Return errors in the response
      parameters: { bar: Schema.Number },
      success: Schema.Number,
      failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
    })
    
    const MyToolkit = Toolkit.make(MyTool)
    
    const MyToolkitLayer = MyToolkit.toLayer({
      MyTool: () => Effect.succeed(42)
    })
    
    const program = LanguageModel.streamText({
      prompt: "Tell me about the meaning of life",
      toolkit: MyToolkit
    }).pipe(
      Stream.runForEach((part) => {
        if (part.type === "tool-result" && part.name === "MyTool") {
          // The `isFailure` property can be used to discriminate whether the result
          // of a tool call is a success or a failure
          if (part.isFailure) {
            part.result
            //   ^? { readonly reason: "reason-1" | "reason-2"; }
          } else {
            part.result
            //   ^? number
          }
        }
        return Effect.void
      }),
      Effect.provide(Claude)
    )
    
    const Anthropic = AnthropicClient.layerConfig({
      apiKey: Config.redacted("ANTHROPIC_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)

Patch Changes

  • Updated dependencies [4c3bdfb]:
    • @effect/ai@0.31.0

@github-actions github-actions bot requested a review from IMax153 as a code owner October 7, 2025 18:27
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Oct 7, 2025
@github-actions github-actions bot force-pushed the changeset-release/main branch from 800b2f3 to 52b86c6 Compare October 8, 2025 00:56
@IMax153 IMax153 merged commit b448792 into main Oct 8, 2025
@IMax153 IMax153 deleted the changeset-release/main branch October 8, 2025 02:17
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants