Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
tool_result_classify.h File Reference

Byte-level classifiers for tool-result content (#44, v2.1.0). More...

#include <entropic/entropic_export.h>
#include <string>
#include <string_view>
Include dependency graph for tool_result_classify.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Functions

ENTROPIC_EXPORT bool entropic::mcp::is_effectively_empty (std::string_view s)
 True if s is empty or contains only ASCII whitespace.
 
ENTROPIC_EXPORT bool entropic::mcp::looks_like_tool_error (std::string_view content)
 Heuristic: the rendered tool-result text reads as an error.
 
ENTROPIC_EXPORT void entropic::mcp::truncate_to_cap (std::string &content, int cap)
 Truncate tool-result content in place when it exceeds cap.
 

Detailed Description

Byte-level classifiers for tool-result content (#44, v2.1.0).

Used by ToolExecutor at the moment a server returns its ServerResponse to map content into ToolResultKind. Pulled out of tool_executor.cpp into a small header so the heuristics are directly unit-testable.

Design notes:
  • "Empty" is purely byte-level (whitespace-only counts). The model's prompt is responsible for interpreting empty in context (e.g. filesystem.grep empty → pivot tools; bash.execute empty → likely side-effect-only success).
  • Error detection covers the common "Error:" / "ERROR:" / "[error]" prefix shapes plus a top-level JSON {"error": …} sniff. False negatives previously surfaced as ToolResultKind::ok and let the model treat error text as success content.
Version
2.1.0

Definition in file tool_result_classify.h.

Function Documentation

◆ is_effectively_empty()

bool entropic::mcp::is_effectively_empty ( std::string_view  s)

True if s is empty or contains only ASCII whitespace.

True if input is empty or contains only ASCII whitespace.

@utility

Version
2.1.0

Definition at line 53 of file tool_result_classify.cpp.

◆ looks_like_tool_error()

bool entropic::mcp::looks_like_tool_error ( std::string_view  content)

Heuristic: the rendered tool-result text reads as an error.

Heuristic match for an error-shaped tool result string.

Recognises (case-insensitively, after stripping leading whitespace):

  • Error: … / ERROR …
  • [error] …
  • top-level { "error": … }

Negative case: "… error somewhere in the middle" is NOT classified as error — only leading-token shapes count.

@utility

Version
2.1.0

@utility

Version
2.1.0

Definition at line 94 of file tool_result_classify.cpp.

◆ truncate_to_cap()

void entropic::mcp::truncate_to_cap ( std::string &  content,
int  cap 
)

Truncate tool-result content in place when it exceeds cap.

Truncate content in place when it exceeds the byte cap.

Demo ask #6 (v2.1.0). When cap is 0, no-op. When content size exceeds cap, the content is shrunk to cap - tail.size() bytes followed by a trailing \\n[... truncated, N more bytes] marker so downstream consumers (the model, classification, the duplicate cache) see the bounded form with a clear signal that bytes were lost. Final size is ≤ cap.

Parameters
contentMutable string; truncated in place when exceeded.
capMaximum byte length. 0 disables. @utility
Version
2.1.1-rc1

@utility

Version
2.1.1-rc1

Definition at line 76 of file tool_result_classify.cpp.