···8181 {!Advanced.send_message} instead. *)
82828383val respond_to_tool :
8484- t -> tool_use_id:string -> content:string -> ?is_error:bool -> unit -> unit
8484+ t -> tool_use_id:string -> content:Jsont.json -> ?is_error:bool -> unit -> unit
8585(** [respond_to_tool t ~tool_use_id ~content ?is_error ()] responds to a tool
8686 use request.
87878888 @param tool_use_id The ID from the {!Response.Tool_use.t} event
8989- @param content The result content (can be any string)
8989+ @param content The result content (can be a string or array of content blocks)
9090 @param is_error Whether this is an error response (default: false) *)
91919292-val respond_to_tools : t -> (string * string * bool option) list -> unit
9292+val respond_to_tools : t -> (string * Jsont.json * bool option) list -> unit
9393(** [respond_to_tools t responses] responds to multiple tool use requests at
9494 once.
95959696- Each tuple is [(tool_use_id, content, is_error option)].
9696+ Each tuple is [(tool_use_id, content, is_error option)] where content
9797+ can be a string or array of content blocks.
97989899 Example:
99100 {[
100101 Client.respond_to_tools client
101102 [
102102- ("tool_use_123", "Success", None);
103103- ("tool_use_456", "Error occurred", Some true);
103103+ ("tool_use_123", Jsont.string "Success", None);
104104+ ("tool_use_456", Jsont.string "Error occurred", Some true);
104105 ]
105106 ]} *)
106107
+4-4
lib/content_block.mli
···6868 val tool_use_id : t -> string
6969 (** [tool_use_id t] returns the ID of the corresponding tool use. *)
70707171- val content : t -> string option
7272- (** [content t] returns the optional result content. *)
7171+ val content : t -> Jsont.json option
7272+ (** [content t] returns the optional result content as raw JSON. *)
73737474 val is_error : t -> bool option
7575 (** [is_error t] returns whether this result represents an error. *)
···125125(** [tool_use ~id ~name ~input] creates a tool use content block. *)
126126127127val tool_result :
128128- tool_use_id:string -> ?content:string -> ?is_error:bool -> unit -> t
128128+ tool_use_id:string -> ?content:Jsont.json -> ?is_error:bool -> unit -> t
129129(** [tool_result ~tool_use_id ?content ?is_error ()] creates a tool result
130130- content block. *)
130130+ content block. Content can be a string or array. *)
131131132132val thinking : thinking:string -> signature:string -> t
133133(** [thinking ~thinking ~signature] creates a thinking content block. *)
+2-2
lib/message.mli
···2626 (** [of_blocks blocks] creates a user message with content blocks. *)
27272828 val with_tool_result :
2929- tool_use_id:string -> content:string -> ?is_error:bool -> unit -> t
2929+ tool_use_id:string -> content:Jsont.json -> ?is_error:bool -> unit -> t
3030 (** [with_tool_result ~tool_use_id ~content ?is_error ()] creates a user
3131- message containing a tool result. *)
3131+ message containing a tool result. Content can be a string or array. *)
32323333 val as_text : t -> string option
3434 (** [as_text t] returns the text content if the message is a simple string,
···7878 Use [Jsont.pp_value jsont ()] for pretty-printing. *)
79798080 val create :
8181- tool_use_id:string -> ?content:string -> ?is_error:bool -> unit -> t
8181+ tool_use_id:string -> ?content:Jsont.json -> ?is_error:bool -> unit -> t
8282 (** [create ~tool_use_id ?content ?is_error ()] creates a new tool result
8383 block.
8484 @param tool_use_id The ID of the corresponding tool use block
8585- @param content Optional result content
8585+ @param content Optional result content (can be string or array of content blocks)
8686 @param is_error Whether the tool execution resulted in an error *)
87878888 val tool_use_id : t -> string
8989 (** [tool_use_id t] returns the ID of the corresponding tool use. *)
90909191- val content : t -> string option
9292- (** [content t] returns the optional result content. *)
9191+ val content : t -> Jsont.json option
9292+ (** [content t] returns the optional result content as raw JSON. *)
93939494 val is_error : t -> bool option
9595 (** [is_error t] returns whether this result represents an error. *)
···148148(** [tool_use ~id ~name ~input] creates a tool use content block. *)
149149150150val tool_result :
151151- tool_use_id:string -> ?content:string -> ?is_error:bool -> unit -> t
151151+ tool_use_id:string -> ?content:Jsont.json -> ?is_error:bool -> unit -> t
152152(** [tool_result ~tool_use_id ?content ?is_error ()] creates a tool result
153153- content block. *)
153153+ content block. Content can be a string or an array of content blocks. *)
154154155155val thinking : thinking:string -> signature:string -> t
156156(** [thinking ~thinking ~signature] creates a thinking content block. *)
+2-2
proto/message.mli
···4242 (** [create_blocks blocks] creates a user message with content blocks. *)
43434444 val create_with_tool_result :
4545- tool_use_id:string -> content:string -> ?is_error:bool -> unit -> t
4545+ tool_use_id:string -> content:Jsont.json -> ?is_error:bool -> unit -> t
4646 (** [create_with_tool_result ~tool_use_id ~content ?is_error ()] creates a
4747- user message containing a tool result. *)
4747+ user message containing a tool result. Content can be a string or array. *)
48484949 val content : t -> content
5050 (** [content t] returns the content of the user message. *)
+6-1
test/simple_permission_test.ml
···6666 if is_error then begin
6767 Log.app (fun m -> m "\n⚠️ Tool result error for %s:" tool_use_id);
6868 match Claude.Content_block.Tool_result.content r with
6969- | Some s -> Log.app (fun m -> m " %s" s)
6969+ | Some json ->
7070+ let s = match Jsont_bytesrw.encode_string' Jsont.json json with
7171+ | Ok str -> str
7272+ | Error _ -> "<encoding error>"
7373+ in
7474+ Log.app (fun m -> m " %s" s)
7075 | None -> ()
7176 end
7277 | Claude.Response.Complete result ->