Tool Message Flattening Adapter (src/nearai_tool_message_flattening.rs)

ClawProBench · ironclaw/crates/ironclaw_llm/src/nearai_tool_message_flattening.rs · rust · Apache-2.0
ai, voice, lang:rust, tag:knn-classified, tag:adapter

Rewrites tool-call and tool-result messages into neutral transcript text for legacy LLM endpoints. Use for LLM provider compatibility.

// Source: https://github.com/suyoumo/ClawProBench | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use ironclaw_common::provider_transcript::format_tool_result_observation;

use super::{ChatCompletionMessage, MessageContent};

/// Rewrite tool-call / tool-result messages into neutral transcript text.
///
/// This is a legacy compatibility adapter for OpenAI-compatible endpoints
/// that reject the standard multi-turn tool-calling protocol (`role: "tool"`
/// messages). It keeps assistant prose but drops assistant tool-call protocol
/// events so the model does not learn an assistant-authored tool-event
/// completion pattern. Tool results become user-side observations.
pub(super) 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key