agent-starter-pack 0.5.3__py3-none-any.whl → 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agent_starter_pack-0.5.3.dist-info → agent_starter_pack-0.6.1.dist-info}/METADATA +1 -1
- {agent_starter_pack-0.5.3.dist-info → agent_starter_pack-0.6.1.dist-info}/RECORD +59 -33
- agents/adk_base/notebooks/adk_app_testing.ipynb +1 -1
- agents/adk_gemini_fullstack/README.md +148 -0
- agents/adk_gemini_fullstack/app/agent.py +363 -0
- src/frontends/streamlit_adk/frontend/style/app_markdown.py → agents/adk_gemini_fullstack/app/config.py +19 -23
- agents/adk_gemini_fullstack/notebooks/adk_app_testing.ipynb +353 -0
- agents/adk_gemini_fullstack/notebooks/evaluating_adk_agent.ipynb +1528 -0
- agents/adk_gemini_fullstack/template/.templateconfig.yaml +37 -0
- agents/adk_gemini_fullstack/tests/integration/test_agent.py +58 -0
- agents/agentic_rag/notebooks/adk_app_testing.ipynb +1 -1
- src/base_template/Makefile +21 -2
- src/base_template/README.md +8 -3
- src/base_template/pyproject.toml +1 -4
- src/cli/commands/create.py +17 -10
- src/cli/utils/template.py +13 -10
- src/deployment_targets/cloud_run/app/server.py +7 -1
- src/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +1 -1
- src/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +321 -0
- src/frontends/adk_gemini_fullstack/frontend/components.json +21 -0
- src/frontends/adk_gemini_fullstack/frontend/eslint.config.js +28 -0
- src/frontends/adk_gemini_fullstack/frontend/index.html +12 -0
- src/frontends/adk_gemini_fullstack/frontend/package-lock.json +5829 -0
- src/frontends/adk_gemini_fullstack/frontend/package.json +46 -0
- src/frontends/adk_gemini_fullstack/frontend/public/vite.svg +1 -0
- src/frontends/adk_gemini_fullstack/frontend/src/App.tsx +565 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ActivityTimeline.tsx +244 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ChatMessagesView.tsx +419 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/InputForm.tsx +60 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/WelcomeScreen.tsx +56 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/badge.tsx +46 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/button.tsx +59 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/card.tsx +92 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/input.tsx +21 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/scroll-area.tsx +56 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/select.tsx +183 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/tabs.tsx +64 -0
- src/frontends/adk_gemini_fullstack/frontend/src/components/ui/textarea.tsx +18 -0
- src/frontends/adk_gemini_fullstack/frontend/src/global.css +154 -0
- src/frontends/adk_gemini_fullstack/frontend/src/main.tsx +13 -0
- src/frontends/adk_gemini_fullstack/frontend/src/utils.ts +7 -0
- src/frontends/adk_gemini_fullstack/frontend/src/vite-env.d.ts +1 -0
- src/frontends/adk_gemini_fullstack/frontend/tsconfig.json +28 -0
- src/frontends/adk_gemini_fullstack/frontend/tsconfig.node.json +24 -0
- src/frontends/adk_gemini_fullstack/frontend/vite.config.ts +37 -0
- src/resources/locks/uv-adk_base-agent_engine.lock +24 -24
- src/resources/locks/uv-adk_base-cloud_run.lock +24 -24
- src/resources/locks/uv-adk_gemini_fullstack-agent_engine.lock +3217 -0
- src/resources/locks/uv-adk_gemini_fullstack-cloud_run.lock +3513 -0
- src/resources/locks/uv-agentic_rag-agent_engine.lock +88 -85
- src/resources/locks/uv-agentic_rag-cloud_run.lock +124 -119
- src/resources/locks/uv-crewai_coding_crew-agent_engine.lock +94 -91
- src/resources/locks/uv-crewai_coding_crew-cloud_run.lock +130 -125
- src/resources/locks/uv-langgraph_base_react-agent_engine.lock +91 -88
- src/resources/locks/uv-langgraph_base_react-cloud_run.lock +130 -125
- src/resources/locks/uv-live_api-cloud_run.lock +121 -116
- src/frontends/streamlit_adk/frontend/side_bar.py +0 -214
- src/frontends/streamlit_adk/frontend/streamlit_app.py +0 -314
- src/frontends/streamlit_adk/frontend/utils/chat_utils.py +0 -84
- src/frontends/streamlit_adk/frontend/utils/local_chat_history.py +0 -110
- src/frontends/streamlit_adk/frontend/utils/message_editing.py +0 -61
- src/frontends/streamlit_adk/frontend/utils/multimodal_utils.py +0 -223
- src/frontends/streamlit_adk/frontend/utils/stream_handler.py +0 -311
- src/frontends/streamlit_adk/frontend/utils/title_summary.py +0 -129
- {agent_starter_pack-0.5.3.dist-info → agent_starter_pack-0.6.1.dist-info}/WHEEL +0 -0
- {agent_starter_pack-0.5.3.dist-info → agent_starter_pack-0.6.1.dist-info}/entry_points.txt +0 -0
- {agent_starter_pack-0.5.3.dist-info → agent_starter_pack-0.6.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,363 @@
|
|
1
|
+
# Copyright 2025 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
import datetime
|
16
|
+
import logging
|
17
|
+
import os
|
18
|
+
import re
|
19
|
+
from collections.abc import AsyncGenerator
|
20
|
+
from typing import Literal
|
21
|
+
|
22
|
+
import google.auth
|
23
|
+
from google.adk.agents import BaseAgent, LlmAgent, LoopAgent, SequentialAgent
|
24
|
+
from google.adk.agents.callback_context import CallbackContext
|
25
|
+
from google.adk.agents.invocation_context import InvocationContext
|
26
|
+
from google.adk.events import Event, EventActions
|
27
|
+
from google.adk.planners import BuiltInPlanner
|
28
|
+
from google.adk.tools import google_search
|
29
|
+
from google.adk.tools.agent_tool import AgentTool
|
30
|
+
from google.genai import types as genai_types
|
31
|
+
from pydantic import BaseModel, Field
|
32
|
+
|
33
|
+
from .config import config
|
34
|
+
|
35
|
+
_, project_id = google.auth.default()
|
36
|
+
os.environ.setdefault("GOOGLE_CLOUD_PROJECT", project_id)
|
37
|
+
os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global")
|
38
|
+
os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True")
|
39
|
+
|
40
|
+
|
41
|
+
# --- Structured Output Models ---
|
42
|
+
class SearchQuery(BaseModel):
|
43
|
+
"""Model representing a specific search query for web search."""
|
44
|
+
|
45
|
+
search_query: str = Field(
|
46
|
+
description="A highly specific and targeted query for web search."
|
47
|
+
)
|
48
|
+
|
49
|
+
|
50
|
+
class Feedback(BaseModel):
|
51
|
+
"""Model for providing evaluation feedback on research quality."""
|
52
|
+
|
53
|
+
grade: Literal["pass", "fail"] = Field(
|
54
|
+
description="Evaluation result. 'pass' if the research is sufficient, 'fail' if it needs revision."
|
55
|
+
)
|
56
|
+
comment: str = Field(
|
57
|
+
description="Detailed explanation of the evaluation, highlighting strengths and/or weaknesses of the research."
|
58
|
+
)
|
59
|
+
follow_up_queries: list[SearchQuery] | None = Field(
|
60
|
+
default=None,
|
61
|
+
description="A list of specific, targeted follow-up search queries needed to fix research gaps. This should be null or empty if the grade is 'pass'.",
|
62
|
+
)
|
63
|
+
|
64
|
+
|
65
|
+
# --- Callbacks ---
|
66
|
+
def collect_research_sources_callback(callback_context: CallbackContext) -> None:
|
67
|
+
"""Collects and organizes web-based research sources and their supported claims from agent events.
|
68
|
+
|
69
|
+
This function processes the agent's `session.events` to extract web source details (URLs,
|
70
|
+
titles, domains from `grounding_chunks`) and associated text segments with confidence scores
|
71
|
+
(from `grounding_supports`). The aggregated source information and a mapping of URLs to short
|
72
|
+
IDs are cumulatively stored in `callback_context.state`.
|
73
|
+
|
74
|
+
Args:
|
75
|
+
callback_context (CallbackContext): The context object providing access to the agent's
|
76
|
+
session events and persistent state.
|
77
|
+
"""
|
78
|
+
session = callback_context._invocation_context.session
|
79
|
+
url_to_short_id = callback_context.state.get("url_to_short_id", {})
|
80
|
+
sources = callback_context.state.get("sources", {})
|
81
|
+
id_counter = len(url_to_short_id) + 1
|
82
|
+
for event in session.events:
|
83
|
+
if not (event.grounding_metadata and event.grounding_metadata.grounding_chunks):
|
84
|
+
continue
|
85
|
+
chunks_info = {}
|
86
|
+
for idx, chunk in enumerate(event.grounding_metadata.grounding_chunks):
|
87
|
+
if not chunk.web:
|
88
|
+
continue
|
89
|
+
url = chunk.web.uri
|
90
|
+
title = (
|
91
|
+
chunk.web.title
|
92
|
+
if chunk.web.title != chunk.web.domain
|
93
|
+
else chunk.web.domain
|
94
|
+
)
|
95
|
+
if url not in url_to_short_id:
|
96
|
+
short_id = f"src-{id_counter}"
|
97
|
+
url_to_short_id[url] = short_id
|
98
|
+
sources[short_id] = {
|
99
|
+
"short_id": short_id,
|
100
|
+
"title": title,
|
101
|
+
"url": url,
|
102
|
+
"domain": chunk.web.domain,
|
103
|
+
"supported_claims": [],
|
104
|
+
}
|
105
|
+
id_counter += 1
|
106
|
+
chunks_info[idx] = url_to_short_id[url]
|
107
|
+
if event.grounding_metadata.grounding_supports:
|
108
|
+
for support in event.grounding_metadata.grounding_supports:
|
109
|
+
confidence_scores = support.confidence_scores or []
|
110
|
+
chunk_indices = support.grounding_chunk_indices or []
|
111
|
+
for i, chunk_idx in enumerate(chunk_indices):
|
112
|
+
if chunk_idx in chunks_info:
|
113
|
+
short_id = chunks_info[chunk_idx]
|
114
|
+
confidence = (
|
115
|
+
confidence_scores[i] if i < len(confidence_scores) else 0.5
|
116
|
+
)
|
117
|
+
text_segment = support.segment.text if support.segment else ""
|
118
|
+
sources[short_id]["supported_claims"].append(
|
119
|
+
{
|
120
|
+
"text_segment": text_segment,
|
121
|
+
"confidence": confidence,
|
122
|
+
}
|
123
|
+
)
|
124
|
+
callback_context.state["url_to_short_id"] = url_to_short_id
|
125
|
+
callback_context.state["sources"] = sources
|
126
|
+
|
127
|
+
|
128
|
+
def citation_replacement_callback(
|
129
|
+
callback_context: CallbackContext,
|
130
|
+
) -> genai_types.Content:
|
131
|
+
"""Replaces citation tags in a report with Markdown-formatted links.
|
132
|
+
|
133
|
+
Processes 'final_cited_report' from context state, converting tags like
|
134
|
+
`<cite source="src-N"/>` into hyperlinks using source information from
|
135
|
+
`callback_context.state["sources"]`. Also fixes spacing around punctuation.
|
136
|
+
|
137
|
+
Args:
|
138
|
+
callback_context (CallbackContext): Contains the report and source information.
|
139
|
+
|
140
|
+
Returns:
|
141
|
+
genai_types.Content: The processed report with Markdown citation links.
|
142
|
+
"""
|
143
|
+
final_report = callback_context.state.get("final_cited_report", "")
|
144
|
+
sources = callback_context.state.get("sources", {})
|
145
|
+
|
146
|
+
def tag_replacer(match: re.Match) -> str:
|
147
|
+
short_id = match.group(1)
|
148
|
+
if not (source_info := sources.get(short_id)):
|
149
|
+
logging.warning(f"Invalid citation tag found and removed: {match.group(0)}")
|
150
|
+
return ""
|
151
|
+
display_text = source_info.get("title", source_info.get("domain", short_id))
|
152
|
+
return f" [{display_text}]({source_info['url']})"
|
153
|
+
|
154
|
+
processed_report = re.sub(
|
155
|
+
r'<cite\s+source\s*=\s*["\']?\s*(src-\d+)\s*["\']?\s*/>',
|
156
|
+
tag_replacer,
|
157
|
+
final_report,
|
158
|
+
)
|
159
|
+
processed_report = re.sub(r"\s+([.,;:])", r"\1", processed_report)
|
160
|
+
callback_context.state["final_report_with_citations"] = processed_report
|
161
|
+
return genai_types.Content(parts=[genai_types.Part(text=processed_report)])
|
162
|
+
|
163
|
+
|
164
|
+
# --- Custom Agent for Loop Control ---
|
165
|
+
class EscalationChecker(BaseAgent):
|
166
|
+
"""Checks research evaluation and escalates to stop the loop if grade is 'pass'."""
|
167
|
+
|
168
|
+
def __init__(self, name: str):
|
169
|
+
super().__init__(name=name)
|
170
|
+
|
171
|
+
async def _run_async_impl(
|
172
|
+
self, ctx: InvocationContext
|
173
|
+
) -> AsyncGenerator[Event, None]:
|
174
|
+
evaluation_result = ctx.session.state.get("research_evaluation")
|
175
|
+
if evaluation_result and evaluation_result.get("grade") == "pass":
|
176
|
+
logging.info(
|
177
|
+
f"[{self.name}] Research evaluation passed. Escalating to stop loop."
|
178
|
+
)
|
179
|
+
yield Event(author=self.name, actions=EventActions(escalate=True))
|
180
|
+
else:
|
181
|
+
logging.info(
|
182
|
+
f"[{self.name}] Research evaluation failed or not found. Loop will continue."
|
183
|
+
)
|
184
|
+
# Yielding an event without content or actions just lets the flow continue.
|
185
|
+
yield Event(author=self.name)
|
186
|
+
|
187
|
+
|
188
|
+
# --- AGENT DEFINITIONS ---
|
189
|
+
plan_generator = LlmAgent(
|
190
|
+
model=config.worker_model,
|
191
|
+
name="plan_generator",
|
192
|
+
description="Generates a 4-5 line action-oriented research plan, using minimal search only for topic clarification.",
|
193
|
+
instruction=f"""
|
194
|
+
You are a research strategist. Your job is to create a high-level RESEARCH PLAN, not a summary.
|
195
|
+
**RULE: Your output MUST be a bulleted list of 4-5 action-oriented research goals or key questions.**
|
196
|
+
- A good goal starts with a verb like "Analyze," "Identify," "Investigate."
|
197
|
+
- A bad output is a statement of fact like "The event was in April 2024."
|
198
|
+
**TOOL USE IS STRICTLY LIMITED:**
|
199
|
+
Your goal is to create a generic, high-quality plan *without searching*.
|
200
|
+
Only use `google_search` if a topic is ambiguous or time-sensitive and you absolutely cannot create a plan without a key piece of identifying information.
|
201
|
+
You are explicitly forbidden from researching the *content* or *themes* of the topic. That is the next agent's job. Your search is only to identify the subject, not to investigate it.
|
202
|
+
Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
|
203
|
+
""",
|
204
|
+
tools=[google_search],
|
205
|
+
)
|
206
|
+
|
207
|
+
|
208
|
+
section_planner = LlmAgent(
|
209
|
+
model=config.worker_model,
|
210
|
+
name="section_planner",
|
211
|
+
description="Breaks down the research plan into a structured markdown outline of report sections.",
|
212
|
+
instruction="""
|
213
|
+
You are an expert report architect. Using the research topic and the plan from the 'research_plan' state key, design a logical structure for the final report.
|
214
|
+
Your task is to create a markdown outline with 4-6 distinct sections that cover the topic comprehensively without overlap.
|
215
|
+
You can use any markdown format you prefer, but here's a suggested structure:
|
216
|
+
# Section Name
|
217
|
+
A brief overview of what this section covers
|
218
|
+
Feel free to add subsections or bullet points if needed to better organize the content.
|
219
|
+
Make sure your outline is clear and easy to follow.
|
220
|
+
Do not include a "References" or "Sources" section in your outline. Citations will be handled in-line.
|
221
|
+
""",
|
222
|
+
output_key="report_sections",
|
223
|
+
)
|
224
|
+
|
225
|
+
|
226
|
+
section_researcher = LlmAgent(
|
227
|
+
model=config.worker_model,
|
228
|
+
name="section_researcher",
|
229
|
+
description="Performs the crucial first pass of web research.",
|
230
|
+
planner=BuiltInPlanner(
|
231
|
+
thinking_config=genai_types.ThinkingConfig(include_thoughts=True)
|
232
|
+
),
|
233
|
+
instruction="""
|
234
|
+
You are a diligent and exhaustive researcher. Your task is to perform the initial, broad information gathering for a report.
|
235
|
+
You will be provided with a list of sections in the 'report_sections' state key.
|
236
|
+
For each section where 'research' is marked as 'true', generate a comprehensive list of 4-5 targeted search queries to cover the topic from multiple angles.
|
237
|
+
Execute all of these queries using the 'google_search' tool and synthesize the results into a detailed summary for that section.
|
238
|
+
""",
|
239
|
+
tools=[google_search],
|
240
|
+
output_key="section_research_findings",
|
241
|
+
after_agent_callback=collect_research_sources_callback,
|
242
|
+
)
|
243
|
+
|
244
|
+
research_evaluator = LlmAgent(
|
245
|
+
model=config.critic_model,
|
246
|
+
name="research_evaluator",
|
247
|
+
description="Critically evaluates research and generates follow-up queries.",
|
248
|
+
instruction=f"""
|
249
|
+
You are a meticulous quality assurance analyst evaluating the research findings in 'section_research_findings'.
|
250
|
+
|
251
|
+
**CRITICAL RULES:**
|
252
|
+
1. Assume the given research topic is correct. Do not question or try to verify the subject itself.
|
253
|
+
2. Your ONLY job is to assess the quality, depth, and completeness of the research provided *for that topic*.
|
254
|
+
3. Focus on evaluating: Comprehensiveness of coverage, logical flow and organization, use of credible sources, depth of analysis, and clarity of explanations.
|
255
|
+
4. Do NOT fact-check or question the fundamental premise or timeline of the topic.
|
256
|
+
5. If suggesting follow-up queries, they should dive deeper into the existing topic, not question its validity.
|
257
|
+
|
258
|
+
Be very critical about the QUALITY of research. If you find significant gaps in depth or coverage, assign a grade of "fail",
|
259
|
+
write a detailed comment about what's missing, and generate 5-7 specific follow-up queries to fill those gaps.
|
260
|
+
If the research thoroughly covers the topic, grade "pass".
|
261
|
+
|
262
|
+
Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
|
263
|
+
Your response must be a single, raw JSON object validating against the 'Feedback' schema.
|
264
|
+
""",
|
265
|
+
output_schema=Feedback,
|
266
|
+
output_key="research_evaluation",
|
267
|
+
)
|
268
|
+
|
269
|
+
enhanced_search_executor = LlmAgent(
|
270
|
+
model=config.worker_model,
|
271
|
+
name="enhanced_search_executor",
|
272
|
+
description="Executes follow-up searches and integrates new findings.",
|
273
|
+
planner=BuiltInPlanner(
|
274
|
+
thinking_config=genai_types.ThinkingConfig(include_thoughts=True)
|
275
|
+
),
|
276
|
+
instruction="""
|
277
|
+
You are a specialist researcher executing a refinement pass.
|
278
|
+
You have been activated because the previous research was graded as 'fail'.
|
279
|
+
|
280
|
+
1. Review the 'research_evaluation' state key to understand the feedback and required fixes.
|
281
|
+
2. Execute EVERY query listed in 'follow_up_queries' using the 'google_search' tool.
|
282
|
+
3. Synthesize the new findings and COMBINE them with the existing information in 'section_research_findings'.
|
283
|
+
4. Your output MUST be the new, complete, and improved set of research findings.
|
284
|
+
""",
|
285
|
+
tools=[google_search],
|
286
|
+
output_key="section_research_findings",
|
287
|
+
after_agent_callback=collect_research_sources_callback,
|
288
|
+
)
|
289
|
+
|
290
|
+
report_composer = LlmAgent(
|
291
|
+
model=config.critic_model,
|
292
|
+
name="report_composer_with_citations",
|
293
|
+
include_contents="none",
|
294
|
+
description="Transforms research data and a markdown outline into a final, cited report.",
|
295
|
+
instruction="""
|
296
|
+
Transform the provided data into a polished, professional, and meticulously cited research report.
|
297
|
+
|
298
|
+
---
|
299
|
+
### INPUT DATA
|
300
|
+
* Research Plan: `{research_plan}`
|
301
|
+
* Research Findings: `{section_research_findings}`
|
302
|
+
* Citation Sources: `{sources}`
|
303
|
+
* Report Structure: `{report_sections}`
|
304
|
+
|
305
|
+
---
|
306
|
+
### CRITICAL: Citation System
|
307
|
+
To cite a source, you MUST insert a special citation tag directly after the claim it supports.
|
308
|
+
|
309
|
+
**The only correct format is:** `<cite source="src-ID_NUMBER" />`
|
310
|
+
|
311
|
+
---
|
312
|
+
### Final Instructions
|
313
|
+
Generate a comprehensive report using ONLY the `<cite source="src-ID_NUMBER" />` tag system for all citations.
|
314
|
+
The final report must strictly follow the structure provided in the **Report Structure** markdown outline.
|
315
|
+
Do not include a "References" or "Sources" section; all citations must be in-line.
|
316
|
+
""",
|
317
|
+
output_key="final_cited_report",
|
318
|
+
after_agent_callback=citation_replacement_callback,
|
319
|
+
)
|
320
|
+
|
321
|
+
research_pipeline = SequentialAgent(
|
322
|
+
name="research_pipeline",
|
323
|
+
description="Executes a pre-approved research plan. It performs iterative research, evaluation, and composes a final, cited report.",
|
324
|
+
sub_agents=[
|
325
|
+
section_planner,
|
326
|
+
section_researcher,
|
327
|
+
LoopAgent(
|
328
|
+
name="iterative_refinement_loop",
|
329
|
+
max_iterations=config.max_search_iterations,
|
330
|
+
sub_agents=[
|
331
|
+
research_evaluator,
|
332
|
+
EscalationChecker(name="escalation_checker"),
|
333
|
+
enhanced_search_executor,
|
334
|
+
],
|
335
|
+
),
|
336
|
+
report_composer,
|
337
|
+
],
|
338
|
+
)
|
339
|
+
|
340
|
+
interactive_planner_agent = LlmAgent(
|
341
|
+
name="interactive_planner_agent",
|
342
|
+
model=config.worker_model,
|
343
|
+
description="The primary research assistant. It collaborates with the user to create a research plan, and then executes it upon approval.",
|
344
|
+
instruction=f"""
|
345
|
+
You are a research planning assistant. Your primary function is to convert ANY user request into a research plan.
|
346
|
+
|
347
|
+
**CRITICAL RULE: Never answer a question directly or refuse a request.** Your one and only first step is to use the `plan_generator` tool to propose a research plan for the user's topic.
|
348
|
+
If the user asks a question, you MUST immediately call `plan_generator` to create a plan to answer the question.
|
349
|
+
|
350
|
+
Your workflow is:
|
351
|
+
1. **Plan:** Use `plan_generator` to create a draft plan and present it to the user.
|
352
|
+
2. **Refine:** Incorporate user feedback until the plan is approved.
|
353
|
+
3. **Execute:** Once the user gives EXPLICIT approval (e.g., "looks good, run it"), you MUST delegate the task to the `research_pipeline` agent, passing the approved plan.
|
354
|
+
|
355
|
+
Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
|
356
|
+
Do not perform any research yourself. Your job is to Plan, Refine, and Delegate.
|
357
|
+
""",
|
358
|
+
sub_agents=[research_pipeline],
|
359
|
+
tools=[AgentTool(plan_generator)],
|
360
|
+
output_key="research_plan",
|
361
|
+
)
|
362
|
+
|
363
|
+
root_agent = interactive_planner_agent
|
@@ -12,26 +12,22 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
color: !important;
|
35
|
-
}
|
36
|
-
</style>
|
37
|
-
"""
|
15
|
+
from dataclasses import dataclass
|
16
|
+
|
17
|
+
|
18
|
+
@dataclass
|
19
|
+
class ResearchConfiguration:
|
20
|
+
"""Configuration for research-related models and parameters.
|
21
|
+
|
22
|
+
Attributes:
|
23
|
+
critic_model (str): Model for evaluation tasks.
|
24
|
+
worker_model (str): Model for working/generation tasks.
|
25
|
+
max_search_iterations (int): Maximum search iterations allowed.
|
26
|
+
"""
|
27
|
+
|
28
|
+
critic_model: str = "gemini-2.5-pro"
|
29
|
+
worker_model: str = "gemini-2.5-flash"
|
30
|
+
max_search_iterations: int = 5
|
31
|
+
|
32
|
+
|
33
|
+
config = ResearchConfiguration()
|