NAME

Langertha::Role::HermesTools - Hermes-style tool calling via XML tags

VERSION

version 0.503

SYNOPSIS

package Langertha::Engine::MyEngine;
use Moose;
extends 'Langertha::Engine::Remote';

with 'Langertha::Role::Tools';
with 'Langertha::Role::HermesTools';

sub _build_tool_wire_format { 'hermes' }

DESCRIPTION

This role configures Hermes-style tool calling: instead of using an API's native tools parameter, tool definitions are injected into the system prompt as <tools> XML and the model responds with <tool_call> XML tags containing JSON. This works with any chat model regardless of native tool API support.

The behaviour itself lives in the tag-driven defaults of Langertha::Role::Tools (selected by tool_wire_format => 'hermes'). This role now only carries the Hermes-specific configuration those defaults read: the call/response tag names ("hermes_call_tag", "hermes_response_tag"), the prompt template ("hermes_tool_prompt"), and the response-content extractor ("hermes_extract_content"). Compose it alongside Langertha::Role::Tools and set _build_tool_wire_format to 'hermes'.

The hermes wire has no tools, tool_choice or parallel_tool_calls body key, so the role clears tools_native, tool_choice_any, tool_choice_named and parallel_tool_use from "engine_capabilities" in Langertha::Role::Capabilities; tools_hermes, tool_choice_auto and tool_choice_none stay.

hermes_call_tag

hermes_call_tag => 'function_call'

The XML tag name used for tool calls in the model's output. Both the prompt template and the response parser use this tag. Defaults to tool_call.

hermes_response_tag

hermes_response_tag => 'function_response'

The XML tag name used when sending tool results back to the model. Defaults to tool_response.

hermes_tool_instructions

hermes_tool_instructions => 'You are a helpful assistant that can call functions.'

The instruction text prepended to the Hermes tool system prompt. Customize this to change the model's behavior without altering the structural XML template. The default instructs the model to call functions without making assumptions about argument values.

hermes_tool_prompt

The full system prompt template used for Hermes tool calling. Must contain a %s placeholder where the tools JSON will be inserted. Built automatically from "hermes_tool_instructions" and "hermes_call_tag". Override this only if you need full control over the prompt structure.

hermes_extract_content

my $content = $self->hermes_extract_content($data);

Extracts raw text content from a parsed LLM response for Hermes tool call parsing. Defaults to OpenAI response format (choices[0].message.content). Override this method in engines with non-OpenAI response structures.

hermes_schema_prompt

The system prompt template for Hermes structured output, in the form of the Hermes function-calling prompt format. Must contain a %s placeholder where the JSON schema is inserted. "chat_f" in Langertha::Role::Chat and "chat_stream_realtime_f" in Langertha::Role::Chat put it in front of the conversation for every json_schema response_format on a hermes engine that takes response_format (including the rewrite of a forced tool), so a backend that ignores response_format still sees the schema.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.