Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Jan 22, 2026

feat: new ContextFilterPlugin

Introduces a new ContextFilterPlugin in Java, which is designed to reduce the size of the LLM context by filtering out older turns.

Here's a breakdown:

  • ContextFilterPlugin.java: This new plugin extends BasePlugin and implements logic in its beforeModelCallback method. It trims the LlmRequest contents to retain only a specified number of the most recent "model" turns and their preceding "user" turns. A key aspect is the adjustSplitIndexToAvoidOrphanedFunctionResponses method, which ensures that any FunctionResponse included in the filtered context has its corresponding FunctionCall also present, preventing invalid inputs to the LLM.
  • ContextFilterPluginTest.java: This file contains unit tests for ContextFilterPlugin, verifying its behavior for both scenarios where context filtering is not needed and where it successfully reduces the LlmRequest contents based on the configured number of invocations to keep.

@copybara-service copybara-service bot force-pushed the test_859380380 branch 8 times, most recently from f053993 to c40b7f9 Compare January 22, 2026 21:12
@copybara-service copybara-service bot changed the title feat: new Plugins feat: new ContextFilterPlugin Jan 22, 2026
@copybara-service copybara-service bot force-pushed the test_859380380 branch 7 times, most recently from 4df9609 to fef87eb Compare January 26, 2026 18:16
@copybara-service copybara-service bot closed this Jan 26, 2026
@copybara-service copybara-service bot deleted the test_859380380 branch January 26, 2026 18:27
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.

0 participants