Skip to content

Conversation

@nebrass
Copy link

@nebrass nebrass commented Jan 5, 2026

Summary

This PR implements the ReasoningBank feature based on the paper "Reasoning-Bank: Learning from the Traces of Thought" (arXiv:2509.25140).

What is ReasoningBank?

ReasoningBank enables agents to store and retrieve proven reasoning strategies, allowing them to learn from past successful task executions and apply those approaches to new, similar problems.

Components Added

Data Models (com.google.adk.reasoning):

  • ReasoningStrategy - Immutable model representing a distilled reasoning approach with problem pattern, steps, and tags
  • ReasoningTrace - Captures raw task execution data (task, output, reasoning steps)
  • SearchReasoningResponse - Response model for strategy search

Service Layer:

  • BaseReasoningBankService - Interface defining store and search operations
  • InMemoryReasoningBankService - In-memory implementation using keyword matching with weighted scoring

Tool Integration (com.google.adk.tools):

  • LoadReasoningStrategyTool - Function tool enabling agents to search and load relevant strategies
  • LoadReasoningStrategyResponse - Tool response record

Context Integration:

  • Added reasoningBankService field to InvocationContext
  • Added searchReasoningStrategies() method to ToolContext

Usage Example

// Create and configure service
BaseReasoningBankService reasoningBank = new InMemoryReasoningBankService();

// Store a strategy
ReasoningStrategy strategy = ReasoningStrategy.builder()
    .id("math-strategy")
    .name("Math Problem Solving")
    .problemPattern("Mathematical word problems")
    .steps(ImmutableList.of("Identify unknowns", "Set up equations", "Solve"))
    .build();
reasoningBank.storeStrategy("myApp", strategy).blockingAwait();

// Configure agent with reasoning bank
InvocationContext context = InvocationContext.builder()
    .reasoningBankService(reasoningBank)
    // ... other config
    .build();

Test Plan

  • Unit tests for ReasoningStrategy (5 tests)
  • Unit tests for ReasoningTrace (5 tests)
  • Unit tests for InMemoryReasoningBankService (10 tests)
  • All existing tests pass (793 tests total)

Related

@google-cla
Copy link

google-cla bot commented Jan 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @nebrass, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the foundational ReasoningBank feature, designed to enhance agent capabilities by allowing them to learn from and reuse successful problem-solving approaches. By providing mechanisms to store and retrieve distilled reasoning strategies and raw execution traces, agents can apply proven methods to new, similar tasks, thereby improving their efficiency and effectiveness. The implementation includes core data models, a service interface with an in-memory prototype, and seamless integration into the existing tool and invocation contexts.

Highlights

  • New Feature: ReasoningBank: Introduces the ReasoningBank feature, enabling agents to store and retrieve proven reasoning strategies, based on the 'Reasoning-Bank: Learning from the Traces of Thought' paper.
  • New Data Models: Added ReasoningStrategy (for distilled reasoning approaches), ReasoningTrace (for raw task execution data), and SearchReasoningResponse (for strategy search results).
  • Service Layer Implementation: Defined BaseReasoningBankService interface and provided an InMemoryReasoningBankService implementation for prototyping, utilizing keyword matching for strategy retrieval.
  • Tool Integration: Integrated LoadReasoningStrategyTool as a function tool, allowing agents to search for and load relevant strategies, along with its corresponding LoadReasoningStrategyResponse.
  • Context Updates: Modified InvocationContext to include the reasoningBankService and ToolContext to expose a searchReasoningStrategies() method for agent access.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@nebrass nebrass force-pushed the feature/reasoning-bank branch from e874b9e to 37a1f5c Compare January 5, 2026 14:19
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a ReasoningBank feature, which is a significant and well-implemented addition. The new components, including data models, services, and tool integrations, are clearly defined and follow the existing architectural patterns of the project. The code is well-documented and accompanied by a comprehensive set of unit tests, ensuring the new functionality is robust. I have a couple of minor suggestions for code refinement in the InMemoryReasoningBankService to improve conciseness and use more idiomatic Java constructs, but overall, this is excellent work.

Implements ReasoningBank feature based on arXiv:2509.25140 paper.

Core components:
- ReasoningStrategy: distilled, reusable reasoning approach
- ReasoningTrace: captures raw task execution data
- BaseReasoningBankService: interface for storage/retrieval
- InMemoryReasoningBankService: in-memory implementation with keyword matching
- LoadReasoningStrategyTool: tool for agents to retrieve relevant strategies
- SearchReasoningResponse: response model for strategy search

Integration:
- Added reasoningBankService to InvocationContext
- Added searchReasoningStrategies() to ToolContext

Includes 20 unit tests covering data models and service functionality.
@nebrass nebrass force-pushed the feature/reasoning-bank branch from 37a1f5c to c29b9c6 Compare January 5, 2026 14:23
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.

1 participant