feat(tools): add consult tool — second opinion from a reference model - #82103
Open
adurham wants to merge 1 commit into
Open
feat(tools): add consult tool — second opinion from a reference model#82103adurham wants to merge 1 commit into
adurham wants to merge 1 commit into
Conversation
Lets the agent (main or delegated subagent) ask a configurable reference
model for a second opinion on a specific, bounded question before
committing to something risky or uncertain -- sanity-check a plan, review
a diff for structural issues, or get a pointed answer on a genuinely
uncertain judgment call. Not for routine work; it costs one full call to
a (usually more expensive, sometimes slower) model.
Routes through the existing agent.auxiliary_client.call_llm plumbing with
task="consult", configured via auxiliary.consult in config.yaml
independently of the main chat model -- the canonical use case is
pointing it at an expensive frontier model that would make a bad MAIN
model (slow, prone to over-cautious refusals) but is a great second
opinion for a narrow question.
Design: a plain registry tool with no agent-loop state, same shape as
vision_analyze -- it just wraps call_llm. Refusals and empty responses
from the reference model are NOT exceptions; they degrade to
{"unavailable": true, "reason": "..."} so the calling agent proceeds on
its own judgment instead of stalling or retrying in a loop. Reasoning-
heavy or safety-tuned models refuse often enough that this has to be a
first-class outcome, not an error path. Also guards against a real
observed failure shape: a local/open-weight aux model returning the
consult request itself (wrapped in raw tool-call template markup) as its
"answer", which a naive caller would paraphrase and present as a
fabricated reference-model opinion -- _degenerate_answer_reason() detects
both leaked template markup and high-similarity echoes and forces
unavailable=true rather than a garbage answer.
Registered as a new opt-in "consult" toolset (not added to
_HERMES_CORE_TOOLS), matching how vision/video are opt-in rather than
always-on -- keeps the narrow-waist core tool schema unaffected for
users who don't enable it.
Auto-discovered by tools/registry.py's existing module-scan mechanism;
no additional core wiring needed beyond the new file + one toolsets.py
entry.
Tests: 19 in tests/tools/test_consult_tool.py (success path, graceful
degradation on refusal/empty/malformed-response/call-exception,
question/context truncation, registry registration + dispatch, toolset
resolution) + 6 in tests/tools/test_consult_degenerate_guard.py (template-
markup leak, plain echo, leading control token, real answer passes, short
answers not falsely flagged, incidental sentinel mention passes).
Verified: ruff clean; 86/86 across the new tests + tests/test_toolsets.py
+ tests/tools/test_registry.py; live boot smoke test confirms the tool
auto-registers with zero manual wiring (import model_tools; registry.
get_entry("consult") is not None). Searched issues/PRs first -- no
existing report or competing PR for this tool.
adurham
pushed a commit
to adurham/hermes-agent
that referenced
this pull request
Aug 9, 2026
…ch#82103) De-forked tools/consult_tool.py (stripped Fable/DSML-specific wording, verified auxiliary_client.call_llm is genuinely shared infra, registered as an opt-in toolset instead of always-on core per upstream's narrow- waist philosophy). The periodic-nudge companion stays fork-only -- depends on agent/fork/skill_recall.py infrastructure with no upstream equivalent.
Contributor
|
This was generated by AI during triage. Summary: Problems:
Solution: Checked against |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets the agent (main or delegated subagent) ask a configurable reference model for a second opinion on a specific, bounded question before committing to something risky or uncertain — sanity-check a plan, review a diff for structural issues, or get a pointed answer on a genuinely uncertain judgment call. Not for routine work; it costs one full call to a (usually more expensive, sometimes slower) model.
Routes through the existing
agent.auxiliary_client.call_llmplumbing withtask="consult", configured viaauxiliary.consultinconfig.yamlindependently of the main chat model — the canonical use case is pointing it at an expensive frontier model that would make a bad MAIN model (slow, prone to over-cautious refusals) but is a great second opinion for a narrow question.Design
A plain registry tool with no agent-loop state, same shape as
vision_analyze— it just wrapscall_llm. Refusals and empty responses from the reference model are not exceptions; they degrade to{"unavailable": true, "reason": "..."}so the calling agent proceeds on its own judgment instead of stalling or retrying in a loop. Reasoning-heavy or safety-tuned models refuse often enough that this has to be a first-class outcome, not an error path.Also guards against a real observed failure shape: a local/open-weight aux model returning the consult request itself (wrapped in raw tool-call template markup) as its "answer", which a naive caller would paraphrase and present as a fabricated reference-model opinion.
_degenerate_answer_reason()detects both leaked template markup and high-similarity echoes and forcesunavailable=truerather than a garbage answer.Registered as a new opt-in
"consult"toolset (not added to_HERMES_CORE_TOOLS), matching howvision/videoare opt-in rather than always-on — keeps the narrow-waist core tool schema unaffected for users who don't enable it.Auto-discovered by
tools/registry.py's existing module-scan mechanism (anytools/*.pyfile that callsregistry.register()at module level); no additional core wiring needed beyond the new file + onetoolsets.pyentry.Test plan
tests/tools/test_consult_tool.py: success path, graceful degradation on refusal/empty/malformed-response/call-exception, question/context truncation, registry registration + dispatch, toolset resolution.tests/tools/test_consult_degenerate_guard.py: template-markup leak, plain echo, leading control token, real answer passes, short answers not falsely flagged, incidental sentinel mention passes.ruff checkclean.tests/test_toolsets.py+tests/tools/test_registry.py.import model_tools; registry.get_entry("consult") is not None→True,toolset == "consult".Searched existing issues/PRs first — no existing report or competing PR for this tool.