Package com.tnsai.llm.observability
Class ToolSurfaceHasher
java.lang.Object
com.tnsai.llm.observability.ToolSurfaceHasher
Single canonical entry point for building a
ToolSurface from
the raw List<Map<String,Object>> tool shape every framework
caller passes around (issue #79).
Why centralise: ToolSurface.surfaceHash is meaningful only
if every call site hashes the same way. Rolling-our-own JSON serialisation
per provider would silently drift — different key order, different number
formatting — and the hash would split, defeating prompt-cache correlation.
This util uses one Jackson ObjectMapper configured for sorted-key
output so (provider, model, surfaceHash) is a stable cache key.
Tool shape recognised:
- OpenAI / Anthropic flavor — top-level
"function"object with"name"(most providers). - Top-level
"name"key — bare schema dict.
tool[i] so the
hash still differentiates by schema content.- Since:
- 0.9.0 (issue #79)
-
Method Summary
Modifier and TypeMethodDescriptionstatic ToolSurfaceBuild aToolSurfacefrom the raw provider tool list.
-
Method Details
-
from
Build aToolSurfacefrom the raw provider tool list. ReturnsToolSurface.empty()whentoolsis null or empty.
-