[GH-ISSUE #119] Bug: Memory injection causes 'tool_use ids must be unique' API error #48

Closed
opened 2026-02-27 10:21:56 +03:00 by kerem · 2 comments
Owner

Originally created by @slavochek2 on GitHub (Jan 26, 2026).
Original GitHub issue: https://github.com/mikeyobrien/ralph-orchestrator/issues/119

Description

When .agent/memories.md exists with valid content, Ralph fails immediately with an API error indicating duplicate tool_use IDs.

Version

  • ralph: 2.2.5 (also reproduced on 2.2.0)
  • Backend: claude

Error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: tool_use ids must be unique"},"request_id":"req_011CXVgkABcDXS5USTcS2t6Q"}

Steps to Reproduce

  1. Have a valid .agent/memories.md file:
# Memories

## Patterns

## Decisions

## Fixes

## Context

### mem-1769091463-aa45
> Some memory content here
<!-- tags: example | created: 2026-01-22 -->
  1. Run ralph:
ralph run --no-tui -p "any prompt here"
  1. Error occurs immediately on first iteration

Logs

INFO ralph_core::event_loop: Memory injection check: enabled=true, inject=Auto
INFO ralph_core::event_loop: Successfully loaded 1 memories from store
INFO ralph_core::event_loop: Injecting 1 memories (478 chars) into prompt
⚙ [Read] /var/folders/.../tmp...

✗ Error: Session ended with error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: tool_use ids must be unique"}}

Workaround

Remove or rename .agent/memories.md:

mv .agent/memories.md .agent/memories.md.disabled

Analysis

The error messages.1.content.1: tool_use ids must be unique suggests that when Ralph constructs the API request with memory injection, it's generating duplicate tool_use block IDs. The issue is in the message construction code path that handles memory injection.

Originally created by @slavochek2 on GitHub (Jan 26, 2026). Original GitHub issue: https://github.com/mikeyobrien/ralph-orchestrator/issues/119 ## Description When `.agent/memories.md` exists with valid content, Ralph fails immediately with an API error indicating duplicate tool_use IDs. ## Version - ralph: 2.2.5 (also reproduced on 2.2.0) - Backend: claude ## Error ``` API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: tool_use ids must be unique"},"request_id":"req_011CXVgkABcDXS5USTcS2t6Q"} ``` ## Steps to Reproduce 1. Have a valid `.agent/memories.md` file: ```markdown # Memories ## Patterns ## Decisions ## Fixes ## Context ### mem-1769091463-aa45 > Some memory content here <!-- tags: example | created: 2026-01-22 --> ``` 2. Run ralph: ```bash ralph run --no-tui -p "any prompt here" ``` 3. Error occurs immediately on first iteration ## Logs ``` INFO ralph_core::event_loop: Memory injection check: enabled=true, inject=Auto INFO ralph_core::event_loop: Successfully loaded 1 memories from store INFO ralph_core::event_loop: Injecting 1 memories (478 chars) into prompt ⚙ [Read] /var/folders/.../tmp... ✗ Error: Session ended with error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: tool_use ids must be unique"}} ``` ## Workaround Remove or rename `.agent/memories.md`: ```bash mv .agent/memories.md .agent/memories.md.disabled ``` ## Analysis The error `messages.1.content.1: tool_use ids must be unique` suggests that when Ralph constructs the API request with memory injection, it's generating duplicate tool_use block IDs. The issue is in the message construction code path that handles memory injection.
kerem closed this issue 2026-02-27 10:21:56 +03:00
Author
Owner

@mikeyobrien commented on GitHub (Jan 26, 2026):

What's your claude version?

<!-- gh-comment-id:3799667339 --> @mikeyobrien commented on GitHub (Jan 26, 2026): What's your claude version?
Author
Owner

@LuoAndOrder commented on GitHub (Jan 27, 2026):

Hey I ran into this. It was an issue with Claude and not with ralph-orchestrator.

Rolling back to 2.1.7 worked. I believe the issue was introduced in Claude 2.1.8

<!-- gh-comment-id:3802414182 --> @LuoAndOrder commented on GitHub (Jan 27, 2026): Hey I ran into this. It was an issue with Claude and not with ralph-orchestrator. Rolling back to 2.1.7 worked. I believe the issue was introduced in Claude 2.1.8
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#48
No description provided.