Skip to content

refactor(llm): drop dead tool-doc path from GemmaPromptHelper - #594

Open
alexisjamet wants to merge 1 commit into
mainfrom
593-gemma-prompt-helper-dead-code
Open

refactor(llm): drop dead tool-doc path from GemmaPromptHelper#594
alexisjamet wants to merge 1 commit into
mainfrom
593-gemma-prompt-helper-dead-code

Conversation

@alexisjamet

Copy link
Copy Markdown
Contributor

Closes #593

What

GemmaPromptHelper.appendToolsToPrompt built a list of tool docs via convertToolsToDocs, early-returned on it, then never used it. All it actually did was inject an unrelated instruction about nullable tool-argument fields. Gemma receives tool definitions through native function calling on the OpenAI-compatible endpoint, so nothing was ever appended to the prompt — the name was inherited from MistralPromptHelper, which does genuinely list tools in-prompt.

  • Renamed to injectNullValueInstruction, which is what it does.
  • Deleted GemmaPromptHelper.convertToolsToDocs (it carried a FIXME: not used anymore).
  • Kept the "skip when there are no tools" behaviour, but stated it directly rather than having it fall out of an empty tool-docs list — the previous coupling meant an empty tool set silently skipped an instruction that has nothing to do with tool docs.

Behaviour

Unchanged. The instruction is injected under exactly the same condition as before (tool set non-empty, and the prompt contains the response-language heading).

Not removed

jsonSchemaToArgumentString looks dead from within this file but is not — ai-sdk-med-gemma.provider.ts:78 reuses it, because MedGemma does render tool docs in-prompt for its JSON tool-call protocol. Added a doc comment so it is not mistaken for dead code again.

Notes

The remaining FIXME is reworded rather than resolved: the injection still anchors on a substring of the master prompt (## Response language:\nAlways answer in) and is silently dropped if that heading ever changes. Out of scope here, but worth its own issue if it matters.

Added a regression test asserting the prompt does not contain tool descriptions, so the Mistral-style listing cannot creep back in.

🤖 Generated with Claude Code

appendToolsToPrompt built a list of tool docs, discarded it, and only
injected an unrelated instruction about nullable argument fields — Gemma
receives tool definitions through native function calling, so nothing was
ever appended. The name described the Mistral helper this was copied from,
not what it does.

Rename to injectNullValueInstruction and delete convertToolsToDocs. The
"skip when there are no tools" behaviour is preserved but stated directly
instead of falling out of an empty tool-docs list.

jsonSchemaToArgumentString stays: the MedGemma provider does render tool
docs in-prompt and reuses it. Documented so it is not mistaken for dead
code next time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GemmaPromptHelper.appendToolsToPrompt computes tool docs and discards them

1 participant