Skip to content

Conversation

@sergiobayona
Copy link

…uity

Tool messages were saved but not restored, causing context loss and redundant tool calls across conversation turns.

  • Add :tool role support to restore_conversation_history
  • Extract helper methods to reduce complexity
  • Enhance MessageExtractor for Hash/Array tool_calls compatibility
  • Add 7 test cases
  • Fully backwards compatible

Fixes critical bug affecting tool-based multi-turn conversations

…uity

Tool messages were saved but not restored, causing context loss and
redundant tool calls across conversation turns.

- Add :tool role support to restore_conversation_history
- Extract helper methods to reduce complexity
- Enhance MessageExtractor for Hash/Array tool_calls compatibility
- Add 7 test cases
- Fully backwards compatible

Fixes critical bug affecting tool-based multi-turn conversations
@netlify
Copy link

netlify bot commented Nov 5, 2025

Deploy Preview for ruby-ai-agents canceled.

Name Link
🔨 Latest commit 93f2cd9
🔍 Latest deploy log https://app.netlify.com/projects/ruby-ai-agents/deploys/691f83caf1e9470008a5b035

@scmmishra
Copy link
Member

Hey, thanks for this. I'll review it get it merged soon.

@scmmishra
Copy link
Member

Fixes: #38

@sergiobayona sergiobayona marked this pull request as draft November 6, 2025 15:11
@scmmishra
Copy link
Member

@codex please review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sergiobayona sergiobayona marked this pull request as ready for review November 18, 2025 16:29
…dation errors

The runner previously intentionally omitted `tool_calls` when restoring conversation history, restoring only the tool results[cite: 688].

However, this behavior violates the API contracts of major providers like OpenAI and Anthropic. These APIs require that any message with a `tool` role be immediately preceded by an `assistant` message containing the corresponding `tool_calls` and matching IDs. Failing to provide this structure results in 400 Bad Request errors when resuming conversations that involve tool usage.
@sergiobayona sergiobayona force-pushed the Fix-Tool-Message-Restoration-Bug branch from cbba6db to e54a275 Compare November 19, 2025 14:44
@sergiobayona sergiobayona force-pushed the Fix-Tool-Message-Restoration-Bug branch from 596f49f to 0c62d47 Compare November 19, 2025 22:50
@sergiobayona
Copy link
Author

@codex please review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants