Skip to content

SWF(bug): preserve Anthropic tool result order - #79

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795398597-anthropic-tool-result-order
Nov 23, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795398597-anthropic-tool-result-order

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Anthropic user turns now lower text/image segments and tool_result blocks in wire order. A turn containing [tool_result, text] now emits Assistant → Tool → User instead of Assistant → User → Tool.

Root cause: the lowering path accumulated user text/images and tool results separately, then always emitted the aggregated User message before the Tool messages, discarding their relative order.

Test plan

  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark tool_result_then_follow_up_text_splits_into_tool_then_user
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark anthropic::tests — 47 passed.
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark — 3261 passed, 0 failed, 14 ignored.
  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests --all-features -- -Dwarnings
  • bash scripts/check-license-headers.sh
  • typos
  • Tested against a real model / hardware: not run. This is a CPU-only request-lowering fix; GPU hosts are reserved.

Try it:

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark tool_result_then_follow_up_text_splits_into_tool_then_user

Notes for reviewers

Assistant block lowering remains aggregated as before. User blocks now flush pending text/images before each tool_result, so [text, tool_result] keeps the existing User → Tool order while [tool_result, text] becomes Tool → User. Tool-result images and is_error handling are preserved.

Rebased onto main after #80 landed; the only conflict was the adjacent doc-comment bullets, resolved by keeping #80's closed-role wording and this PR's wire-order wording.

Untested: live model/GPU behavior and non-Anthropic request surfaces.

CLA


Software Factory opened this PR for Robert
Implemented in session Order Anthropic tool results before follow-up text
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1795398597-anthropic-tool-result-order branch from 2cfd225 to fe11ff3 Compare November 23, 2026 02:27
@maplepaladin73
maplepaladin73 merged commit fae586b into main Nov 23, 2026
1 check passed
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.

1 participant