Skip to content

Append tool usage instructions to system prompt when creating LLM instances#88

Merged
0xba1a merged 2 commits intomainfrom
copilot/append-tool-usage-instructions
Dec 30, 2025
Merged

Append tool usage instructions to system prompt when creating LLM instances#88
0xba1a merged 2 commits intomainfrom
copilot/append-tool-usage-instructions

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

The Tool.usage_instructions_to_llm field was being ignored when initializing LLM instances, preventing tools from providing usage guidance to the model.

Changes

  • Modified _create_llm() in MicroBot.py: Concatenate all tool usage instructions to the system prompt before passing to LLM constructors (OpenAI, Anthropic, OllamaLocal)
  • Added unit tests: Verify single/multiple tool instructions are appended correctly and system prompt remains unchanged when no tools provided

Example

tool = Tool(
    name="cscope",
    usage_instructions_to_llm="# Non-interactive cscope usage\ncscope -L <query_type> <symbol>",
    # ... other fields
)

bot = MicroBot(
    model="anthropic/claude-sonnet-4",
    system_prompt="You are a helpful assistant.",
    additional_tools=[tool]
)

# bot.llm.system_prompt now contains:
# "You are a helpful assistant.\n\n# Non-interactive cscope usage\ncscope -L <query_type> <symbol>"
Original prompt

This section details on the original issue you should resolve

<issue_title>Append tool usage instructions in system prompt before creating LLM messages</issue_title>
<issue_description>Tool usage instructions are not considered while passing system prompt to LLM.</issue_description>

<agent_instructions>Class Tool in tool.py is getting an argument as usage_instructions_to_llm from the client application. That value should be appended to the system prompt before the system prompt in the _create_llm function. Check this and fix it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: 0xba1a <2942888+0xba1a@users.noreply.github.com>
Copilot AI changed the title [WIP] Append tool usage instructions to system prompt Append tool usage instructions to system prompt when creating LLM instances Dec 30, 2025
Copilot AI requested a review from 0xba1a December 30, 2025 15:33
@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.97%. Comparing base (1a2d77b) to head (c9934ab).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
+ Coverage   91.80%   91.97%   +0.17%     
==========================================
  Files          21       21              
  Lines         805      810       +5     
==========================================
+ Hits          739      745       +6     
+ Misses         66       65       -1     
Flag Coverage Δ
integration 60.24% <40.00%> (+0.12%) ⬆️
ollama_local 65.55% <40.00%> (-0.16%) ⬇️
slow-browser 55.92% <100.00%> (+1.14%) ⬆️
slow-other 71.11% <40.00%> (+0.30%) ⬆️
unit 65.67% <100.00%> (+3.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/microbots/MicroBot.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0xba1a 0xba1a marked this pull request as ready for review December 30, 2025 16:08
@0xba1a 0xba1a merged commit 167ed59 into main Dec 30, 2025
7 checks passed
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.

Append tool usage instructions in system prompt before creating LLM messages

4 participants