Skip to content

Conversation

@edwardzjl
Copy link
Owner

Which also counts in the system message, including tool schemas

Pull Request Checklist

  • Test cases added for changed code.

Describe what you have changed in this PR.

Which also counts in the system message, including tool schemas
@edwardzjl edwardzjl requested a review from Copilot July 4, 2025 15:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors the tool picker and chatbot initiation to use the trim_messages runnable and centralized token management instead of manually slicing message lists.

  • Introduces trim_messages runnable in create_tool_picker and chatbot pipeline.
  • Adds token_counter and context_length parameters with resolve_token_management_params.
  • Removes manual trimming of windowed_messages in __init__.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
api/chatbot/agent/toolpicker.py Added trim_messages runnable, token management parameters, and extracted system instruction.
api/chatbot/agent/init.py Chained trim_messages into the prompt runnable pipeline and removed manual windowed trimming.
Comments suppressed due to low confidence (3)

api/chatbot/agent/toolpicker.py:23

  • Add a docstring explaining the new token_counter and context_length parameters and their expected behavior to aid maintainability and user understanding.
def create_tool_picker(

api/chatbot/agent/toolpicker.py:64

  • No test cases cover the new trimming behavior; please add tests to verify that trim_messages correctly limits tokens and retains system/human messages as intended.
    trimmer = trim_messages(

api/chatbot/agent/toolpicker.py:17

  • [nitpick] The constant name SYS_INST is terse and may be unclear; consider renaming to something more descriptive like SYSTEM_INSTRUCTION or TOOL_PICKER_INSTRUCTION.
SYS_INST = """You are a helpful assistant with access to a set of tools. Use them only when truly necessary.

@edwardzjl edwardzjl merged commit c81e364 into main Jul 4, 2025
7 checks passed
@edwardzjl edwardzjl deleted the tr branch July 4, 2025 15:19
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.

2 participants