Hard-coded `new InMemoryRunner(...)` prevents injection and custom runner implementations
@hemasekhar-p đang làm issue này rồi.
Từ ngày 14/1/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
In the current implementation of AgentTool.runAsync(...), the runner instance is created directly via constructor:
Runner runner = new InMemoryRunner(this.agent, toolContext.agentName());
This introduces a structural limitation:
the code forces a specific runner implementation and does not allow the caller to provide their own Runner or override behaviour.
Why this is problematic
-
No ability to inject alternative Runner implementations
Any attempt to replaceInMemoryRunner(e.g., with a distributed runner, persistent runner, mocked test runner, or custom lifecycle-managed runner) becomes impossible. The hard-codedneweliminates extensibility. -
Loss of execution context
The runner manages sessions and state. By creating it directly inside the tool, the execution context may diverge from the tool context, especially when session/state lifecycles are coordinated elsewhere in the system.
This can lead to unexpected state resets or inconsistent flow. -
Unexpected or non-deterministic behaviour
When tooling relies on a specific execution model, but the tool enforcesInMemoryRunner, callers may get results that differ from their expected environment (e.g., summarization rules, session persistence, or event pipelines). -
Violation of dependency-injection principles
The tool is not inversion-of-control–friendly, which makes it harder to integrate into larger orchestrators or frameworks.
Proposed solution
Two possible fixes:
A. Inject runner instance externally
E.g. pass Runner via constructor or provide a RunnerFactory:
public AgentTool(BaseAgent agent, boolean skipSummarization, RunnerFactory factory) {
this.runnerFactory = factory;
}
This keeps the tool composable, testable, and compatible with custom infrastructures.
B. If only a single atomic action is required, avoid the full Runner and call the LLM directly
If the intention is to execute a one-off LLM request without full agent orchestration, then using a full Runner is unnecessary overhead.
A direct LLM call would be more predictable, cheaper, and avoids unwanted runner logic (session creation, events, summarization pipelines, etc.).
Please review
If the current implementation has hidden assumptions requiring InMemoryRunner specifically, or if there are constraints that justify not injecting it, then please adjust this issue accordingly. Otherwise, replacing the direct constructor call with a proper injection mechanism will make the system more modular and avoid context inconsistencies in the future.
- Ngôn ngữ chính
- Java
- Star
- 1.7k
- Fork
- 421
- Merge trung bình
- 3 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 36
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-java
-
needs review
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
needs review
-
needs review
-
needs review
-
needs review
Tất cả issue của google/adk-java
Issue tương tự
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Đang mởarea/plugin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Add canonical URLs and a sitemap Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/rocketmq-dashboard#5064 ·