#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/../../../.." source scripts/lib.sh MODEL="${MODEL:-claude-haiku-4-5-20251001}" # Custom client tool, forced with tool_choice {type: tool}, then the tool_result round trip. # STATUS: LIVE_VERIFIED 2026-09-18 (identical requests a1_forced_tool + a2_tool_result_final, claude-haiku-4-5-20251001, ~$0.002). TOOLS='[{"name":"get_weather","description":"Get the current weather for a city. Returns a short text description.","input_schema":{"type":"object","properties":{"location":{"type":"string","description":"City name, e.g. Paris"}},"required":["location"]}}]' R1=$(ant POST /v1/messages -d "$(jq -n --argjson t "$TOOLS" --arg m "$MODEL" '{model:$m,max_tokens:200,tools:$t,tool_choice:{type:"tool",name:"get_weather"},messages:[{role:"user",content:"Weather in Paris?"}]}')") log_request anthropic POST /v1/messages "$ANT_STATUS" 0.001 "custom-tools/basic.sh step1 forced tool_choice" echo "$R1" | jq -c '.stop_reason, (.content[]|select(.type=="tool_use"))' TU_ID=$(echo "$R1" | jq -r '.content[]|select(.type=="tool_use")|.id') R2=$(ant POST /v1/messages -d "$(jq -n --argjson t "$TOOLS" --arg m "$MODEL" --argjson a "$(echo "$R1"|jq '.content')" --arg id "$TU_ID" '{model:$m,max_tokens:60,tools:$t,messages:[{role:"user",content:"Weather in Paris?"},{role:"assistant",content:$a},{role:"user",content:[{type:"tool_result",tool_use_id:$id,content:"18 C, light rain"}]}]}')") log_request anthropic POST /v1/messages "$ANT_STATUS" 0.001 "custom-tools/basic.sh step2 tool_result" echo "$R2" | jq -c '.stop_reason, .content'