diff --git a/VERSION b/VERSION index ee6cdce..b616048 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1 +0.6.2 diff --git a/larry.sh b/larry.sh index 5bc9b64..ca5ec07 100755 --- a/larry.sh +++ b/larry.sh @@ -36,7 +36,7 @@ set -o pipefail # ───────────────────────────────────────────────────────────────────────────── # Config # ───────────────────────────────────────────────────────────────────────────── -LARRY_VERSION="0.6.1" +LARRY_VERSION="0.6.2" LARRY_HOME="${LARRY_HOME:-$HOME/.larry}" LARRY_BASE_URL="${LARRY_BASE_URL:-https://raw.githubusercontent.com/bojj27/cloverleaf-larry/main}" LARRY_UPDATE_URL="${LARRY_UPDATE_URL:-${LARRY_BASE_URL}/larry.sh}" @@ -1040,6 +1040,11 @@ build_system_prompt() { # ───────────────────────────────────────────────────────────────────────────── agent_turn() { local system_prompt="$1" + # Write the TOOLS_JSON to a file ONCE per agent_turn rather than passing it + # via --argjson (which puts the full 21KB blob on the jq command line and + # blows up Cygwin/Windows argv limits with E2BIG / "Argument list too long"). + local tools_file; tools_file=$(mktemp) + printf '%s' "$TOOLS_JSON" > "$tools_file" while true; do local payload_file; payload_file=$(mktemp) jq -n \ @@ -1047,18 +1052,19 @@ agent_turn() { --argjson max_tokens "$LARRY_MAX_TOKENS" \ --arg system "$system_prompt" \ --slurpfile messages "$MESSAGES_FILE" \ - --argjson tools "$TOOLS_JSON" \ - '{model:$model, max_tokens:$max_tokens, system:$system, messages:$messages[0], tools:$tools}' \ + --slurpfile tools "$tools_file" \ + '{model:$model, max_tokens:$max_tokens, system:$system, messages:$messages[0], tools:$tools[0]}' \ > "$payload_file" local resp; resp=$(call_api "$payload_file") rm -f "$payload_file" - if [ -z "$resp" ]; then err "empty response from API (timeout or network?)"; return 1; fi + if [ -z "$resp" ]; then err "empty response from API (timeout or network?)"; rm -f "$tools_file"; return 1; fi local err_type; err_type=$(printf '%s' "$resp" | jq -r '.error.type // empty' 2>/dev/null) if [ -n "$err_type" ]; then err "API error: $err_type — $(printf '%s' "$resp" | jq -r '.error.message // "no message"')" + rm -f "$tools_file" return 1 fi @@ -1101,6 +1107,7 @@ agent_turn() { add_user_tool_results "$results" done + rm -f "$tools_file" } # ─────────────────────────────────────────────────────────────────────────────